commit:     d428c50a040b5ae00ec1d0fc38769565108c5d24
Author:     Adrian Moennich <adrian <AT> planetcoding <DOT> net>
AuthorDate: Sat Sep  5 22:21:37 2020 +0000
Commit:     Patrice Clement <monsieurp <AT> gentoo <DOT> org>
CommitDate: Thu Nov 12 21:28:42 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d428c50a

dev-util/watchman: new package.

Watchman is a file watching service.

Signed-off-by: Adrian Moennich <adrian <AT> planetcoding.net>
Package-Manager: Portage-3.0.4, Repoman-3.0.1
Closes: https://github.com/gentoo/gentoo/pull/17433
Signed-off-by: Patrice Clement <monsieurp <AT> gentoo.org>

 dev-util/watchman/Manifest                  |  1 +
 dev-util/watchman/files/4.9.0-changes.patch | 80 +++++++++++++++++++++++++++++
 dev-util/watchman/files/4.9.0-python3.patch | 65 +++++++++++++++++++++++
 dev-util/watchman/metadata.xml              | 22 ++++++++
 dev-util/watchman/watchman-4.9.0.ebuild     | 61 ++++++++++++++++++++++
 5 files changed, 229 insertions(+)

diff --git a/dev-util/watchman/Manifest b/dev-util/watchman/Manifest
new file mode 100644
index 00000000000..8faca46f3e0
--- /dev/null
+++ b/dev-util/watchman/Manifest
@@ -0,0 +1 @@
+DIST watchman-4.9.0.tar.gz 3508045 BLAKE2B 
413b779f02736442c371af1d9e18e5c84f05f9e9465c114dc4bdf79cbc1d823f1ad3167abef22818652a924ca2cb563c54d18f7599b987f579655d8a2b82162a
 SHA512 
3c1222ba41383b26c2c427415e75abdb4bef5a95001438c3debe7cf3ca654944ecf08e432c5ad0aefa2a6554ae73ff0f6995e7f4ee61cdb2cde80f8378d3a704

