public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] Install a verbose example postsync.d script.
@ 2014-12-04 23:13 Michał Górny
  2014-12-05 16:12 ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
  0 siblings, 1 reply; 3+ messages in thread
From: Michał Górny @ 2014-12-04 23:13 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

---
 cnf/postsync.d/example | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 setup.py               |  1 +
 2 files changed, 64 insertions(+)
 create mode 100644 cnf/postsync.d/example

diff --git a/cnf/postsync.d/example b/cnf/postsync.d/example
new file mode 100644
index 0000000..66a5c86
--- /dev/null
+++ b/cnf/postsync.d/example
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Example /etc/portage/postsync.d script. Make it executable (chmod +x) for
+# Portage to process it.
+#
+# With portage-2.2.16 and newer, all hooks will be called multiple
+# times:
+# 1. after syncing each repository,
+# 2. one more time after syncing all the repositories.
+#
+# Older versions of Portage support syncing only one repository.
+# In those versions, the hooks will be called only once, and they will
+# not be passed any parameters.
+
+# On per-repository hook, positional parameters contain information
+# about the just-synced repository. On final hook, the parameters are
+# empty.
+
+# The repository name (or null in final hook).
+repository_name=${1}
+# The URI to which the repository was synced.
+sync_uri=${2}
+# The path to the repository.
+repository_path=${3}
+
+# Portage assumes hook succeeded if it exits with 0 code. If no explicit
+# exit is done, the exit code is the exit code of last spawned command.
+# Since our script is a bit more complex, we want to control the exit
+# code explicitly.
+ret=0
+
+if [ -n "${repository_name}" ]; then
+	# Repository name provided, we're in post-repository hook.
+	echo "* In post-repository hook for ${repository_name}"
+	echo "** synced from remote repository ${sync_uri}"
+	echo "** synced into ${repository_path}"
+
+	# Gentoo comes with pregenerated cache but other reposiotories
+	# usually don't. Generate them to improve performance.
+	if [ "${repository_name}" != "gentoo" ]; then
+		if ! egencache --update --repo="${repository_name}" --jobs=4
+		then
+			echo "!!! egencache failed!"
+			ret=1
+		fi
+	fi
+else
+	# No repository name provided, we've synced all repositories.
+	# Now it's time to run hooks that work on all repositories
+	# simultaneously.
+
+	echo "* In final post-sync hook"
+
+	# Run eix-update if eix is installed.
+	if [ -n "$(type -p eix-update)" ]; then
+		if ! eix-update; then
+			echo "!!! eix-update failed"
+			ret=1
+		fi
+	fi
+fi
+
+# Return explicit status.
+exit "${ret}"
diff --git a/setup.py b/setup.py
index 4388a99..367cdb4 100755
--- a/setup.py
+++ b/setup.py
@@ -629,6 +629,7 @@ setup(
 		['$portage_setsdir', ['cnf/sets/portage.conf']],
 		['$docdir', ['NEWS', 'RELEASE-NOTES']],
 		['$portage_base/bin', ['bin/deprecated-path']],
+		['$sysconfdir/portage/postsync.d', ['cnf/postsync.d/example']],
 	],
 
 	cmdclass = {
-- 
2.2.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-portage-dev] [PATCH v2] Install a verbose example postsync.d script
  2014-12-04 23:13 [gentoo-portage-dev] [PATCH] Install a verbose example postsync.d script Michał Górny
@ 2014-12-05 16:12 ` Michał Górny
  2014-12-07  5:47   ` Brian Dolbec
  0 siblings, 1 reply; 3+ messages in thread
From: Michał Górny @ 2014-12-05 16:12 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

---
 cnf/postsync.d/example | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 setup.py               |  1 +
 2 files changed, 64 insertions(+)
 create mode 100644 cnf/postsync.d/example

