Gentoo Archives: gentoo-portage-dev

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

Replies