[arch-projects] [DEVTOOLS][PATCH 1/3] archbuild: build without updating the chroot
From: Sébastien Luttringer <seblu@seblu.net> Useful when you need to build with an outdated package version --- archbuild.in | 5 ++++- zsh_completion.in | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/archbuild.in b/archbuild.in index 9c5d706..7d8d2a9 100644 --- a/archbuild.in +++ b/archbuild.in @@ -17,11 +17,13 @@ else fi chroots='/var/lib/archbuild' clean_first=false +update=true usage() { echo "Usage: $cmd [options] -- [makechrootpkg args]" echo ' -h This help' echo ' -c Recreate the chroot before building' + echo ' -u Do not update the chroot before before building' echo ' -r <dir> Create chroots in this directory' echo '' echo "Default makechrootpkg args: ${makechrootpkg_args[*]}" @@ -34,6 +36,7 @@ orig_argv=("$@") while getopts 'hcr:' arg; do case "${arg}" in c) clean_first=true ;; + u) update=false ;; r) chroots="$OPTARG" ;; *) usage ;; esac @@ -67,7 +70,7 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then -M "@pkgdatadir@/makepkg-${arch}.conf" \ "${chroots}/${repo}-${arch}/root" \ "${base_packages[@]}" || abort -else +elif $update; then lock 9 "${chroots}/${repo}-${arch}/root.lock" "Locking clean chroot" arch-nspawn \ -C "@pkgdatadir@/pacman-${repo}.conf" \ diff --git a/zsh_completion.in b/zsh_completion.in index 4c6dd99..8c418ea 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -4,6 +4,7 @@ m4_include(lib/valid-tags.sh) _archbuild_args=( '-c[Recreate the chroot before building]' + '-u[Do not update the chroot before before building]' '-r[Create chroots in this directory]:base_dir:_files -/' ) -- Sébastien "Seblu" Luttringer
From: Sébastien Luttringer <seblu@seblu.net> In order to install/downgrade packages with dependencies (e.g gcc-multilib), pass all packages to install in a row to pacman. As a side improvement, when a package installation fails, build fails. --- makechrootpkg.in | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 3c8a20f..447157d 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -126,23 +126,26 @@ clean_temporary() { stat_done } +# install packages in one call to pacman to let it manage correctly +# dependencies between packages install_packages() { - local pkgname + (( ${#install_pkgs[*]} == 0 )) && return 0 - for install_pkg in "${install_pkgs[@]}"; do - pkgname="${install_pkg##*/}" - cp "$install_pkg" "$copydir/$pkgname" + local src dst + local -a dsts - arch-nspawn "$copydir" \ - "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ - pacman -U /$pkgname --noconfirm - (( ret += !! $? )) - - rm "$copydir/$pkgname" + for src in "${install_pkgs[@]}"; do + dst=/"${src##*/}" + dsts+=("$dst") + cp "$src" "$copydir$dst" done - # If there is no PKGBUILD we are done - [[ -f PKGBUILD ]] || exit $ret + arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + pacman -U "${dsts[@]}" --noconfirm || exit $? + + for dst in "${dsts[@]}"; do + rm "$copydir$dst" + done } prepare_chroot() { @@ -384,6 +387,9 @@ $update_first && arch-nspawn "$copydir" \ [[ -n ${install_pkgs[*]} ]] && install_packages +# If there is no PKGBUILD we are done +[[ -f PKGBUILD ]] || exit 0 + download_sources prepare_chroot -- Sébastien "Seblu" Luttringer
On Thu, Aug 13, 2015 at 10:56:41PM +0200, seblu@archlinux.org wrote:
From: Sébastien Luttringer <seblu@seblu.net>
In order to install/downgrade packages with dependencies (e.g gcc-multilib), pass all packages to install in a row to pacman.
As a side improvement, when a package installation fails, build fails. --- makechrootpkg.in | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/makechrootpkg.in b/makechrootpkg.in index 3c8a20f..447157d 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -126,23 +126,26 @@ clean_temporary() { stat_done }
+# install packages in one call to pacman to let it manage correctly +# dependencies between packages install_packages() { - local pkgname + (( ${#install_pkgs[*]} == 0 )) && return 0
- for install_pkg in "${install_pkgs[@]}"; do - pkgname="${install_pkg##*/}" - cp "$install_pkg" "$copydir/$pkgname" + local src dst + local -a dsts
These aren't "destinations", they're packages. Please call the variable as such.
- arch-nspawn "$copydir" \ - "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ - pacman -U /$pkgname --noconfirm - (( ret += !! $? )) - - rm "$copydir/$pkgname" + for src in "${install_pkgs[@]}"; do + dst=/"${src##*/}" + dsts+=("$dst") + cp "$src" "$copydir$dst" done
- # If there is no PKGBUILD we are done - [[ -f PKGBUILD ]] || exit $ret + arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + pacman -U "${dsts[@]}" --noconfirm || exit $?
exit $? is redundant, you only need 'exit'. Better still, use 'die' with an appropriate error message?
+ + for dst in "${dsts[@]}"; do + rm "$copydir$dst" + done
rm "${dsts[@]}"
}
prepare_chroot() { @@ -384,6 +387,9 @@ $update_first && arch-nspawn "$copydir" \
[[ -n ${install_pkgs[*]} ]] && install_packages
+# If there is no PKGBUILD we are done +[[ -f PKGBUILD ]] || exit 0 +
Seems like an unrelated change... And, shouldn't lack of a PKGBUILD be a failure?
download_sources
prepare_chroot -- Sébastien "Seblu" Luttringer
On Fri, 2015-08-14 at 10:06 -0400, Dave Reisner wrote:
On Thu, Aug 13, 2015 at 10:56:41PM +0200, seblu@archlinux.org wrote:
From: Sébastien Luttringer <seblu@seblu.net>
+ + for dst in "${dsts[@]}"; do + rm "$copydir$dst" + done
rm "${dsts[@]}" The path is missing; I don't see something better than
( cd "$copydir" && rm -f "${pkg_filenames[@]}" )
}
prepare_chroot() { @@ -384,6 +387,9 @@ $update_first && arch-nspawn "$copydir" \
[[ -n ${install_pkgs[*]} ]] && install_packages
+# If there is no PKGBUILD we are done +[[ -f PKGBUILD ]] || exit 0 +
Seems like an unrelated change... And, shouldn't lack of a PKGBUILD be a failure?
This is useful to synchronise the root file on a daily basis (without building a package). I will move that in a different commit. -- Sébastien "Seblu" Luttringer https://seblu.net | Twitter: @seblu42 GPG: 0x2072D77A
From: Sébastien Luttringer <seblu@seblu.net> This add sudo config to allow member of devtools group to run build commands as root without password --- Makefile | 3 +++ sudoers | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 sudoers diff --git a/Makefile b/Makefile index dcdb522..d071602 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,8 @@ install: for l in ${BASHCOMPLETION_LINKS}; do ln -sf devtools $(DESTDIR)/usr/share/bash-completion/completions/$$l; done install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco + install -dm750 $(DESTDIR)/etc/sudoers.d + install -Dm0644 sudoers $(DESTDIR)/etc/sudoers.d/50-devtools uninstall: for f in ${BINPROGS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done @@ -106,6 +108,7 @@ uninstall: rm $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools rm -f $(DESTDIR)$(PREFIX)/bin/communityco rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides + rm -f $(DESTDIR)$/etc/sudoers.d/50-devtools dist: git archive --format=tar --prefix=devtools-$(V)/ $(V) | gzip -9 > devtools-$(V).tar.gz diff --git a/sudoers b/sudoers new file mode 100644 index 0000000..42508e4 --- /dev/null +++ b/sudoers @@ -0,0 +1,12 @@ +Cmnd_Alias DEVTOOLS = \ + /usr/bin/makechrootpkg, \ + /usr/bin/extra-i686-build, /usr/bin/extra-x86_64-build, /usr/bin/extra-build, \ + /usr/bin/testing-i686-build, /usr/bin/testing-x86_64-build, /usr/bin/testing-build, \ + /usr/bin/staging-i686-build, /usr/bin/staging-x86_64-build, /usr/bin/staging-build, \ + /usr/bin/multilib-build, /usr/bin/multilib-testing-build, /usr/bin/multilib-staging-build, \ + /usr/bin/kde-unstable-i686-build, /usr/bin/kde-unstable-x86_64-build, \ + /usr/bin/gnome-unstable-i686-build, /usr/bin/gnome-unstable-x86_64-build + +Defaults!DEVTOOLS umask_override + +%devtools ALL=(root) NOPASSWD: DEVTOOLS -- Sébastien "Seblu" Luttringer
On Thu, Aug 13, 2015 at 10:56:42PM +0200, seblu@archlinux.org wrote:
From: Sébastien Luttringer <seblu@seblu.net>
This add sudo config to allow member of devtools group to run build commands as root without password --- Makefile | 3 +++ sudoers | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 sudoers
diff --git a/Makefile b/Makefile index dcdb522..d071602 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,8 @@ install: for l in ${BASHCOMPLETION_LINKS}; do ln -sf devtools $(DESTDIR)/usr/share/bash-completion/completions/$$l; done install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco + install -dm750 $(DESTDIR)/etc/sudoers.d
This is redundant with the line below...
+ install -Dm0644 sudoers $(DESTDIR)/etc/sudoers.d/50-devtools
uninstall: for f in ${BINPROGS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done @@ -106,6 +108,7 @@ uninstall: rm $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools rm -f $(DESTDIR)$(PREFIX)/bin/communityco rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides + rm -f $(DESTDIR)$/etc/sudoers.d/50-devtools
dist: git archive --format=tar --prefix=devtools-$(V)/ $(V) | gzip -9 > devtools-$(V).tar.gz diff --git a/sudoers b/sudoers new file mode 100644 index 0000000..42508e4 --- /dev/null +++ b/sudoers @@ -0,0 +1,12 @@ +Cmnd_Alias DEVTOOLS = \ + /usr/bin/makechrootpkg, \ + /usr/bin/extra-i686-build, /usr/bin/extra-x86_64-build, /usr/bin/extra-build, \ + /usr/bin/testing-i686-build, /usr/bin/testing-x86_64-build, /usr/bin/testing-build, \ + /usr/bin/staging-i686-build, /usr/bin/staging-x86_64-build, /usr/bin/staging-build, \ + /usr/bin/multilib-build, /usr/bin/multilib-testing-build, /usr/bin/multilib-staging-build, \ + /usr/bin/kde-unstable-i686-build, /usr/bin/kde-unstable-x86_64-build, \ + /usr/bin/gnome-unstable-i686-build, /usr/bin/gnome-unstable-x86_64-build
Where do binary names like 'extra-build' and 'testing-build' come from? These aren't provided by devtools... We probably want this list generated from the Makefile to keep it in sync with reality.
+ +Defaults!DEVTOOLS umask_override + +%devtools ALL=(root) NOPASSWD: DEVTOOLS -- Sébastien "Seblu" Luttringer
On Fri, 2015-08-14 at 10:08 -0400, Dave Reisner wrote:
On Thu, Aug 13, 2015 at 10:56:42PM +0200, seblu@archlinux.org wrote:
From: Sébastien Luttringer <seblu@seblu.net>
This add sudo config to allow member of devtools group to run build commands as root without password --- Makefile | 3 +++ sudoers | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 sudoers
diff --git a/Makefile b/Makefile index dcdb522..d071602 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,8 @@ install: for l in ${BASHCOMPLETION_LINKS}; do ln -sf devtools $(DESTDIR)/usr/share/bash-completion/completions/$$l; done install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco + install -dm750 $(DESTDIR)/etc/sudoers.d
This is redundant with the line below... Nop. This is for correct directory rights.
+ install -Dm0644 sudoers $(DESTDIR)/etc/sudoers.d/50 -devtools
uninstall: for f in ${BINPROGS}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done @@ -106,6 +108,7 @@ uninstall: rm $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools rm -f $(DESTDIR)$(PREFIX)/bin/communityco rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides + rm -f $(DESTDIR)$/etc/sudoers.d/50-devtools
dist: git archive --format=tar --prefix=devtools-$(V)/ $(V) | gzip -9 > devtools-$(V).tar.gz diff --git a/sudoers b/sudoers new file mode 100644 index 0000000..42508e4 --- /dev/null +++ b/sudoers @@ -0,0 +1,12 @@ +Cmnd_Alias DEVTOOLS = \ + /usr/bin/makechrootpkg, \ + /usr/bin/extra-i686-build, /usr/bin/extra-x86_64-build, /usr/bin/extra-build, \ + /usr/bin/testing-i686-build, /usr/bin/testing-x86_64 -build, /usr/bin/testing-build, \ + /usr/bin/staging-i686-build, /usr/bin/staging-x86_64 -build, /usr/bin/staging-build, \ + /usr/bin/multilib-build, /usr/bin/multilib-testing-build, /usr/bin/multilib-staging-build, \ + /usr/bin/kde-unstable-i686-build, /usr/bin/kde-unstable -x86_64-build, \ + /usr/bin/gnome-unstable-i686-build, /usr/bin/gnome -unstable-x86_64-build
Where do binary names like 'extra-build' and 'testing-build' come from?
Future patches, I will remove them.
These aren't provided by devtools... We probably want this list generated from the Makefile to keep it in sync with reality. Make sense.
-- Sébastien "Seblu" Luttringer https://seblu.net | Twitter: @seblu42 GPG: 0x2072D77A
On Thu, Aug 13, 2015 at 10:56:40PM +0200, seblu@archlinux.org wrote:
From: Sébastien Luttringer <seblu@seblu.net>
Useful when you need to build with an outdated package version
Why wouldn't you just call makechrootpkg directly?
--- archbuild.in | 5 ++++- zsh_completion.in | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/archbuild.in b/archbuild.in index 9c5d706..7d8d2a9 100644 --- a/archbuild.in +++ b/archbuild.in @@ -17,11 +17,13 @@ else fi chroots='/var/lib/archbuild' clean_first=false +update=true
usage() { echo "Usage: $cmd [options] -- [makechrootpkg args]" echo ' -h This help' echo ' -c Recreate the chroot before building' + echo ' -u Do not update the chroot before before building' echo ' -r <dir> Create chroots in this directory' echo '' echo "Default makechrootpkg args: ${makechrootpkg_args[*]}" @@ -34,6 +36,7 @@ orig_argv=("$@") while getopts 'hcr:' arg; do case "${arg}" in c) clean_first=true ;; + u) update=false ;; r) chroots="$OPTARG" ;; *) usage ;; esac @@ -67,7 +70,7 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then -M "@pkgdatadir@/makepkg-${arch}.conf" \ "${chroots}/${repo}-${arch}/root" \ "${base_packages[@]}" || abort -else +elif $update; then lock 9 "${chroots}/${repo}-${arch}/root.lock" "Locking clean chroot" arch-nspawn \ -C "@pkgdatadir@/pacman-${repo}.conf" \ diff --git a/zsh_completion.in b/zsh_completion.in index 4c6dd99..8c418ea 100644 --- a/zsh_completion.in +++ b/zsh_completion.in @@ -4,6 +4,7 @@ m4_include(lib/valid-tags.sh)
_archbuild_args=( '-c[Recreate the chroot before building]' + '-u[Do not update the chroot before before building]' '-r[Create chroots in this directory]:base_dir:_files -/' )
-- Sébastien "Seblu" Luttringer
On Fri, 2015-08-14 at 10:04 -0400, Dave Reisner wrote:
On Thu, Aug 13, 2015 at 10:56:40PM +0200, seblu@archlinux.org wrote:
From: Sébastien Luttringer <seblu@seblu.net>
Useful when you need to build with an outdated package version
Why wouldn't you just call makechrootpkg directly?
Shorter, no need to specify the correct repository path manually. This is also useful for the next $repo-$arch-build -R patch. Regards, -- Sébastien "Seblu" Luttringer https://seblu.net | Twitter: @seblu42 GPG: 0x2072D77A
participants (3)
-
Dave Reisner
-
seblu@archlinux.org
-
Sébastien Luttringer