diff --git a/dev-util/watchman/files/4.9.0-changes.patch 
b/dev-util/watchman/files/4.9.0-changes.patch
new file mode 100644
index 00000000000..4625bc81553
--- /dev/null
+++ b/dev-util/watchman/files/4.9.0-changes.patch
@@ -0,0 +1,80 @@
+diff -ru old/python/bin/watchman-make new/python/bin/watchman-make
+--- old/python/bin/watchman-make       2020-09-06 11:36:12.202435809 +0200
++++ new/python/bin/watchman-make       2020-09-06 11:36:14.105482419 +0200
+@@ -55,7 +55,14 @@
+         data = client.getSubscription(self.name)
+         if data is None:
+             return
+-        self.triggered = True
++        for item in data:
++            # We only want to trigger if files matched;
++            # updates without a files list are metadata
++            # such as state-enter/leave notices so we skip them
++            if 'files' in item:
++                self.triggered = True
++            if 'canceled' in item:
++                raise RuntimeError('Watch was cancelled')
+
+     def execute(self):
+         if not self.triggered:
+@@ -165,6 +172,11 @@
+ parser.add_argument('-r', '--run', type=str, help="""
+ The script that should be run when changes are detected
+ """)
++parser.add_argument('--connect-timeout', type=float, default=600, help="""
++Initial watchman client connection timeout. It should be sufficiently large to
++prevent timeouts when watchman is busy (eg. performing a crawl). The default
++value is 600 seconds.
++""")
+ args = parser.parse_args()
+
+ if args.target is None and args.run is None:
+@@ -187,7 +199,7 @@
+         sys.exit(1)
+
+ targets = {}
+-client = pywatchman.client(timeout=600)
++client = pywatchman.client(timeout=args.connect_timeout)
+ try:
+     client.capabilityCheck(
+         required=['cmd-watch-project', 'wildmatch'])
+diff -ru old/python/bin/watchman-wait new/python/bin/watchman-wait
+--- old/python/bin/watchman-wait       2020-09-06 11:36:12.202435809 +0200
++++ new/python/bin/watchman-wait       2020-09-06 11:36:14.106482444 +0200
+@@ -76,6 +76,11 @@
+ Exit if no events trigger within the specified timeout.  If timeout is
+ zero (the default) then keep running indefinitely.
+ """)
++parser.add_argument('--connect-timeout', type=float, default=100, help="""
++Initial watchman client connection timeout. It should be sufficiently large to
++prevent timeouts when watchman is busy (eg. performing a crawl). The default
++value is 100 seconds.
++""")
+ args = parser.parse_args()
+
+
+@@ -141,7 +146,7 @@
+     def formatField(self, fname, val):
+         if fname == 'name':
+             # Respect the --relative path printing option
+-            return os.path.relpath(val, args.relative)
++            return os.path.relpath(os.path.join(self.name, val), 
args.relative)
+         # otherwise just make sure it's a string so that we can join it
+         return str(val)
+
+@@ -173,12 +178,13 @@
+ for path in args.path:
+     sub = Subscription(path)
+
++# and start up the client + subscriptions
++client = pywatchman.client(timeout=args.connect_timeout)
++
+ deadline = None
+ if args.timeout > 0:
+     deadline = time.time() + args.timeout
+
+-# and start up the client + subscriptions
+-client = pywatchman.client()
+ try:
+     client.capabilityCheck(
+         required=['term-dirname', 'cmd-watch-project', 'wildmatch'])

diff --git a/dev-util/watchman/files/4.9.0-python3.patch 
b/dev-util/watchman/files/4.9.0-python3.patch
new file mode 100644
index 00000000000..5b416f24ae4
--- /dev/null
+++ b/dev-util/watchman/files/4.9.0-python3.patch
@@ -0,0 +1,65 @@
+diff -ru backup/old/python/bin/watchman-make old/python/bin/watchman-make
+--- backup/old/python/bin/watchman-make        2020-09-06 11:33:34.449582111 
+0200
++++ old/python/bin/watchman-make       2020-09-06 11:33:43.473801969 +0200
+@@ -100,7 +100,7 @@
+             targets = []
+             setattr(namespace, self.dest, targets)
+ 
+-        if isinstance(values, basestring):
++        if isinstance(values, (str, bytes)):
+             values = [values]
+ 
+         if namespace.pattern is None or len(namespace.pattern) == 0:
+@@ -209,7 +209,7 @@
+         client.setTimeout(600)
+ 
+         result = client.receive()
+-        for _, t in targets.iteritems():
++        for _, t in targets.items():
+             t.consumeEvents(client)
+ 
+         # Now we wait for events to settle
+@@ -218,7 +218,7 @@
+         while not settled:
+             try:
+                 result = client.receive()
+-                for _, t in targets.iteritems():
++                for _, t in targets.items():
+                     t.consumeEvents(client)
+             except pywatchman.SocketTimeout as ex:
+                 # Our short settle timeout hit, so we're now settled
+@@ -226,7 +226,7 @@
+                 break
+ 
+         # Now we can work on executing the targets
+-        for _, t in targets.iteritems():
++        for _, t in targets.items():
+             t.execute()
+ 
+         # Print this at the bottom of the loop rather than the top
+@@ -249,4 +249,3 @@
+     except KeyboardInterrupt:
+         # suppress ugly stack trace when they Ctrl-C
+         break
+-
+diff -ru backup/old/python/bin/watchman-wait old/python/bin/watchman-wait
+--- backup/old/python/bin/watchman-wait        2020-09-06 11:33:34.449582111 
+0200
++++ old/python/bin/watchman-wait       2020-09-06 11:33:43.473801969 +0200
+@@ -182,7 +182,7 @@
+ try:
+     client.capabilityCheck(
+         required=['term-dirname', 'cmd-watch-project', 'wildmatch'])
+-    for _, sub in subscriptions.iteritems():
++    for _, sub in subscriptions.items():
+         sub.start(client)
+ 
+ except pywatchman.CommandError as ex:
+@@ -200,7 +200,7 @@
+         # the client object will accumulate all subscription results
+         # over time, so we ask it to remove and return those values
+         # for each of the subscriptions
+-        for _, sub in subscriptions.iteritems():
++        for _, sub in subscriptions.items():
+             sub.emit(client)
+ 
+     except pywatchman.SocketTimeout as ex:

diff --git a/dev-util/watchman/metadata.xml b/dev-util/watchman/metadata.xml
new file mode 100644
index 00000000000..57a0732b555
--- /dev/null
+++ b/dev-util/watchman/metadata.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM 'http://www.gentoo.org/dtd/metadata.dtd'>
+<pkgmetadata>
+       <maintainer type="person">
+        <email>[email protected]</email>
+               <name>Patrice Clement</name>
+       </maintainer>
+       <maintainer type="person">
+               <email>[email protected]</email>
+               <name>Adrian Moennich</name>
+       </maintainer>
+       <maintainer type="project">
+               <email>[email protected]</email>
+               <name>Proxy Maintainers</name>
+       </maintainer>
+       <upstream>
+               <remote-id type="github">facebook/watchman</remote-id>
+       </upstream>
+       <use>
+               <flag name="python">Install pywatchman bindings and the 
watchman-{wait,make} utils</flag>
+       </use>
+</pkgmetadata>

diff --git a/dev-util/watchman/watchman-4.9.0.ebuild 
b/dev-util/watchman/watchman-4.9.0.ebuild
new file mode 100644
index 00000000000..ca3006fbc0c
--- /dev/null
+++ b/dev-util/watchman/watchman-4.9.0.ebuild
@@ -0,0 +1,61 @@
+# Copyright 2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+PYTHON_COMPAT=( python3_{6,7,8} )
+inherit autotools distutils-r1
+
+COMMIT="8e0ba724d85de2c89f48161807e878667b9ed089"  # v4.9.0 tag
+DESCRIPTION="A file watching service"
+HOMEPAGE="https://facebook.github.io/watchman/";
+SRC_URI="https://github.com/facebook/watchman/archive/${COMMIT}.tar.gz -> 
${P}.tar.gz"
+S="${WORKDIR}/${PN}-${COMMIT}"
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="pcre python"
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+
+RDEPEND="pcre? ( dev-libs/libpcre )
+       python? ( ${PYTHON_DEPS} )"
+DEPEND="${RDEPEND}"
+
+PATCHES=(
+       "${FILESDIR}/${PV}-python3.patch"
+       "${FILESDIR}/${PV}-changes.patch"
+)
+
+src_prepare() {
+       default
+
+       eautoreconf
+}
+
+src_configure() {
+       econf \
+               --enable-lenient \
+               --disable-statedir \
+               --without-python \
+               $(use_with pcre)
+}
+
+src_compile() {
+       default
+
+       if use python; then
+               pushd python >/dev/null || die
+               distutils-r1_src_compile
+               popd >/dev/null || die
+       fi
+}
+
+src_install() {
+       default
+
+       if use python; then
+               pushd python >/dev/null || die
+               distutils-r1_src_install
+               popd >/dev/null || die
+       fi
+}

Reply via email to