diff --git a/cnf/postsync.d/example b/cnf/postsync.d/example
new file mode 100644
index 0000000..773e519
--- /dev/null
+++ b/cnf/postsync.d/example
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Example /etc/portage/postsync.d script. Make it executable (chmod +x) for
+# Portage to process it.
+#
+# With portage-2.2.16 and newer, all hooks will be called multiple
+# times:
+# 1. after syncing each repository,
+# 2. one more time after syncing all the repositories.
+#
+# Older versions of Portage support syncing only one repository.
+# In those versions, the hooks will be called only once, and they will
+# not be passed any parameters.
+
+# On a per-repository hook call, positional parameters contain
+# information about the just-synced repository. On the final hook call,
+# the parameters are empty.
+
+# The repository name (or null in the final hook).
+repository_name=${1}
+# The URI to which the repository was synced.
+sync_uri=${2}
+# The path to the repository.
+repository_path=${3}
+
+# Portage assumes that a hook succeeded if it exits with 0 code. If no
+# explicit exit is done, the exit code is the exit code of last spawned
+# command. Since our script is a bit more complex, we want to control
+# the exit code explicitly.
+ret=0
+
+if [ -n "${repository_name}" ]; then
+	# Repository name was provided, so we're in a post-repository hook.
+	echo "* In post-repository hook for ${repository_name}"
+	echo "** synced from remote repository ${sync_uri}"
+	echo "** synced into ${repository_path}"
+
+	# Gentoo comes with pregenerated cache but the other repositories
+	# usually don't. Generate them to improve performance.
+	if [ "${repository_name}" != "gentoo" ]; then
+		if ! egencache --update --repo="${repository_name}" --jobs=4
+		then
+			echo "!!! egencache failed!"
+			ret=1
+		fi
+	fi
+else
+	# No repository name provided, so we've synced all repositories.
+	# Now it's time to run commands that work on all repositories
+	# simultaneously.
+
+	echo "* In final post-sync hook"
+
+	# Run eix-update if eix is installed.
+	if [ -n "$(type -p eix-update)" ]; then
+		if ! eix-update; then
+			echo "!!! eix-update failed"
+			ret=1
+		fi
+	fi
+fi
+
+# Return explicit status.
+exit "${ret}"
diff --git a/setup.py b/setup.py
index 4388a99..367cdb4 100755
--- a/setup.py
+++ b/setup.py
@@ -629,6 +629,7 @@ setup(
 		['$portage_setsdir', ['cnf/sets/portage.conf']],
 		['$docdir', ['NEWS', 'RELEASE-NOTES']],
 		['$portage_base/bin', ['bin/deprecated-path']],
+		['$sysconfdir/portage/postsync.d', ['cnf/postsync.d/example']],
 	],
 
 	cmdclass = {
-- 
2.2.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [gentoo-portage-dev] [PATCH v2] Install a verbose example postsync.d script
  2014-12-05 16:12 ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
@ 2014-12-07  5:47   ` Brian Dolbec
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Dolbec @ 2014-12-07  5:47 UTC (permalink / raw
  To: gentoo-portage-dev

On Fri,  5 Dec 2014 17:12:17 +0100
Michał Górny <mgorny@gentoo.org> wrote:

> ---
>  cnf/postsync.d/example | 63
> ++++++++++++++++++++++++++++++++++++++++++++++++++
> setup.py               |  1 + 2 files changed, 64 insertions(+)
>  create mode 100644 cnf/postsync.d/example
> 
> diff --git a/cnf/postsync.d/example b/cnf/postsync.d/example
> new file mode 100644
> index 0000000..773e519
> --- /dev/null
> +++ b/cnf/postsync.d/example
> @@ -0,0 +1,63 @@
> +#!/bin/sh
> +# Example /etc/portage/postsync.d script. Make it executable (chmod
> +x) for +# Portage to process it.
> +#
> +# With portage-2.2.16 and newer, all hooks will be called multiple
> +# times:
> +# 1. after syncing each repository,
> +# 2. one more time after syncing all the repositories.
> +#
> +# Older versions of Portage support syncing only one repository.
> +# In those versions, the hooks will be called only once, and they
> will +# not be passed any parameters.
> +
> +# On a per-repository hook call, positional parameters contain
> +# information about the just-synced repository. On the final hook
> call, +# the parameters are empty.
> +
> +# The repository name (or null in the final hook).
> +repository_name=${1}
> +# The URI to which the repository was synced.
> +sync_uri=${2}
> +# The path to the repository.
> +repository_path=${3}
> +
> +# Portage assumes that a hook succeeded if it exits with 0 code. If
> no +# explicit exit is done, the exit code is the exit code of last
> spawned +# command. Since our script is a bit more complex, we want
> to control +# the exit code explicitly.
> +ret=0
> +
> +if [ -n "${repository_name}" ]; then
> +	# Repository name was provided, so we're in a
> post-repository hook.
> +	echo "* In post-repository hook for ${repository_name}"
> +	echo "** synced from remote repository ${sync_uri}"
> +	echo "** synced into ${repository_path}"
> +
> +	# Gentoo comes with pregenerated cache but the other
> repositories
> +	# usually don't. Generate them to improve performance.
> +	if [ "${repository_name}" != "gentoo" ]; then
> +		if ! egencache --update --repo="${repository_name}"
> --jobs=4
> +		then
> +			echo "!!! egencache failed!"
> +			ret=1
> +		fi
> +	fi
> +else
> +	# No repository name provided, so we've synced all
> repositories.
> +	# Now it's time to run commands that work on all repositories
> +	# simultaneously.
> +
> +	echo "* In final post-sync hook"
> +
> +	# Run eix-update if eix is installed.
> +	if [ -n "$(type -p eix-update)" ]; then
> +		if ! eix-update; then
> +			echo "!!! eix-update failed"
> +			ret=1
> +		fi
> +	fi
> +fi
> +
> +# Return explicit status.
> +exit "${ret}"
> diff --git a/setup.py b/setup.py
> index 4388a99..367cdb4 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -629,6 +629,7 @@ setup(
>  		['$portage_setsdir', ['cnf/sets/portage.conf']],
>  		['$docdir', ['NEWS', 'RELEASE-NOTES']],
>  		['$portage_base/bin', ['bin/deprecated-path']],
> +		['$sysconfdir/portage/postsync.d',
> ['cnf/postsync.d/example']], ],
>  
>  	cmdclass = {


I committed a trimmed down slightly re-worded version which installs to
repo.postsync.d/example.

This new repo.postsync.d directory and system is strictly for per-repo
hooks.  In this way, the original postsync.d directory hooks are only
run once after all repos are run.  It also does not break compatibility
with existing hooks.

-- 
Brian Dolbec <dolsen>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-07  5:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-04 23:13 [gentoo-portage-dev] [PATCH] Install a verbose example postsync.d script Michał Górny
2014-12-05 16:12 ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
2014-12-07  5:47   ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox