mirror of
https://gitlab.archlinux.org/archlinux/devtools.git
synced 2025-09-13 18:06:19 +02:00
Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
59b7a739e8 | ||
![]() |
9e14e8691d | ||
![]() |
c22a6014d7 | ||
![]() |
d440e5998d | ||
![]() |
611314a740 | ||
![]() |
c39e59892d | ||
![]() |
f76261f073 | ||
![]() |
a37c07a8cb | ||
![]() |
72a2b4789a | ||
![]() |
30cfcdc501 | ||
![]() |
f09baea392 | ||
![]() |
d68e7cb031 | ||
![]() |
106a0cddfe | ||
![]() |
0e43db65b2 | ||
![]() |
3e3b32641d | ||
![]() |
16dd1fe6e0 | ||
![]() |
f8ab1fb7a7 | ||
![]() |
4ea489ad85 | ||
![]() |
0346db0ff7 | ||
![]() |
a1ede4dd4b | ||
![]() |
7ce9cd6965 | ||
![]() |
a7d88845a8 | ||
![]() |
ea4b0d0a67 | ||
![]() |
0c17e0d9fc |
40
archrelease
40
archrelease
@@ -21,35 +21,13 @@ if [ "$(svn diff)" != "" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d ../repos/$1 ]; then
|
||||
pushd ..
|
||||
[ -d repos ] || mkdir repos
|
||||
svn copy -r HEAD trunk repos/$1
|
||||
svn commit -m "archrelease: new repo $1"
|
||||
pushd repos/$1
|
||||
svnmerge init
|
||||
svn commit -F svnmerge-commit-message.txt
|
||||
rm svnmerge-commit-message.txt
|
||||
popd
|
||||
popd
|
||||
else
|
||||
svnmerge merge ../repos/$1
|
||||
pushd ..
|
||||
if [ -f trunk/svnmerge-commit-message.txt ]; then
|
||||
svn commit -F trunk/svnmerge-commit-message.txt
|
||||
if [ $? -ne 0 ]; then
|
||||
# The user is going to have to clean things up a bit
|
||||
echo "*** ATTENTION: There was a problem merging the package changes ***"
|
||||
echo "To fix it, edit the conflicting files in repos/$1 (the ones that are C in svn status)."
|
||||
echo "Once you have resolved conflicts, execute 'svn resolved <path to file>' to tell svn the error was resolved."
|
||||
echo "Then to finish the merge commit, execute 'svn commit -F trunk/svnmerge-commit-message.txt' and, if there are no problems, delete trunk/svnmerge-commit-message.txt"
|
||||
exit $?
|
||||
fi
|
||||
rm trunk/svnmerge-commit-message.txt
|
||||
else
|
||||
echo "Nothing to commit"
|
||||
fi
|
||||
popd
|
||||
echo -n 'releasing package...'
|
||||
pushd .. >/dev/null
|
||||
if [ -d repos/$1 ]; then
|
||||
svn rm --force -q repos/$1
|
||||
svn commit -q -m "archrelease: remove $1"
|
||||
fi
|
||||
|
||||
echo "===> Tagged for $1"
|
||||
svn copy -q -r HEAD trunk repos/$1
|
||||
svn commit -q -m "archrelease: copy trunk to $1"
|
||||
popd >/dev/null
|
||||
echo 'done'
|
||||
|
71
commitpkg
71
commitpkg
@@ -5,17 +5,6 @@ abort() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Verify that a remote file exists and is identical to a local one
|
||||
# Usage: package_verify <local path> <remote host> <remote path>
|
||||
package_verify() {
|
||||
local remote_checksum=$(ssh $2 openssl sha1 "'$3'" 2>/dev/null |
|
||||
grep -o '[0-9a-f]\{40\}$')
|
||||
local local_checksum=$(openssl sha1 "$1" | grep -o '[0-9a-f]\{40\}$')
|
||||
if [ -n "$remote_checksum" -a "$remote_checksum" == "$local_checksum" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Source makepkg.conf; fail if it is not found
|
||||
if [ -r "/etc/makepkg.conf" ]; then
|
||||
@@ -60,61 +49,55 @@ else
|
||||
shift
|
||||
fi
|
||||
|
||||
# see if any limit options were passed, we'll send them to SCP
|
||||
unset scpopts
|
||||
# check if all local source files are under version control
|
||||
(for s in ${source[@]} $install; do
|
||||
echo $s | grep -vq '://' && \
|
||||
svn status $s | grep -q '?' && \
|
||||
abort "$s is not under version control"
|
||||
done) || true
|
||||
|
||||
# see if any limit options were passed, we'll send them to rsync
|
||||
unset rsyncopts
|
||||
if [ "$1" = "-l" ]; then
|
||||
scpopts="-l $2"
|
||||
rsyncopts="--bwlimit=$2"
|
||||
shift 2
|
||||
fi
|
||||
|
||||
echo -n 'committing changes to trunk...'
|
||||
if [ -n "$1" ]; then
|
||||
svn commit -q -m "upgpkg: $pkgbase $pkgver-$pkgrel
|
||||
$1" || abort
|
||||
else
|
||||
svn commit -q || abort
|
||||
fi
|
||||
echo 'done'
|
||||
|
||||
for _arch in ${arch[@]}; do
|
||||
echo "===> Uploading to staging/$repo for arch=${_arch}"
|
||||
for _pkgname in ${pkgname[@]}; do
|
||||
pkgfile=$_pkgname-$pkgver-$pkgrel-${_arch}$PKGEXT
|
||||
|
||||
if [ ! -f $pkgfile -a -f "$PKGDEST/$pkgfile" ]; then
|
||||
pkgfile="$PKGDEST/$pkgfile"
|
||||
elif [ ! -f $pkgfile ]; then
|
||||
echo "File $pkgfile doesn't exist"
|
||||
# skip to next architecture
|
||||
echo "skipping ${_arch}"
|
||||
continue 2
|
||||
fi
|
||||
|
||||
# combine what we know into a variable
|
||||
uploadto=staging/$repo/$(basename "$pkgfile")
|
||||
# don't re-upload the same package (useful for -any sub packages)
|
||||
if ! package_verify "$pkgfile" $server "$uploadto"; then
|
||||
scp $scpopts "$pkgfile" $server:"$uploadto" || abort
|
||||
fi
|
||||
if ! package_verify "$pkgfile" $server "$uploadto"; then
|
||||
abort "File got corrupted during upload, cancelled."
|
||||
else
|
||||
echo "File integrity okay."
|
||||
fi
|
||||
echo "===> Uploaded $pkgfile"
|
||||
echo -n 'uploading '
|
||||
rsync -c -h --progress $rsyncopts "${pkgfile}" -e ssh $server:staging/$repo || abort
|
||||
done
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
svn commit -m "upgpkg: $pkgbase $pkgver-$pkgrel
|
||||
$1" >/dev/null || abort
|
||||
echo "===> Commited with message:
|
||||
upgpkg: $pkgbase $pkgver-$pkgrel
|
||||
$1"
|
||||
else
|
||||
svn commit || abort
|
||||
echo "===> Commited"
|
||||
fi
|
||||
|
||||
archrelease $repo-${_arch} || abort
|
||||
done
|
||||
|
||||
if [ "${arch[*]}" == "any" ]; then
|
||||
if [ -d ../repos/$repo-i686 -a -d ../repos/$repo-x86_64 ]; then
|
||||
pushd ../repos/
|
||||
pushd ../repos/ >/dev/null
|
||||
echo -n "removing $repo-i686 and $repo-x86_64..."
|
||||
svn rm $repo-i686
|
||||
svn rm $repo-x86_64
|
||||
svn commit -m "removed $repo-i686 and $repo-x86_64 for $pkgname"
|
||||
popd
|
||||
svn commit -q -m "removed $repo-i686 and $repo-x86_64 for $pkgname"
|
||||
echo 'done'
|
||||
popd >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
|
147
makechrootpkg
147
makechrootpkg
@@ -12,7 +12,7 @@ FORCE="n"
|
||||
RUN=""
|
||||
MAKEPKG_ARGS="-sr"
|
||||
REPACK=""
|
||||
LAYER="rw"
|
||||
COPY="copy"
|
||||
WORKDIR=$PWD
|
||||
|
||||
update_first="0"
|
||||
@@ -32,8 +32,8 @@ usage ()
|
||||
echo " will be passed to makepkg."
|
||||
echo ""
|
||||
echo " The chroot dir consists of the following directories:"
|
||||
echo " <chrootdir>/{root, rw, union} but only 'root' is required"
|
||||
echo " by default. The rest will be created as needed"
|
||||
echo " <chrootdir>/{root, copy} but only 'root' is required"
|
||||
echo " by default. The working copy will be created as needed"
|
||||
echo ""
|
||||
echo "The chroot 'root' directory must be created via the following"
|
||||
echo "command:"
|
||||
@@ -44,14 +44,14 @@ usage ()
|
||||
echo "Flags:"
|
||||
echo "-h This help"
|
||||
echo "-c Clean the chroot before building"
|
||||
echo "-u Update the rw layer of the chroot before building"
|
||||
echo "-u Update the working copy of the chroot before building"
|
||||
echo " This is useful for rebuilds without dirtying the pristine"
|
||||
echo " chroot"
|
||||
echo "-d Add the package to a local db at /repo after building"
|
||||
echo "-r <dir> The chroot shell to use"
|
||||
echo "-I <pkg> Install a package into the rw layer of the chroot"
|
||||
echo "-l <layer> The directory to use as the rw layer of the union"
|
||||
echo " Useful for maintain multiple layers. Default: rw"
|
||||
echo "-r <dir> The chroot dir to use"
|
||||
echo "-I <pkg> Install a package into the working copy of the chroot"
|
||||
echo "-l <copy> The directory to use as the working copy of the chroot"
|
||||
echo " Useful for maintain multiple copies Default: copy"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -63,13 +63,14 @@ while getopts 'hcudr:I:l:' arg; do
|
||||
d) add_to_db=1 ;;
|
||||
r) chrootdir="$OPTARG" ;;
|
||||
I) install_pkg="$OPTARG" ;;
|
||||
l) LAYER="$OPTARG" ;;
|
||||
l) COPY="$OPTARG" ;;
|
||||
*) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
#Get rid of trailing / in chrootdir
|
||||
[ "$chrootdir" != "/" ] && chrootdir=$(echo $chrootdir | sed 's#/$##')
|
||||
copydir="$chrootdir/$COPY"
|
||||
|
||||
# Pass all arguments after -- right to makepkg
|
||||
MAKEPKG_ARGS="$MAKEPKG_ARGS ${*:$OPTIND}"
|
||||
@@ -104,77 +105,58 @@ if [ ! -d "$chrootdir/root" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
[ -d "$chrootdir/$LAYER" -a "$clean_first" -eq "1" ] && rm -rf "$chrootdir/$LAYER/"
|
||||
[ -d "$chrootdir/$LAYER" ] || mkdir "$chrootdir/$LAYER"
|
||||
[ -d "$chrootdir/union" ] || mkdir "$chrootdir/union"
|
||||
|
||||
cleanup ()
|
||||
{
|
||||
echo "cleaning up unioned mounts"
|
||||
umount "$chrootdir/union"
|
||||
}
|
||||
|
||||
uniondir="$chrootdir/union"
|
||||
echo "building union chroot"
|
||||
grep -Fq aufs /proc/filesystems
|
||||
if [ $? -ne 0 ]; then
|
||||
modprobe -q aufs
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: No aufs available. Abandon ship!" && exit 1
|
||||
fi
|
||||
umask 000
|
||||
if [ ! -d "$copydir" -o "$clean_first" -eq "1" ]; then
|
||||
echo -n 'creating clean working copy...'
|
||||
mkdir -p "$copydir"
|
||||
rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
|
||||
echo 'done'
|
||||
fi
|
||||
mount -t aufs none -o "dirs=$chrootdir/$LAYER=rw:$chrootdir/root=ro" "$uniondir"
|
||||
trap 'cleanup' 0 1 2 15
|
||||
|
||||
if [ -n "$install_pkg" ]; then
|
||||
pkgname="$(basename "$install_pkg")"
|
||||
echo "installing '$pkgname' in chroot"
|
||||
cp "$install_pkg" "$uniondir/$pkgname"
|
||||
mkarchroot -r "pacman -U /$pkgname" "$uniondir"
|
||||
cp "$install_pkg" "$copydir/$pkgname"
|
||||
mkarchroot -r "pacman -U /$pkgname" "$copydir"
|
||||
ret=$?
|
||||
rm "$uniondir/$pkgname"
|
||||
rm "$copydir/$pkgname"
|
||||
#exit early, we've done all we need to
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
if [ $update_first -eq 1 ]; then
|
||||
echo "updating chroot"
|
||||
mkarchroot -r "pacman -Syu --noconfirm" "$uniondir"
|
||||
mkarchroot -r "pacman -Syu --noconfirm" "$copydir"
|
||||
fi
|
||||
|
||||
echo "moving build files to chroot"
|
||||
[ -d "$uniondir/build" ] || mkdir "$uniondir/build"
|
||||
[ -d "$copydir/build" ] || mkdir "$copydir/build"
|
||||
|
||||
if [ "$REPACK" != "1" ]; then
|
||||
#Remove anything in there UNLESS -R (repack) was passed to makepkg
|
||||
rm -rf "$uniondir/build/"*
|
||||
rm -rf "$copydir/build/"*
|
||||
fi
|
||||
|
||||
[ -d "$uniondir/pkgdest" ] || mkdir "$uniondir/pkgdest"
|
||||
if ! grep "PKGDEST=/pkgdest" "$uniondir/etc/makepkg.conf" >/dev/null 2>&1; then
|
||||
echo "Setting PKGDEST in makepkg.conf"
|
||||
echo "PKGDEST=/pkgdest" >> "$uniondir/etc/makepkg.conf"
|
||||
# Get SRC/PKGDEST from makepkg.conf
|
||||
SRCDEST=$(grep '^SRCDEST=' /etc/makepkg.conf | cut -d= -f2)
|
||||
PKGDEST=$(grep '^PKGDEST=' /etc/makepkg.conf | cut -d= -f2)
|
||||
|
||||
[ -d "$copydir/pkgdest" ] || mkdir "$copydir/pkgdest"
|
||||
if ! grep "PKGDEST=/pkgdest" "$copydir/etc/makepkg.conf" >/dev/null 2>&1; then
|
||||
echo "PKGDEST=/pkgdest" >> "$copydir/etc/makepkg.conf"
|
||||
fi
|
||||
|
||||
[ -d "$uniondir/srcdest" ] || mkdir "$uniondir/srcdest"
|
||||
if ! grep "SRCDEST=/srcdest" "$uniondir/etc/makepkg.conf" >/dev/null 2>&1; then
|
||||
echo "Setting SRCDEST in makepkg.conf"
|
||||
echo "SRCDEST=/srcdest" >> "$uniondir/etc/makepkg.conf"
|
||||
[ -d "$copydir/srcdest" ] || mkdir "$copydir/srcdest"
|
||||
if ! grep "SRCDEST=/srcdest" "$copydir/etc/makepkg.conf" >/dev/null 2>&1; then
|
||||
echo "SRCDEST=/srcdest" >> "$copydir/etc/makepkg.conf"
|
||||
fi
|
||||
|
||||
chown -R nobody "$uniondir/build"
|
||||
chown -R nobody "$uniondir/srcdest"
|
||||
chown -R nobody "$uniondir/pkgdest"
|
||||
|
||||
# Copy PKGBUILD and sources
|
||||
source PKGBUILD
|
||||
cp PKGBUILD "$uniondir/build/"
|
||||
cp PKGBUILD "$copydir/build/"
|
||||
for f in ${source[@]}; do
|
||||
basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g')
|
||||
if [ -f "$basef" ]; then
|
||||
cp "$basef" "$uniondir/srcdest/"
|
||||
cp "$basef" "$copydir/srcdest/"
|
||||
elif [ -f "$SRCDEST/$basef" ]; then
|
||||
cp "$SRCDEST/$basef" "$uniondir/srcdest/"
|
||||
cp "$SRCDEST/$basef" "$copydir/srcdest/"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -188,23 +170,26 @@ done
|
||||
for f in $install_files;do
|
||||
install="${f#"install="}"
|
||||
if [ "$install" != "" -a -f "$install" ]; then
|
||||
cp "$install" "$uniondir/build/"
|
||||
cp "$install" "$copydir/build/"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f "ChangeLog" ]; then
|
||||
cp ChangeLog "$uniondir/build/"
|
||||
cp ChangeLog "$copydir/build/"
|
||||
fi
|
||||
|
||||
if ! grep "^nobody" "$uniondir/etc/sudoers" >/dev/null 2>&1; then
|
||||
echo "allowing 'nobody' sudo rights in the chroot"
|
||||
touch "$uniondir/etc/sudoers"
|
||||
echo "nobody ALL=(ALL) NOPASSWD: ALL" >> "$uniondir/etc/sudoers"
|
||||
chmod 440 "$uniondir/etc/sudoers"
|
||||
chown -R nobody "$copydir/build"
|
||||
chown -R nobody "$copydir/srcdest"
|
||||
chown -R nobody "$copydir/pkgdest"
|
||||
|
||||
if ! grep "^nobody" "$copydir/etc/sudoers" >/dev/null 2>&1; then
|
||||
touch "$copydir/etc/sudoers"
|
||||
echo "nobody ALL=(ALL) NOPASSWD: ALL" >> "$copydir/etc/sudoers"
|
||||
chmod 440 "$copydir/etc/sudoers"
|
||||
fi
|
||||
|
||||
#This is a little gross, but this way the script is recreated every time in the
|
||||
#rw portion of the union
|
||||
#working copy
|
||||
(cat <<EOF
|
||||
#!/bin/bash
|
||||
export LANG=$LOCALE
|
||||
@@ -215,56 +200,50 @@ sudo -u nobody makepkg $MAKEPKG_ARGS || touch BUILD_FAILED
|
||||
which namcap &>/dev/null && namcap /build/PKGBUILD /pkgdest/*${PKGEXT} > /pkgdest/namcap.log
|
||||
exit 0
|
||||
EOF
|
||||
) > "$uniondir/chrootbuild"
|
||||
chmod +x "$uniondir/chrootbuild"
|
||||
) > "$copydir/chrootbuild"
|
||||
chmod +x "$copydir/chrootbuild"
|
||||
|
||||
if mkarchroot -r "/chrootbuild" "$uniondir"; then
|
||||
|
||||
# Source global makepkg.conf for SRCDEST and PKGDEST vars
|
||||
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf
|
||||
[ -f ~/.makepkg.conf ] && source ~/.makepkg.conf
|
||||
|
||||
for pkgfile in "${chrootdir}"/union/pkgdest/*${PKGEXT}; do
|
||||
if mkarchroot -r "/chrootbuild" "$copydir"; then
|
||||
for pkgfile in "${copydir}"/pkgdest/*${PKGEXT}; do
|
||||
[ -e "$pkgfile" ] || continue
|
||||
_pkgname=$(basename "$pkgfile")
|
||||
if [ "$add_to_db" -eq "1" ]; then
|
||||
[ -d "${chrootdir}/union/repo" ] || mkdir -p "${chrootdir}/union/repo"
|
||||
pushd "${chrootdir}/union/repo" >/dev/null
|
||||
[ -d "${copydir}/repo" ] || mkdir -p "${copydir}/repo"
|
||||
pushd "${copydir}/repo" >/dev/null
|
||||
cp "$pkgfile" .
|
||||
repo-add repo.db.tar.${DB_COMPRESSION} "$_pkgname"
|
||||
repo-add repo.db.tar.gz "$_pkgname"
|
||||
popd >/dev/null
|
||||
fi
|
||||
|
||||
if [ -d "$PKGDEST" ]; then
|
||||
echo "Moving completed ${_pkgname%${PKGEXT}} package file to ${PKGDEST}"
|
||||
mv "$pkgfile" "${PKGDEST}"
|
||||
else
|
||||
echo "Moving completed ${_pkgname%${PKGEXT}} package file to ${WORKDIR}"
|
||||
mv "$pkgfile" "${WORKDIR}"
|
||||
fi
|
||||
done
|
||||
|
||||
for f in "${chrootdir}"/union/srcdest/*; do
|
||||
for f in "${copydir}"/srcdest/*; do
|
||||
[ -e "$f" ] || continue
|
||||
if [ -d "$SRCDEST" ]; then
|
||||
echo "Moving downloaded source file $(basename $f) to ${SRCDEST}"
|
||||
mv "$f" "${SRCDEST}"
|
||||
else
|
||||
echo "Moving downloaded source file $(basename $f) to ${WORKDIR}"
|
||||
mv "$f" "${WORKDIR}"
|
||||
fi
|
||||
done
|
||||
|
||||
for l in "${copydir}"/build/*-{build,package}.log; do
|
||||
[ -f "$l" ] && mv "$l" "${WORKDIR}"
|
||||
done
|
||||
else
|
||||
#just in case. We returned 1, make sure we fail
|
||||
touch "${chrootdir}/union/build/BUILD_FAILED"
|
||||
touch "${copydir}/build/BUILD_FAILED"
|
||||
fi
|
||||
|
||||
if [ -e "${chrootdir}/union/build/BUILD_FAILED" ]; then
|
||||
echo "Build failed, check $chrootdir/$LAYER/build"
|
||||
rm "${chrootdir}/union/build/BUILD_FAILED"
|
||||
if [ -e "${copydir}/build/BUILD_FAILED" ]; then
|
||||
echo "Build failed, check $copydir/build"
|
||||
rm "${copydir}/build/BUILD_FAILED"
|
||||
else
|
||||
rm -rf "${chrootdir}"/union/build/*
|
||||
echo "Build complete"
|
||||
rm -rf "${copydir}"/build/*
|
||||
fi
|
||||
|
||||
|
||||
|
39
mkarchroot
39
mkarchroot
@@ -13,6 +13,7 @@ RUN=""
|
||||
NOCOPY="n"
|
||||
|
||||
working_dir=""
|
||||
cache_dir=$((grep -m 1 '^CacheDir' /etc/pacman.conf || echo 'CacheDir = /var/cache/pacman/pkg') | sed 's/CacheDir\s*=\s*//')
|
||||
|
||||
APPNAME=$(basename "${0}")
|
||||
|
||||
@@ -24,14 +25,15 @@ usage ()
|
||||
echo " -r <app> Run 'app' within the context of the chroot"
|
||||
echo " -u Update the chroot via pacman"
|
||||
echo " -f Force overwrite of files in the working-dir"
|
||||
echo " -C <file> location of a pacman config file"
|
||||
echo " -M <file> location of a makepkg config file"
|
||||
echo " -n do not copy config files into the chroot"
|
||||
echo " -C <file> Location of a pacman config file"
|
||||
echo " -M <file> Location of a makepkg config file"
|
||||
echo " -n Do not copy config files into the chroot"
|
||||
echo " -c <dir> Set pacman cache. Default: ${cache_dir}"
|
||||
echo " -h This message"
|
||||
exit $1
|
||||
}
|
||||
|
||||
while getopts 'r:ufhC:M:' arg; do
|
||||
while getopts 'r:ufnhC:M:c:' arg; do
|
||||
case "${arg}" in
|
||||
r) RUN="$OPTARG" ;;
|
||||
u) RUN="pacman -Syu" ;;
|
||||
@@ -39,6 +41,7 @@ while getopts 'r:ufhC:M:' arg; do
|
||||
C) pac_conf="$OPTARG" ;;
|
||||
M) makepkg_conf="$OPTARG" ;;
|
||||
n) NOCOPY="y" ;;
|
||||
c) cache_dir="$OPTARG" ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
esac
|
||||
@@ -68,45 +71,39 @@ shift 1
|
||||
|
||||
chroot_mount ()
|
||||
{
|
||||
echo "mounting sysfs : /sys"
|
||||
[ -e "${working_dir}/sys" ] || mkdir "${working_dir}/sys"
|
||||
mount -t sysfs sysfs "${working_dir}/sys"
|
||||
|
||||
echo "mounting procfs : /proc"
|
||||
[ -e "${working_dir}/proc" ] || mkdir "${working_dir}/proc"
|
||||
mount -t proc proc "${working_dir}/proc"
|
||||
|
||||
echo "binding device nodes : /dev"
|
||||
[ -e "${working_dir}/dev" ] || mkdir "${working_dir}/dev"
|
||||
mount -o bind /dev "${working_dir}/dev"
|
||||
|
||||
echo "binding pacman cache : /var/cache/pacman"
|
||||
[ -e "${working_dir}/var/cache/pacman" ] || mkdir -p "${working_dir}/var/cache/pacman"
|
||||
mount -o bind /var/cache/pacman "${working_dir}/var/cache/pacman"
|
||||
[ -e "${working_dir}/var/cache/pacman/pkg" ] || mkdir -p "${working_dir}/var/cache/pacman/pkg"
|
||||
[ -e "${cache_dir}" ] || mkdir -p "${cache_dir}"
|
||||
mount -o bind "${cache_dir}" "${working_dir}/var/cache/pacman/pkg"
|
||||
|
||||
trap 'chroot_umount' 0 1 2 15
|
||||
}
|
||||
|
||||
copy_hostconf ()
|
||||
{
|
||||
echo "copying mtab : /etc/mtab"
|
||||
cp /etc/mtab "${working_dir}/etc/mtab"
|
||||
|
||||
echo "copying resolv.conf : /etc/resolv.conf"
|
||||
cp /etc/resolv.conf "${working_dir}/etc/resolv.conf"
|
||||
|
||||
}
|
||||
|
||||
chroot_umount ()
|
||||
{
|
||||
echo "cleaning up mounts"
|
||||
umount "${working_dir}/proc"
|
||||
umount "${working_dir}/sys"
|
||||
umount "${working_dir}/dev"
|
||||
umount "${working_dir}/var/cache/pacman"
|
||||
umount "${working_dir}/var/cache/pacman/pkg"
|
||||
}
|
||||
# }}}
|
||||
|
||||
umask 000
|
||||
if [ "$RUN" != "" ]; then
|
||||
# run chroot {{{
|
||||
#Sanity check
|
||||
@@ -119,7 +116,6 @@ if [ "$RUN" != "" ]; then
|
||||
chroot_mount
|
||||
copy_hostconf
|
||||
|
||||
echo "starting chroot ($RUN)"
|
||||
chroot "${working_dir}" ${RUN}
|
||||
|
||||
# }}}
|
||||
@@ -143,12 +139,7 @@ else
|
||||
pacargs="$pacargs --config=${pac_conf}"
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "no packages to install"
|
||||
else
|
||||
echo "installing packages:"
|
||||
for i in $@; do echo -e "\t$i"; done
|
||||
|
||||
if [ $# -ne 0 ]; then
|
||||
op="-Sy"
|
||||
if [ "$FORCE" = "y" ]; then
|
||||
op="${op}f"
|
||||
@@ -160,22 +151,18 @@ else
|
||||
fi
|
||||
|
||||
if [ -d "${working_dir}/lib/modules" ]; then
|
||||
echo "running ldconfig"
|
||||
ldconfig -r "${working_dir}"
|
||||
fi
|
||||
|
||||
if [ "$pac_conf" != "" -a "$NOCOPY" = "n" ]; then
|
||||
echo "installing custom pacman.conf"
|
||||
cp ${pac_conf} ${working_dir}/etc/pacman.conf
|
||||
fi
|
||||
|
||||
if [ "$makepkg_conf" != "" -a "$NOCOPY" = "n" ]; then
|
||||
echo "installing custom makepkg.conf"
|
||||
cp ${makepkg_conf} ${working_dir}/etc/makepkg.conf
|
||||
fi
|
||||
|
||||
if [ -e "${working_dir}/etc/locale.gen" ]; then
|
||||
echo "generating default locales from host system"
|
||||
cp /etc/locale.gen "${working_dir}/etc/locale.gen"
|
||||
chroot "${working_dir}" locale-gen
|
||||
fi
|
||||
|
Reference in New Issue
Block a user