1 |
On Fri, 5 Dec 2014 17:12:17 +0100 |
2 |
Michał Górny <mgorny@g.o> wrote: |
3 |
|
4 |
> --- |
5 |
> cnf/postsync.d/example | 63 |
6 |
> ++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 |
> setup.py | 1 + 2 files changed, 64 insertions(+) |
8 |
> create mode 100644 cnf/postsync.d/example |
9 |
> |
10 |
> diff --git a/cnf/postsync.d/example b/cnf/postsync.d/example |
11 |
> new file mode 100644 |
12 |
> index 0000000..773e519 |
13 |
> --- /dev/null |
14 |
> +++ b/cnf/postsync.d/example |
15 |
> @@ -0,0 +1,63 @@ |
16 |
> +#!/bin/sh |
17 |
> +# Example /etc/portage/postsync.d script. Make it executable (chmod |
18 |
> +x) for +# Portage to process it. |
19 |
> +# |
20 |
> +# With portage-2.2.16 and newer, all hooks will be called multiple |
21 |
> +# times: |
22 |
> +# 1. after syncing each repository, |
23 |
> +# 2. one more time after syncing all the repositories. |
24 |
> +# |
25 |
> +# Older versions of Portage support syncing only one repository. |
26 |
> +# In those versions, the hooks will be called only once, and they |
27 |
> will +# not be passed any parameters. |
28 |
> + |
29 |
> +# On a per-repository hook call, positional parameters contain |
30 |
> +# information about the just-synced repository. On the final hook |
31 |
> call, +# the parameters are empty. |
32 |
> + |
33 |
> +# The repository name (or null in the final hook). |
34 |
> +repository_name=${1} |
35 |
> +# The URI to which the repository was synced. |
36 |
> +sync_uri=${2} |
37 |
> +# The path to the repository. |
38 |
> +repository_path=${3} |
39 |
> + |
40 |
> +# Portage assumes that a hook succeeded if it exits with 0 code. If |
41 |
> no +# explicit exit is done, the exit code is the exit code of last |
42 |
> spawned +# command. Since our script is a bit more complex, we want |
43 |
> to control +# the exit code explicitly. |
44 |
> +ret=0 |
45 |
> + |
46 |
> +if [ -n "${repository_name}" ]; then |
47 |
> + # Repository name was provided, so we're in a |
48 |
> post-repository hook. |
49 |
> + echo "* In post-repository hook for ${repository_name}" |
50 |
> + echo "** synced from remote repository ${sync_uri}" |
51 |
> + echo "** synced into ${repository_path}" |
52 |
> + |
53 |
> + # Gentoo comes with pregenerated cache but the other |
54 |
> repositories |
55 |
> + # usually don't. Generate them to improve performance. |
56 |
> + if [ "${repository_name}" != "gentoo" ]; then |
57 |
> + if ! egencache --update --repo="${repository_name}" |
58 |
> --jobs=4 |
59 |
> + then |
60 |
> + echo "!!! egencache failed!" |
61 |
> + ret=1 |
62 |
> + fi |
63 |
> + fi |
64 |
> +else |
65 |
> + # No repository name provided, so we've synced all |
66 |
> repositories. |
67 |
> + # Now it's time to run commands that work on all repositories |
68 |
> + # simultaneously. |
69 |
> + |
70 |
> + echo "* In final post-sync hook" |
71 |
> + |
72 |
> + # Run eix-update if eix is installed. |
73 |
> + if [ -n "$(type -p eix-update)" ]; then |
74 |
> + if ! eix-update; then |
75 |
> + echo "!!! eix-update failed" |
76 |
> + ret=1 |
77 |
> + fi |
78 |
> + fi |
79 |
> +fi |
80 |
> + |
81 |
> +# Return explicit status. |
82 |
> +exit "${ret}" |
83 |
> diff --git a/setup.py b/setup.py |
84 |
> index 4388a99..367cdb4 100755 |
85 |
> --- a/setup.py |
86 |
> +++ b/setup.py |
87 |
> @@ -629,6 +629,7 @@ setup( |
88 |
> ['$portage_setsdir', ['cnf/sets/portage.conf']], |
89 |
> ['$docdir', ['NEWS', 'RELEASE-NOTES']], |
90 |
> ['$portage_base/bin', ['bin/deprecated-path']], |
91 |
> + ['$sysconfdir/portage/postsync.d', |
92 |
> ['cnf/postsync.d/example']], ], |
93 |
> |
94 |
> cmdclass = { |
95 |
|
96 |
|
97 |
I committed a trimmed down slightly re-worded version which installs to |
98 |
repo.postsync.d/example. |
99 |
|
100 |
This new repo.postsync.d directory and system is strictly for per-repo |
101 |
hooks. In this way, the original postsync.d directory hooks are only |
102 |
run once after all repos are run. It also does not break compatibility |
103 |
with existing hooks. |
104 |
|
105 |
-- |
106 |
Brian Dolbec <dolsen> |