Compare commits

...

36 Commits

Author SHA1 Message Date
Pierre Schmitz
10eba28151 archbuild: fix default build flags 2013-01-22 20:12:36 +01:00
Pierre Schmitz
9cef7e0a9e Use nymeria instead of gerolde 2013-01-20 18:24:04 +01:00
Sébastien Luttringer
cb3a6ce1e8 -I ends early if there is nothing to build
This allow to build in one shot a package depending of a missing package

Signed-off-by: Sébastien Luttringer <seblu@seblu.net>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-01-20 10:21:39 +01:00
Sébastien Luttringer
fb71ad1e7f Allow makechroot options in archbuild
This will allow, by example, to easily build a package with a custom pkg.

staging-x86_64-build -- -cI /var/cache/pacman/pkg/ldoc-1.2.0-1-any.pkg.tar.xz
staging-x86_64-build -- -n

Signed-off-by: Sébastien Luttringer <seblu@seblu.net>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-01-20 10:21:31 +01:00
Pierre Schmitz
828143751b Drop initscripts support 2013-01-20 10:08:24 +01:00
Eric Bélanger
890baf6891 Make sure the usage functions are consistent
The usage messages now begins with a "Usage:", i.e. capitalized and with a colon. Fixes FS#26956.

Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-11-15 15:25:07 +01:00
Pierre Schmitz
2020fb406a prepare release 2012-11-15 14:38:03 +01:00
Eric Bélanger
4427b80aba crossrepomove: Fix dbscripts path for [community] move to nymeria
Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-11-15 14:32:34 +01:00
Eric Bélanger
41b54bdde5 mkarchroot: Remove unnecessary parameter for usage function
Fixes FS#28973

Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-11-15 14:28:50 +01:00
Eric Bélanger
54bad4c91d checkpkg: replace wget usage by curl
Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-11-15 14:27:20 +01:00
Pierre Schmitz
fc95a57556 prepare release 2012-11-12 18:44:26 +01:00
Pierre Schmitz
21458bd07b For now only packages and svn from sigurd will be moved to nymeria 2012-11-11 21:07:34 +01:00
Pierre Schmitz
a05969b29d prepare release 2012-11-03 18:26:45 +01:00
Pierre Schmitz
fdeaed894a Use nymeria.archlinux.org as shared host for developers and trusted users 2012-11-03 17:32:33 +01:00
Pierre Schmitz
3699321904 Prepare release 2012-10-27 20:31:05 +02:00
Pierre Schmitz
d8ec9c9066 Use sigurd.archlinux.org instead of the now moved aur.archlinux.org hostname 2012-10-27 20:30:24 +02:00
Jan Alexander Steffens (heftig)
fbb2bd2b8e Fix return code handling
Stop trap_exit from forcing a 0 exit code. This fixes makechrootpkg,
which used to always return success, even if the build failed.

Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-10-27 20:27:39 +02:00
Pierre Schmitz
d5c6bc7656 prepare release 2012-10-13 21:06:31 +02:00
Dan McGee
f7615fe7d7 Fix releasing files with '@' in name
SVN treats '@' as a revision specifier, so with the addition of systemd
spawning service files, we need to ensure it doesn't screw things up.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-10-13 20:40:09 +02:00
Pierre Schmitz
1703b92e1a mkarchroot: do not try to bind /etc/timezone from host
/etc/timezone is no longer used. We only need /etc/localtime.

This fixes FS#31929
2012-10-13 20:33:53 +02:00
Pierre Schmitz
cfd81ab563 prepare release 2012-10-04 21:19:31 +02:00
Pierre Schmitz
ac1ee41e4d mkarchroot: use a helper function to simplify bind mounts 2012-10-04 19:57:19 +02:00
Pierre Schmitz
ecae65e7fd prepare release 2012-10-03 12:46:07 +02:00
Pierre Schmitz
c617c67ff8 mkarchroot: Use systemd's nspawn if available
* If we are running systemd use nspawn instead of our own chroot setup
* Use pacstrap to setup our chroot environment
* Make sure the common trap is still called
* Bind resolve.conf, timezone and lcoaltime from the host if nspawn is not used
* Run ldconfig within the chroot
2012-10-03 12:38:33 +02:00
Pierre Schmitz
7228cc00e8 Use dedicated trap functions to avoid unsetting the trap when e.g. cleanup is called 2012-10-03 12:35:40 +02:00
Pierre Schmitz
a26416dca3 makechrootpkg: do not run namcap as root 2012-10-03 12:32:55 +02:00
Pierre Schmitz
37bb1d33a7 archbuild: abort if update or creation of the chroot fails 2012-10-03 12:32:03 +02:00
Florian Pritz
dbef0b91bf Fix ownership when copying files from chroot to system
Previously files were always owned by nobody which means trying to write
to them directly would fail because only the owner has +w.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-09-14 16:01:01 +02:00
Pierre Schmitz
499f20071a prepare release 2012-07-20 23:29:43 +02:00
Eric Bélanger
0d3d63e3aa Fix bash completions
With bash-completion 2.0, the completion must have the same name as the binary.

Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-06-25 00:01:32 +02:00
Pierre Schmitz
d2ec5ab67d prepare release 2012-06-16 17:06:15 +02:00
Pierre Schmitz
a23d93ce7f commitpkg: check if there are any packages to process before doing so 2012-06-16 16:56:42 +02:00
Pierre Schmitz
246b8ead60 mkarchroot: reset trap so it wont be called twice 2012-06-16 16:21:55 +02:00
Pierre Schmitz
b14a1b1bcc archbuild: do not cross filesystems when removing the chroot copies 2012-06-16 15:28:52 +02:00
Pierre Schmitz
0cd9e1ae7e archbuild: use flock -n as we do elsewhere 2012-06-16 15:24:16 +02:00
Allan McRae
3734c80bf7 Fix /run permissions in chroot
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2012-06-15 09:27:27 +02:00
13 changed files with 133 additions and 133 deletions

2
.gitignore vendored
View File

@@ -1,5 +1,5 @@
*~ *~
devtools-*.tar.gz devtools-*.tar.gz*
archbuild archbuild
archco archco
archrelease archrelease

View File

@@ -1,4 +1,4 @@
V=20120612 V=20130122
PREFIX = /usr/local PREFIX = /usr/local
@@ -64,6 +64,10 @@ CROSSREPOMOVE_LINKS = \
extra2community \ extra2community \
community2extra community2extra
BASHCOMPLETION_LINKS = \
archco \
communityco
all: $(BINPROGS) $(SBINPROGS) bash_completion zsh_completion all: $(BINPROGS) $(SBINPROGS) bash_completion zsh_completion
edit = sed -e "s|@pkgdatadir[@]|$(DESTDIR)$(PREFIX)/share/devtools|g" edit = sed -e "s|@pkgdatadir[@]|$(DESTDIR)$(PREFIX)/share/devtools|g"
@@ -90,6 +94,7 @@ install:
for l in ${CROSSREPOMOVE_LINKS}; do ln -sf crossrepomove $(DESTDIR)$(PREFIX)/bin/$$l; done for l in ${CROSSREPOMOVE_LINKS}; do ln -sf crossrepomove $(DESTDIR)$(PREFIX)/bin/$$l; done
ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides
install -Dm0644 bash_completion $(DESTDIR)/usr/share/bash-completion/completions/devtools install -Dm0644 bash_completion $(DESTDIR)/usr/share/bash-completion/completions/devtools
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 install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools
ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco
@@ -110,6 +115,6 @@ dist:
gpg --detach-sign --use-agent devtools-$(V).tar.gz gpg --detach-sign --use-agent devtools-$(V).tar.gz
upload: upload:
scp devtools-$(V).tar.gz devtools-$(V).tar.gz.sig gerolde.archlinux.org:/srv/ftp/other/devtools/ scp devtools-$(V).tar.gz devtools-$(V).tar.gz.sig nymeria.archlinux.org:/srv/ftp/other/devtools/
.PHONY: all clean install uninstall dist upload .PHONY: all clean install uninstall dist upload

View File

@@ -3,6 +3,7 @@
m4_include(lib/common.sh) m4_include(lib/common.sh)
base_packages=(base base-devel sudo) base_packages=(base base-devel sudo)
makechrootpkg_args=(-c -n)
cmd="${0##*/}" cmd="${0##*/}"
if [[ "${cmd%%-*}" == 'multilib' ]]; then if [[ "${cmd%%-*}" == 'multilib' ]]; then
@@ -18,13 +19,17 @@ chroots='/var/lib/archbuild'
clean_first=false clean_first=false
usage() { usage() {
echo "usage $cmd" echo "Usage: $cmd [options] -- [makechrootpkg args]"
echo ' -h This help'
echo ' -c Recreate the chroot before building' echo ' -c Recreate the chroot before building'
echo ' -r <dir> Create chroots in this directory' echo ' -r <dir> Create chroots in this directory'
echo ''
echo "Default makechrootpkg args: ${makechrootpkg_args[*]}"
echo ''
exit 1 exit 1
} }
while getopts 'cr:' arg; do while getopts 'hcr:' arg; do
case "${arg}" in case "${arg}" in
c) clean_first=true ;; c) clean_first=true ;;
r) chroots="$OPTARG" ;; r) chroots="$OPTARG" ;;
@@ -32,7 +37,10 @@ while getopts 'cr:' arg; do
esac esac
done done
if [[ "$EUID" != '0' ]]; then # Pass all arguments after -- right to makepkg
makechrootpkg_args+=("${@:$OPTIND}")
if (( EUID )); then
die 'This script must be run as root.' die 'This script must be run as root.'
fi fi
@@ -43,29 +51,32 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
[[ -d $copy ]] || continue [[ -d $copy ]] || continue
msg2 "Deleting chroot copy '$(basename "${copy}")'..." msg2 "Deleting chroot copy '$(basename "${copy}")'..."
# Lock the copy exec 9>"$copydir.lock"
exec 9>"${copy}.lock" if ! flock -n 9; then
stat_busy "Locking chroot copy '$copy'"
flock 9 flock 9
stat_done
fi
{ type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null { type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null
rm -rf "${copy}" rm -rf --one-file-system "${copy}"
done done
exec 9>&- exec 9>&-
rm -rf "${chroots}/${repo}-${arch}" rm -rf --one-file-system "${chroots}/${repo}-${arch}"
mkdir -p "${chroots}/${repo}-${arch}" mkdir -p "${chroots}/${repo}-${arch}"
setarch "${arch}" mkarchroot \ setarch "${arch}" mkarchroot \
-C "@pkgdatadir@/pacman-${repo}.conf" \ -C "@pkgdatadir@/pacman-${repo}.conf" \
-M "@pkgdatadir@/makepkg-${arch}.conf" \ -M "@pkgdatadir@/makepkg-${arch}.conf" \
"${chroots}/${repo}-${arch}/root" \ "${chroots}/${repo}-${arch}/root" \
"${base_packages[@]}" "${base_packages[@]}" || abort
else else
setarch ${arch} mkarchroot \ setarch ${arch} mkarchroot \
-u \ -u \
-C "@pkgdatadir@/pacman-${repo}.conf" \ -C "@pkgdatadir@/pacman-${repo}.conf" \
-M "@pkgdatadir@/makepkg-${arch}.conf" \ -M "@pkgdatadir@/makepkg-${arch}.conf" \
"${chroots}/${repo}-${arch}/root" "${chroots}/${repo}-${arch}/root" || abort
fi fi
msg "Building in chroot for [${repo}] (${arch})..." msg "Building in chroot for [${repo}] (${arch})..."
exec setarch "${arch}" makechrootpkg -c -n -r "${chroots}/${repo}-${arch}" exec setarch "${arch}" makechrootpkg "${makechrootpkg_args[@]}" -r "${chroots}/${repo}-${arch}"

View File

@@ -11,9 +11,9 @@ fi
case $scriptname in case $scriptname in
archco) archco)
SVNURL="svn+ssh://gerolde.archlinux.org/srv/svn-packages";; SVNURL="svn+ssh://svn-packages@nymeria.archlinux.org/srv/repos/svn-packages/svn";;
communityco) communityco)
SVNURL="svn+ssh://aur.archlinux.org/srv/svn-packages";; SVNURL="svn+ssh://svn-community@nymeria.archlinux.org/srv/repos/svn-community/svn";;
*) *)
die "Couldn't find svn url for $scriptname" die "Couldn't find svn url for $scriptname"
;; ;;

View File

@@ -66,7 +66,7 @@ for tag in "$@"; do
while read -r file; do while read -r file; do
trash+=("repos/$tag/$file") trash+=("repos/$tag/$file")
done < <(svn ls "repos/$tag") done < <(svn ls "repos/$tag")
[[ $trash ]] && svn rm -q "${trash[@]}" [[ $trash ]] && svn rm -q "${trash[@]/%/@}"
else else
mkdir -p "repos/$tag" mkdir -p "repos/$tag"
svn add --parents -q "repos/$tag" svn add --parents -q "repos/$tag"

View File

@@ -58,7 +58,7 @@ for _pkgname in "${pkgname[@]}"; do
elif [[ -f "$STARTDIR/$oldpkg" ]]; then elif [[ -f "$STARTDIR/$oldpkg" ]]; then
ln -s "$STARTDIR/$oldpkg" "$oldpkg" ln -s "$STARTDIR/$oldpkg" "$oldpkg"
else else
wget --quiet "$pkgurl" curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl"
fi fi
fi fi

View File

@@ -42,7 +42,7 @@ pkgbase=${pkgbase:-$pkgname}
case "$cmd" in case "$cmd" in
commitpkg) commitpkg)
if (( $# == 0 )); then if (( $# == 0 )); then
die 'usage: commitpkg <reponame> [-f] [-s server] [-l limit] [-a arch] [commit message]' die 'Usage: commitpkg <reponame> [-f] [-s server] [-l limit] [-a arch] [commit message]'
fi fi
repo="$1" repo="$1"
shift shift
@@ -51,7 +51,7 @@ case "$cmd" in
repo="${cmd%pkg}" repo="${cmd%pkg}"
;; ;;
*) *)
die 'usage: commitpkg <reponame> [-f] [-s server] [-l limit] [-a arch] [commit message]' die 'Usage: commitpkg <reponame> [-f] [-s server] [-l limit] [-a arch] [commit message]'
;; ;;
esac esac
@@ -105,15 +105,7 @@ for _arch in ${arch[@]}; do
done done
if [[ -z $server ]]; then if [[ -z $server ]]; then
case "$repo" in server='nymeria.archlinux.org'
core|extra|testing|staging|kde-unstable|gnome-unstable)
server='gerolde.archlinux.org' ;;
community*|multilib*)
server='aur.archlinux.org' ;;
*)
server='gerolde.archlinux.org'
msg "Non-standard repository $repo in use, defaulting to server $server" ;;
esac
fi fi
if [[ -n $(svn status -q) ]]; then if [[ -n $(svn status -q) ]]; then
@@ -183,19 +175,21 @@ for _arch in ${arch[@]}; do
commit_arches+=($_arch) commit_arches+=($_arch)
fi fi
done done
archrelease "${archreleaseopts[@]}" "${commit_arches[@]/#/$repo-}" || die
new_uploads=() if [[ ${#commit_arches[*]} -gt 0 ]]; then
archrelease "${archreleaseopts[@]}" "${commit_arches[@]/#/$repo-}" || die
# convert to absolute paths so rsync can work with colons (epoch) fi
while read -r -d '' upload; do
new_uploads+=("$upload")
done < <(realpath -z "${uploads[@]}")
uploads=("${new_uploads[@]}")
unset new_uploads
if [[ ${#uploads[*]} -gt 0 ]]; then if [[ ${#uploads[*]} -gt 0 ]]; then
new_uploads=()
# convert to absolute paths so rsync can work with colons (epoch)
while read -r -d '' upload; do
new_uploads+=("$upload")
done < <(realpath -z "${uploads[@]}")
uploads=("${new_uploads[@]}")
unset new_uploads
msg 'Uploading all package and signature files' msg 'Uploading all package and signature files'
rsync "${rsyncopts[@]}" "${uploads[@]}" "$server:staging/$repo/" || die rsync "${rsyncopts[@]}" "${uploads[@]}" "$server:staging/$repo/" || die
fi fi

View File

@@ -11,10 +11,10 @@ fi
pkgbase="${1}" pkgbase="${1}"
packages_svn='svn+ssh://gerolde.archlinux.org/srv/svn-packages' packages_svn='svn+ssh://svn-packages@nymeria.archlinux.org/srv/repos/svn-packages/svn'
packages_server='gerolde.archlinux.org' packages_server='nymeria.archlinux.org'
community_svn='svn+ssh://aur.archlinux.org/srv/svn-packages' community_svn='svn+ssh://svn-community@nymeria.archlinux.org/srv/repos/svn-community/svn'
community_server='aur.archlinux.org' community_server='nymeria.archlinux.org'
mirror='http://mirrors.kernel.org/archlinux' mirror='http://mirrors.kernel.org/archlinux'
case $scriptname in case $scriptname in
@@ -72,11 +72,23 @@ svn -q commit -m"${scriptname}: Moving ${pkgbase} from ${source_repo} to ${targe
pushd "target_checkout/${pkgbase}/trunk" >/dev/null pushd "target_checkout/${pkgbase}/trunk" >/dev/null
archrelease "${arch[@]/#/$target_repo-}" || die archrelease "${arch[@]/#/$target_repo-}" || die
popd >/dev/null popd >/dev/null
ssh "${target_server}" '/arch/db-update' || die
if [[ "${target_server}" == "${community_server}" ]]; then
dbscripts_path='/srv/repos/svn-community/dbscripts'
else
dbscripts_path='/srv/repos/svn-packages/dbscripts'
fi
ssh "${target_server}" "${dbscripts_path}/db-update" || die
msg "Removing ${pkgbase} from ${source_repo}" msg "Removing ${pkgbase} from ${source_repo}"
if [[ "${source_server}" == "${community_server}" ]]; then
dbscripts_path='/srv/repos/svn-community/dbscripts'
else
dbscripts_path='/srv/repos/svn-packages/dbscripts'
fi
for _arch in ${arch[@]}; do for _arch in ${arch[@]}; do
ssh "${source_server}" "/arch/db-remove ${source_repo} ${_arch} ${pkgbase}" ssh "${source_server}" "${dbscripts_path}/db-remove ${source_repo} ${_arch} ${pkgbase}"
done done
svn -q checkout -N "${source_svn}" source_checkout svn -q checkout -N "${source_svn}" source_checkout
svn -q up "source_checkout/${pkgbase}" svn -q up "source_checkout/${pkgbase}"

View File

@@ -8,7 +8,7 @@ m4_include(lib/common.sh)
match=$1 match=$1
if [[ -z $match ]]; then if [[ -z $match ]]; then
echo 'usage: finddeps <depname>' echo 'Usage: finddeps <depname>'
echo '' echo ''
echo 'Find packages that depend on a given depname.' echo 'Find packages that depend on a given depname.'
echo 'Run this script from the top-level directory of your ABS tree.' echo 'Run this script from the top-level directory of your ABS tree.'

View File

@@ -62,8 +62,6 @@ setup_workdir() {
} }
cleanup() { cleanup() {
trap - EXIT INT QUIT TERM
[[ -n $WORKDIR ]] && rm -rf "$WORKDIR" [[ -n $WORKDIR ]] && rm -rf "$WORKDIR"
[[ $1 ]] && exit $1 [[ $1 ]] && exit $1
} }
@@ -73,13 +71,23 @@ abort() {
cleanup 0 cleanup 0
} }
trap_abort() {
trap - EXIT INT QUIT TERM HUP
abort
}
trap_exit() {
trap - EXIT INT QUIT TERM HUP
cleanup
}
die() { die() {
error "$*" error "$*"
cleanup 1 cleanup 1
} }
trap abort INT QUIT TERM HUP trap 'trap_abort' INT QUIT TERM HUP
trap 'cleanup 0' EXIT trap 'trap_exit' EXIT
## ##
# usage : in_array( $needle, $haystack ) # usage : in_array( $needle, $haystack )

View File

@@ -25,9 +25,10 @@ passeddir=
default_copy=$USER default_copy=$USER
[[ -n $SUDO_USER ]] && default_copy=$SUDO_USER [[ -n $SUDO_USER ]] && default_copy=$SUDO_USER
[[ -z $default_copy || $default_copy = root ]] && default_copy=copy [[ -z $default_copy || $default_copy = root ]] && default_copy=copy
src_owner=${SUDO_USER:-$USER}
usage() { usage() {
echo "usage ${0##*/} [options] -r <chrootdir> [--] [makepkg args]" echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
echo ' Run this script in a PKGBUILD dir to build a package inside a' echo ' Run this script in a PKGBUILD dir to build a package inside a'
echo ' clean chroot. All unrecognized arguments passed to this script' echo ' clean chroot. All unrecognized arguments passed to this script'
echo ' will be passed to makepkg.' echo ' will be passed to makepkg.'
@@ -160,8 +161,8 @@ if [[ -n $install_pkg ]]; then
rm "$copydir/$pkgname" rm "$copydir/$pkgname"
# Exit early, we've done all we need to # If there is no PKGBUILD we have done
exit $ret [[ -f PKGBUILD ]] || exit $ret
fi fi
$update_first && mkarchroot -u "$copydir" $update_first && mkarchroot -u "$copydir"
@@ -274,7 +275,7 @@ if $run_namcap; then
pacman -S --needed --noconfirm namcap pacman -S --needed --noconfirm namcap
for pkgfile in /build/PKGBUILD /pkgdest/*.pkg.tar.?z; do for pkgfile in /build/PKGBUILD /pkgdest/*.pkg.tar.?z; do
echo "Checking \${pkgfile##*/}" echo "Checking \${pkgfile##*/}"
namcap "\$pkgfile" 2>&1 | tee "/build/\${pkgfile##*/}-namcap.log" sudo -u nobody namcap "\$pkgfile" 2>&1 | tee "/build/\${pkgfile##*/}-namcap.log"
done done
fi fi
@@ -292,10 +293,12 @@ if mkarchroot -r "/chrootbuild" "$copydir"; then
popd >/dev/null popd >/dev/null
fi fi
chown "$src_owner" "$pkgfile"
mv "$pkgfile" "$PKGDEST" mv "$pkgfile" "$PKGDEST"
done done
for l in "$copydir"/build/*-{build,check,namcap,package,package_*}.log; do for l in "$copydir"/build/*-{build,check,namcap,package,package_*}.log; do
chown "$src_owner" "$l"
[[ -f $l ]] && mv "$l" . [[ -f $l ]] && mv "$l" .
done done
else else
@@ -304,6 +307,7 @@ else
fi fi
for f in "$copydir"/srcdest/*; do for f in "$copydir"/srcdest/*; do
chown "$src_owner" "$f"
mv "$f" "$SRCDEST" mv "$f" "$SRCDEST"
done done

View File

@@ -22,7 +22,7 @@ APPNAME=$(basename "${0}")
# usage: usage <exitvalue> # usage: usage <exitvalue>
usage() { usage() {
echo "usage ${APPNAME} [options] working-dir [package-list | app]" echo "Usage: ${APPNAME} [options] working-dir [package-list | app]"
echo ' options:' echo ' options:'
echo ' -r <app> Run "app" within the context of the chroot' echo ' -r <app> Run "app" within the context of the chroot'
echo ' -u Update the chroot via pacman' echo ' -u Update the chroot via pacman'
@@ -44,7 +44,7 @@ while getopts 'r:ufnhC:M:c:' arg; do
M) makepkg_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;;
n) NOCOPY='y' ;; n) NOCOPY='y' ;;
c) cache_dir="$OPTARG" ;; c) cache_dir="$OPTARG" ;;
h|?) usage 0 ;; h|?) usage ;;
*) error "invalid argument '${arg}'"; usage ;; *) error "invalid argument '${arg}'"; usage ;;
esac esac
done done
@@ -78,66 +78,35 @@ if echo "${host_mirror}" | grep -q 'file://'; then
fi fi
# {{{ functions # {{{ functions
chroot_mount() { bind_mount() {
[[ -e "${working_dir}/sys" ]] || mkdir "${working_dir}/sys" local mode="${2:-rw}"
mount -o bind /sys "${working_dir}/sys" local target="${working_dir}${1}"
mount -o remount,ro,bind "${working_dir}/sys"
[[ -e "${working_dir}/proc" ]] || mkdir "${working_dir}/proc" if [[ ! -e "$target" ]]; then
mount -t proc proc -o nosuid,noexec,nodev "${working_dir}/proc" if [[ -d "$1" ]]; then
mount -o bind /proc/sys "${working_dir}/proc/sys" install -d "$target"
mount -o remount,ro,bind "${working_dir}/proc/sys"
[[ -e "${working_dir}/dev" ]] || mkdir "${working_dir}/dev"
mount -t tmpfs dev "${working_dir}/dev" -o mode=0755,size=10M,nosuid,strictatime
mknod -m 666 "${working_dir}/dev/null" c 1 3
mknod -m 666 "${working_dir}/dev/zero" c 1 5
mknod -m 600 "${working_dir}/dev/console" c 5 1
mknod -m 644 "${working_dir}/dev/random" c 1 8
mknod -m 644 "${working_dir}/dev/urandom" c 1 9
mknod -m 666 "${working_dir}/dev/tty" c 5 0
mknod -m 666 "${working_dir}/dev/ptmx" c 5 2
mknod -m 666 "${working_dir}/dev/tty0" c 4 0
mknod -m 666 "${working_dir}/dev/full" c 1 7
mknod -m 666 "${working_dir}/dev/rtc0" c 254 0
ln -s /proc/kcore "${working_dir}/dev/core"
ln -s /proc/self/fd "${working_dir}/dev/fd"
ln -s /proc/self/fd/0 "${working_dir}/dev/stdin"
ln -s /proc/self/fd/1 "${working_dir}/dev/stdout"
ln -s /proc/self/fd/2 "${working_dir}/dev/stderr"
[[ -e "${working_dir}/dev/shm" ]] || mkdir "${working_dir}/dev/shm"
mount -t tmpfs shm "${working_dir}/dev/shm" -o nodev,nosuid,size=128M
[[ -e "${working_dir}/dev/pts" ]] || mkdir "${working_dir}/dev/pts"
mount -o bind /dev/pts "${working_dir}/dev/pts"
[[ -e "${working_dir}/run" ]] || mkdir "${working_dir}/run"
mount -t tmpfs tmpfs "${working_dir}/run" -o nodev,nosuid,strictatime,size=64M
if [[ -n $host_mirror_path ]]; then
[[ -e "${working_dir}/${host_mirror_path}" ]] || mkdir -p "${working_dir}/${host_mirror_path}"
mount -o bind "${host_mirror_path}" "${working_dir}/${host_mirror_path}"
mount -o remount,ro,bind "${working_dir}/${host_mirror_path}"
fi
local cache_dir_first=true
for cache_dir in ${cache_dirs[@]}; do
[[ -e $cache_dir ]] || mkdir -p "${cache_dir}"
[[ -e "${working_dir}/${cache_dir}" ]] || mkdir -p "${working_dir}/${cache_dir}"
mount -o bind "${cache_dir}" "${working_dir}/${cache_dir}"
if ! ${cache_dir_first}; then
mount -o remount,ro,bind "${working_dir}/${cache_dir}"
else else
cache_dir_first=false install -D /dev/null "$target"
fi
fi fi
done
trap 'chroot_umount' EXIT INT QUIT TERM HUP mount -o bind "$1" "$target"
mount -o remount,${mode},bind "$target"
mount --make-slave "$target"
}
chroot_mount() {
trap 'trap_chroot_umount' EXIT INT QUIT TERM HUP
[[ -n $host_mirror_path ]] && bind_mount "$host_mirror_path" ro
bind_mount "${cache_dirs[0]}"
for cache_dir in ${cache_dirs[@]:1}; do
bind_mount "$cache_dir" ro
done
} }
copy_hostconf () { copy_hostconf () {
cp /etc/resolv.conf "${working_dir}/etc/resolv.conf"
cp -a /etc/pacman.d/gnupg "${working_dir}/etc/pacman.d" cp -a /etc/pacman.d/gnupg "${working_dir}/etc/pacman.d"
echo "Server = ${host_mirror}" > ${working_dir}/etc/pacman.d/mirrorlist echo "Server = ${host_mirror}" > ${working_dir}/etc/pacman.d/mirrorlist
@@ -152,14 +121,10 @@ copy_hostconf () {
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i ${working_dir}/etc/pacman.conf sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i ${working_dir}/etc/pacman.conf
} }
chroot_umount () { trap_chroot_umount () {
umount "${working_dir}/proc/sys" trap 'trap_abort' INT QUIT TERM HUP
umount "${working_dir}/proc" trap 'trap_exit' EXIT
umount "${working_dir}/sys"
umount "${working_dir}/dev/pts"
umount "${working_dir}/dev/shm"
umount "${working_dir}/dev"
umount "${working_dir}/run"
for cache_dir in ${cache_dirs[@]}; do for cache_dir in ${cache_dirs[@]}; do
umount "${working_dir}/${cache_dir}" umount "${working_dir}/${cache_dir}"
done done
@@ -179,6 +144,13 @@ chroot_lock () {
stat_done stat_done
fi fi
} }
chroot_run() {
local dir=$1
shift
eval systemd-nspawn -D "${dir}" -- ${@} 2>/dev/null
}
# }}} # }}}
umask 0022 umask 0022
@@ -195,7 +167,7 @@ if [[ -n $RUN ]]; then
chroot_mount chroot_mount
copy_hostconf copy_hostconf
eval unshare -mui -- chroot "${working_dir}" ${RUN} chroot_run "${working_dir}" ${RUN}
# }}} # }}}
else else
@@ -208,37 +180,31 @@ else
chmod 0755 "${working_dir}" chmod 0755 "${working_dir}"
fi fi
mkdir -p "${working_dir}/var/lib/pacman/sync"
mkdir -p "${working_dir}/etc/"
chroot_lock chroot_lock
chroot_mount chroot_mount
pacargs="--noconfirm --root=${working_dir} ${cache_dirs[@]/#/--cachedir=}" pacargs="${cache_dirs[@]/#/--cachedir=}"
if [[ -n $pac_conf ]]; then if [[ -n $pac_conf ]]; then
pacargs="$pacargs --config=${pac_conf}" pacargs="$pacargs --config=${pac_conf}"
fi fi
if (( $# != 0 )); then if (( $# != 0 )); then
op='-Sy'
if [[ $FORCE = 'y' ]]; then if [[ $FORCE = 'y' ]]; then
op="${op}f" pacargs="$pacargs --force"
fi fi
if ! pacman ${op} ${pacargs} $@; then if ! pacstrap -GMcd "${working_dir}" ${pacargs} $@; then
die 'Failed to install all packages' die 'Failed to install all packages'
fi fi
fi fi
if [[ -d "${working_dir}/lib/modules" ]]; then if [[ -d "${working_dir}/lib/modules" ]]; then
ldconfig -r "${working_dir}" chroot_run "${working_dir}" ldconfig
fi fi
if [[ -e "${working_dir}/etc/locale.gen" ]]; then if [[ -e "${working_dir}/etc/locale.gen" ]]; then
sed -i 's@^#\(en_US\|de_DE\)\(\.UTF-8\)@\1\2@' "${working_dir}/etc/locale.gen" sed -i 's@^#\(en_US\|de_DE\)\(\.UTF-8\)@\1\2@' "${working_dir}/etc/locale.gen"
chroot "${working_dir}" /usr/sbin/locale-gen chroot_run "${working_dir}" locale-gen
fi fi
echo 'UTC' > "${working_dir}/etc/timezone"
ln -s /usr/share/zoneinfo/UTC "${working_dir}/etc/localtime"
echo 'LANG=C' > "${working_dir}/etc/locale.conf" echo 'LANG=C' > "${working_dir}/etc/locale.conf"
copy_hostconf copy_hostconf

View File

@@ -12,7 +12,7 @@
m4_include(lib/common.sh) m4_include(lib/common.sh)
if (( $# < 1 )); then if (( $# < 1 )); then
echo "usage: $(basename $0) <chrootdir> <packages to rebuild>" echo "Usage: $(basename $0) <chrootdir> <packages to rebuild>"
echo " example: $(basename $0) ~/chroot readline bash foo bar baz" echo " example: $(basename $0) ~/chroot readline bash foo bar baz"
exit 1 exit 1
fi fi
@@ -47,7 +47,7 @@ pkg_from_pkgbuild() {
chrootdir="$1"; shift chrootdir="$1"; shift
pkgs="$@" pkgs="$@"
SVNPATH='svn+ssh://gerolde.archlinux.org/srv/svn-packages' SVNPATH='svn+ssh://nymeria.archlinux.org/srv/repos/svn-packages/svn'
msg "Work will be done in $(pwd)/rebuilds" msg "Work will be done in $(pwd)/rebuilds"