Compare commits

..

24 Commits

Author SHA1 Message Date
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
11 changed files with 148 additions and 94 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=20120616 V=20121115
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

View File

@@ -61,13 +61,13 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
-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})..."

View File

@@ -13,7 +13,7 @@ case $scriptname in
archco) archco)
SVNURL="svn+ssh://gerolde.archlinux.org/srv/svn-packages";; SVNURL="svn+ssh://gerolde.archlinux.org/srv/svn-packages";;
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

@@ -109,7 +109,7 @@ if [[ -z $server ]]; then
core|extra|testing|staging|kde-unstable|gnome-unstable) core|extra|testing|staging|kde-unstable|gnome-unstable)
server='gerolde.archlinux.org' ;; server='gerolde.archlinux.org' ;;
community*|multilib*) community*|multilib*)
server='aur.archlinux.org' ;; server='nymeria.archlinux.org' ;;
*) *)
server='gerolde.archlinux.org' server='gerolde.archlinux.org'
msg "Non-standard repository $repo in use, defaulting to server $server" ;; msg "Non-standard repository $repo in use, defaulting to server $server" ;;

View File

@@ -13,8 +13,8 @@ pkgbase="${1}"
packages_svn='svn+ssh://gerolde.archlinux.org/srv/svn-packages' packages_svn='svn+ssh://gerolde.archlinux.org/srv/svn-packages'
packages_server='gerolde.archlinux.org' packages_server='gerolde.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='/arch'
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='/arch'
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

@@ -62,8 +62,6 @@ setup_workdir() {
} }
cleanup() { cleanup() {
trap - EXIT INT QUIT TERM HUP
[[ -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,6 +25,7 @@ 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]"
@@ -212,12 +213,12 @@ if ! grep -q 'SRCDEST="/srcdest"' "$copydir/etc/makepkg.conf"; then
echo 'SRCDEST="/srcdest"' >> "$copydir/etc/makepkg.conf" echo 'SRCDEST="/srcdest"' >> "$copydir/etc/makepkg.conf"
fi fi
if [[ -n $MAKEFLAGS ]]; then if [[ -n $MAKEFLAGS ]]; then
sed -i '/^MAKEFLAGS=/d' "$copydir/etc/makepkg.conf" sed -i '/^MAKEFLAGS=/d' "$copydir/etc/makepkg.conf"
echo "MAKEFLAGS='${MAKEFLAGS}'" >> "$copydir/etc/makepkg.conf" echo "MAKEFLAGS='${MAKEFLAGS}'" >> "$copydir/etc/makepkg.conf"
fi fi
if [[ -n $PACKAGER ]]; then if [[ -n $PACKAGER ]]; then
sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg.conf" sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg.conf"
echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf" echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf"
fi fi
@@ -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

@@ -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,73 @@ 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" else
install -D /dev/null "$target"
[[ -e "${working_dir}/dev" ]] || mkdir "${working_dir}/dev" fi
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 mode=0755,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 fi
local cache_dir_first=true mount -o bind "$1" "$target"
for cache_dir in ${cache_dirs[@]}; do mount -o remount,${mode},bind "$target"
[[ -e $cache_dir ]] || mkdir -p "${cache_dir}" mount --make-slave "$target"
[[ -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
cache_dir_first=false
fi
done
trap 'chroot_umount' EXIT INT QUIT TERM HUP chroot_mount() {
trap 'trap_chroot_umount' EXIT INT QUIT TERM HUP
if (( ! have_nspawn )); then
bind_mount /sys ro
[[ -e "${working_dir}/proc" ]] || mkdir "${working_dir}/proc"
mount -t proc proc -o nosuid,noexec,nodev "${working_dir}/proc"
bind_mount /proc/sys ro
[[ -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
bind_mount /dev/pts
[[ -e "${working_dir}/run" ]] || mkdir "${working_dir}/run"
mount -t tmpfs tmpfs "${working_dir}/run" -o mode=0755,nodev,nosuid,strictatime,size=64M
for host_config in resolv.conf localtime; do
bind_mount /etc/$host_config ro
done
fi
[[ -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,19 +159,27 @@ 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 () {
trap - EXIT INT QUIT TERM HUP trap 'trap_abort' INT QUIT TERM HUP
umount "${working_dir}/proc/sys" trap 'trap_exit' EXIT
umount "${working_dir}/proc"
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
[[ -n $host_mirror_path ]] && umount "${working_dir}/${host_mirror_path}" [[ -n $host_mirror_path ]] && umount "${working_dir}/${host_mirror_path}"
if (( ! have_nspawn )); then
for host_config in resolv.conf localtime; do
umount "${working_dir}/etc/${host_config}"
done
umount "${working_dir}/proc/sys"
umount "${working_dir}/proc"
umount "${working_dir}/sys"
umount "${working_dir}/dev/pts"
umount "${working_dir}/dev/shm"
umount "${working_dir}/dev"
umount "${working_dir}/run"
fi
} }
chroot_lock () { chroot_lock () {
@@ -180,8 +195,24 @@ chroot_lock () {
stat_done stat_done
fi fi
} }
chroot_run() {
local dir=$1
shift
if (( have_nspawn)); then
eval systemd-nspawn -D "${dir}" -- ${@} 2>/dev/null
else
eval unshare -mui -- chroot "${dir}" ${@}
fi
}
# }}} # }}}
# use systemd-nspawn if we have it available and systemd is running
if type -P systemd-nspawn >/dev/null && mountpoint -q /sys/fs/cgroup/systemd; then
have_nspawn=1
fi
umask 0022 umask 0022
if [[ -n $RUN ]]; then if [[ -n $RUN ]]; then
# run chroot {{{ # run chroot {{{
@@ -196,7 +227,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
@@ -209,37 +240,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