X-Original-To: alpine-aports@mail.alpinelinux.org Delivered-To: alpine-aports@mail.alpinelinux.org Received: from mail.alpinelinux.org (dallas-a1.alpinelinux.org [127.0.0.1]) by mail.alpinelinux.org (Postfix) with ESMTP id 28B67DC0409 for ; Sun, 10 May 2015 21:46:31 +0000 (UTC) Received: from apollo.thewebhostserver.com (apollomail.thewebhostserver.com [46.23.65.248]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id CA781DC0177 for ; Sun, 10 May 2015 21:46:25 +0000 (UTC) Received: from [81.4.121.188] (port=52955 helo=localhost.localdomain) by apollo.thewebhostserver.com with esmtpsa (TLSv1.2:AES128-SHA256:128) (Exim 4.85) (envelope-from ) id 1YrZ3F-0034aw-OP; Sun, 10 May 2015 22:46:22 +0100 From: Stuart Cardall To: alpine-aports@lists.alpinelinux.org Cc: Stuart Cardall Subject: [alpine-aports] [PATCH] testing/inotify-tools-inc: new aport (with --include regex) Date: Sun, 10 May 2015 21:46:06 +0000 Message-Id: <1431294366-93115-1-git-send-email-developer@it-offshore.co.uk> X-Mailer: git-send-email 2.4.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - apollo.thewebhostserver.com X-AntiAbuse: Original Domain - lists.alpinelinux.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - it-offshore.co.uk X-Get-Message-Sender-Via: apollo.thewebhostserver.com: authenticated_id: developer@it-offshore.co.uk X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched X-Virus-Scanned: ClamAV using ClamSMTP X-Mailinglist: alpine-aports Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: This is inotify-tools patched to add --include & --includei regexes I've been testing it watching for a specific file. The --exclude regexes still work too. --- testing/inotify-tools-inc/APKBUILD | 59 ++++ testing/inotify-tools-inc/add-include-regex.patch | 365 ++++++++++++++++++++++ 2 files changed, 424 insertions(+) create mode 100644 testing/inotify-tools-inc/APKBUILD create mode 100644 testing/inotify-tools-inc/add-include-regex.patch diff --git a/testing/inotify-tools-inc/APKBUILD b/testing/inotify-tools-inc/APKBUILD new file mode 100644 index 0000000..78e6220 --- /dev/null +++ b/testing/inotify-tools-inc/APKBUILD @@ -0,0 +1,59 @@ +# Contributor: Stuart Cardall +# Maintainer: Stuart Cardall +pkgname="inotify-tools-inc" +_realname="${pkgname%*-inc}" +pkgver=3.14 +pkgrel=0 +pkgdesc="inotify-tools patched to add --include regex" +url="http://github.com/rvoicilas/inotify-tools" +arch="all" +license="GPL2" +replaces="inotify-tools" +subpackages="$pkgname-dev $pkgname-doc" +source="https://github.com/downloads/rvoicilas/$_realname/$_realname-$pkgver.tar.gz + add-include-regex.patch + " + +_builddir="$srcdir"/$_realname-$pkgver +prepare() { + local i + cd "$_builddir" + for i in $source; do + case $i in + *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;; + esac + done +} + +build() { + cd "$_builddir" + ./configure --prefix=/usr \ + --sysconfdir=/etc \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info \ + || return 1 + make || return 1 +} + +package() { + cd "$_builddir" + make DESTDIR="$pkgdir" install || return 1 + rm "$pkgdir"/usr/lib/*.la || return 1 + # post-install message + mkdir -p "$pkgdir/usr/share/doc/$pkgname" + cat > $pkgdir/usr/share/doc/$pkgname/example.sh <.\n"); + printf("\t--excludei \n" + "\t \tLike --exclude but case insensitive.\n"); ++ printf("\t--include \n" ++ "\t \tInclude all events on only those files matching\n" ++ "\t \tthe extended regular expression .\n"); ++ printf("\t--includei \n" ++ "\t \tLike --include but case insensitive.\n"); + printf("\t-m|--monitor \tKeep listening for events forever. Without\n" + "\t \tthis option, inotifywait will exit after one\n" + "\t \tevent is received.\n"); +diff -urp inotify-tools-3.14/src/inotifywatch.c inotify-tools.new/src/inotifywatch.c +--- inotify-tools-3.14/src/inotifywatch.c 2010-03-12 13:53:46.000000000 +0000 ++++ inotify-tools.new/src/inotifywatch.c 2015-05-10 16:51:40.060391453 +0000 +@@ -43,7 +43,9 @@ bool parse_opts( + int * recursive, + char ** fromfile, + char ** regex, +- char ** iregex ++ char ** iregex, ++ char ** include_regex, ++ char ** include_iregex + ); + + void print_help(); +@@ -91,21 +93,34 @@ int main(int argc, char ** argv) + done = false; + char * regex = NULL; + char * iregex = NULL; ++ char * include_regex = NULL; ++ char * include_iregex = NULL; ++ bool invert_regex = false; + + signal( SIGINT, handle_impatient_user ); + + // Parse commandline options, aborting if something goes wrong + if ( !parse_opts( &argc, &argv, &events, &timeout, &verbose, &zero, &sort, +- &recursive, &fromfile, ®ex, &iregex ) ) { ++ &recursive, &fromfile, ®ex, &iregex, &include_regex, &include_iregex ) ) { + return EXIT_FAILURE; + } + ++ if (include_regex) { ++ regex = include_regex; ++ invert_regex = true; ++ } ++ ++ if (include_iregex) { ++ iregex = include_iregex; ++ invert_regex = true; ++ } ++ + if ( +- (regex && !inotifytools_ignore_events_by_regex(regex, REG_EXTENDED) ) || ++ (regex && !inotifytools_ignore_events_by_regex(regex, REG_EXTENDED, invert_regex) ) || + (iregex && !inotifytools_ignore_events_by_regex(iregex, REG_EXTENDED| +- REG_ICASE)) ++ REG_ICASE, invert_regex)) + ) { +- fprintf(stderr, "Error in `exclude' regular expression.\n"); ++ fprintf(stderr, "Error in `exclude' or `include' regular expression.\n"); + return EXIT_FAILURE; + } + +@@ -390,7 +405,9 @@ bool parse_opts( + int * recursive, + char ** fromfile, + char ** regex, +- char ** iregex ++ char ** iregex, ++ char ** include_regex, ++ char ** include_iregex + ) { + assert( argc ); assert( argv ); assert( events ); assert( timeout ); + assert( verbose ); assert( zero ); assert( sort ); assert( recursive ); +@@ -400,7 +417,7 @@ bool parse_opts( + char * opt_string = "hra:d:zve:t:"; + + // Construct array +- struct option long_opts[12]; ++ struct option long_opts[14]; + + // --help + long_opts[0].name = "help"; +@@ -460,11 +477,21 @@ bool parse_opts( + long_opts[10].has_arg = 1; + long_opts[10].flag = NULL; + long_opts[10].val = (int)'b'; ++ // --include ++ long_opts[11].name = "include"; ++ long_opts[11].has_arg = 1; ++ long_opts[11].flag = NULL; ++ long_opts[11].val = (int)'j'; ++ // --includei ++ long_opts[12].name = "includei"; ++ long_opts[12].has_arg = 1; ++ long_opts[12].flag = NULL; ++ long_opts[12].val = (int)'k'; + // Empty last element +- long_opts[11].name = 0; +- long_opts[11].has_arg = 0; +- long_opts[11].flag = 0; +- long_opts[11].val = 0; ++ long_opts[13].name = 0; ++ long_opts[13].has_arg = 0; ++ long_opts[13].flag = 0; ++ long_opts[13].val = 0; + + // Get first option + char curr_opt = getopt_long(*argc, *argv, opt_string, long_opts, NULL); +@@ -506,6 +533,16 @@ bool parse_opts( + (*iregex) = optarg; + break; + ++ // --include ++ case 'j': ++ (*include_regex) = optarg; ++ break; ++ ++ // --includei ++ case 'k': ++ (*include_iregex) = optarg; ++ break; ++ + // --fromfile + case 'o': + if (*fromfile) { +@@ -625,6 +662,16 @@ bool parse_opts( + return false; + } + ++ if ( *include_regex && *include_iregex ) { ++ fprintf(stderr, "--include and --includei cannot both be specified.\n"); ++ return false; ++ } ++ ++ if ( ( *include_regex || *include_iregex ) && ( *regex || *iregex ) ) { ++ fprintf(stderr, "Cannot use include and exclude options simultaneously.\n"); ++ return false; ++ } ++ + // If ? returned, invalid option + return (curr_opt != '?'); + } +@@ -647,6 +694,11 @@ void print_help() + "\t\texpression .\n"); + printf("\t--excludei \n" + "\t\tLike --exclude but case insensitive.\n"); ++ printf("\t--include \n" ++ "\t\tInclude all events only those files matching the extended\n" ++ "\t\tregular expression .\n"); ++ printf("\t--includei \n" ++ "\t\tLike --include but case insensitive.\n"); + printf("\t-z|--zero\n" + "\t\tIn the final table of results, output rows and columns even\n" + "\t\tif they consist only of zeros (the default is to not output\n" -- 2.4.0 --- Unsubscribe: alpine-aports+unsubscribe@lists.alpinelinux.org Help: alpine-aports+help@lists.alpinelinux.org ---