aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-03-27 13:07:57 -0400
committerMike Frysinger <vapier@gentoo.org>2016-03-27 13:07:57 -0400
commit26d038ae9c2f499cfb52486913cc326854a50571 (patch)
tree5143d651e6f51fcca7dc9a0eaf7d496f800d0cf1
parentusage: handle optional args, and auto-align display (diff)
downloadportage-utils-26d038ae.tar.gz
portage-utils-26d038ae.tar.bz2
portage-utils-26d038ae.zip
q: migrate to new repo posthook system
This also extends the reinit interface to optionally take a path to the overlay to process. That allows the postsync hook to fire on specific repos rather than all of them. URL: https://bugs.gentoo.org/522032
-rw-r--r--Makefile7
-rw-r--r--Makefile.am5
-rw-r--r--main.c3
-rw-r--r--main.h1
-rw-r--r--man/q.16
-rw-r--r--q.c34
-rw-r--r--repo.postsync/q-reinit10
7 files changed, 54 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index fe6092f4..baa27c20 100644
--- a/Makefile
+++ b/Makefile
@@ -27,9 +27,11 @@ LIBADD += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lk
LIBADD += -liniparser
DESTDIR :=
PREFIX := $(DESTDIR)/usr
+ETCDIR := $(DESTDIR)/etc
STRIP := strip
MKDIR := mkdir -p
CP := cp
+INSTALL_EXE := install -m755
ifndef V
Q = @
@@ -106,13 +108,16 @@ testclean:
install: all
$(MKDIR) $(PREFIX)/bin/
- $(CP) q $(PREFIX)/bin/
+ $(INSTALL_EXE) q $(PREFIX)/bin/
set -e ; \
for applet in $(filter-out q,$(APPLETS)) ; do \
ln -sf q $(PREFIX)/bin/$${applet} ; \
done
+ $(MKDIR) $(ETCDIR)/portage/repo.postsync.d
+ $(INSTALL_EXE) repo.postsync/* $(ETCDIR)/portage/repo.postsync.d/
+
ifneq ($(wildcard man/*.1),)
$(MKDIR) $(PREFIX)/share/man/man1/
cp $(wildcard man/*.1) $(PREFIX)/share/man/man1/
diff --git a/Makefile.am b/Makefile.am
index 225c9791..362ee219 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,11 @@ ACLOCAL_AMFLAGS = -I autotools/m4
SUBDIRS = autotools/gnulib
+portagedir = $(sysconfdir)/portage
+postsyncddir = $(portagedir)/repo.postsync.d
+
+dist_postsyncd_SCRIPTS = repo.postsync/q-reinit
+
bin_PROGRAMS = q
q_SOURCES = main.c
q_CPPFLAGS = \
diff --git a/main.c b/main.c
index e9bacda1..08347567 100644
--- a/main.c
+++ b/main.c
@@ -976,7 +976,8 @@ initialize_flat(const char *overlay, int cache_type, bool force)
}
if (!quiet)
- warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");
+ warn("Updating ebuild %scache in %s ... ",
+ cache_type == CACHE_EBUILD ? "" : "meta", overlay);
count = frac = secs = 0;
diff --git a/main.h b/main.h
index 877c1ecb..6848a9fc 100644
--- a/main.h
+++ b/main.h
@@ -99,3 +99,4 @@
getopt_long(argc, argv, ex A ## _FLAGS, a ## _long_opts, NULL)
#define a_argument required_argument
+#define opt_argument optional_argument
diff --git a/man/q.1 b/man/q.1
index 322e1af9..0f8f3676 100644
--- a/man/q.1
+++ b/man/q.1
@@ -1,4 +1,4 @@
-.TH q "1" "Mar 2014" "Gentoo Foundation" "q"
+.TH q "1" "Mar 2016" "Gentoo Foundation" "q"
.SH NAME
q \- invoke a portage utility applet
.SH SYNOPSIS
@@ -11,10 +11,10 @@ q \- invoke a portage utility applet
\fB\-i\fR, \fB\-\-install\fR
Install symlinks for applets
.TP
-\fB\-r\fR, \fB\-\-reinitialize\fR
+\fB\-r\fR \fI[arg]\fR, \fB\-\-reinitialize\fR \fI[arg]\fR
Reinitialize ebuild cache
.TP
-\fB\-m\fR, \fB\-\-metacache\fR
+\fB\-m\fR \fI[arg]\fR, \fB\-\-metacache\fR \fI[arg]\fR
Reinitialize metadata cache
.TP
\fB\-M\fR \fI<arg>\fR, \fB\-\-modpath\fR \fI<arg>\fR
diff --git a/q.c b/q.c
index 53b359f6..1475f99b 100644
--- a/q.c
+++ b/q.c
@@ -8,10 +8,10 @@
#define Q_FLAGS "irmM:" COMMON_FLAGS
static struct option const q_long_opts[] = {
- {"install", no_argument, NULL, 'i'},
- {"reinitialize", no_argument, NULL, 'r'},
- {"metacache", no_argument, NULL, 'm'},
- {"modpath", a_argument, NULL, 'M'},
+ {"install", no_argument, NULL, 'i'},
+ {"reinitialize", opt_argument, NULL, 'r'},
+ {"metacache", opt_argument, NULL, 'm'},
+ {"modpath", a_argument, NULL, 'M'},
COMMON_LONG_OPTS
};
static const char * const q_opts_help[] = {
@@ -84,8 +84,24 @@ int q_main(int argc, char **argv)
switch (i) {
COMMON_GETOPTS_CASES(q)
case 'M': modpath = optarg; break;
- case 'm': reinitialize_metacache = 1; break;
- case 'r': reinitialize = 1; break;
+ case 'm':
+ if (optarg) {
+ const char *path = initialize_flat(optarg, CACHE_METADATA, true);
+ if (path) { /* silence warning */ }
+ IF_DEBUG(free((void *)path));
+ reinitialize_metacache = -1;
+ } else
+ reinitialize_metacache = 1;
+ break;
+ case 'r':
+ if (optarg) {
+ const char *path = initialize_flat(optarg, CACHE_EBUILD, true);
+ if (path) { /* silence warning */ }
+ IF_DEBUG(free((void *)path));
+ reinitialize = -1;
+ } else
+ reinitialize = 1;
+ break;
case 'i': install = 1; break;
}
}
@@ -128,8 +144,12 @@ int q_main(int argc, char **argv)
return ret;
}
- if (reinitialize || reinitialize_metacache)
+ if (reinitialize > 0 || reinitialize_metacache > 0)
return 0;
+ if (reinitialize < 0 || reinitialize_metacache < 0) {
+ reinitialize = reinitialize_metacache = 0;
+ return 0;
+ }
if (argc == optind)
q_usage(EXIT_FAILURE);
if ((func = lookup_applet(argv[optind])) == NULL)
diff --git a/repo.postsync/q-reinit b/repo.postsync/q-reinit
new file mode 100644
index 00000000..0833c66f
--- /dev/null
+++ b/repo.postsync/q-reinit
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+repository_name=$1
+repository_path=$3
+
+if [ -n "${repository_name}" ]; then
+ q ${PORTAGE_QUIET:+-q} --reinitialize="${repository_path}"
+fi
+
+: