mirror of
https://gitlab.archlinux.org/archlinux/devtools.git
synced 2025-09-14 18:36:18 +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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d ../repos/$1 ]; then
|
echo -n 'releasing package...'
|
||||||
pushd ..
|
pushd .. >/dev/null
|
||||||
[ -d repos ] || mkdir repos
|
if [ -d repos/$1 ]; then
|
||||||
svn copy -r HEAD trunk repos/$1
|
svn rm --force -q repos/$1
|
||||||
svn commit -m "archrelease: new repo $1"
|
svn commit -q -m "archrelease: remove $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
|
|
||||||
fi
|
fi
|
||||||
|
svn copy -q -r HEAD trunk repos/$1
|
||||||
echo "===> Tagged for $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
|
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
|
# Source makepkg.conf; fail if it is not found
|
||||||
if [ -r "/etc/makepkg.conf" ]; then
|
if [ -r "/etc/makepkg.conf" ]; then
|
||||||
@@ -60,61 +49,55 @@ else
|
|||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# see if any limit options were passed, we'll send them to SCP
|
# check if all local source files are under version control
|
||||||
unset scpopts
|
(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
|
if [ "$1" = "-l" ]; then
|
||||||
scpopts="-l $2"
|
rsyncopts="--bwlimit=$2"
|
||||||
shift 2
|
shift 2
|
||||||
fi
|
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
|
for _arch in ${arch[@]}; do
|
||||||
echo "===> Uploading to staging/$repo for arch=${_arch}"
|
|
||||||
for _pkgname in ${pkgname[@]}; do
|
for _pkgname in ${pkgname[@]}; do
|
||||||
pkgfile=$_pkgname-$pkgver-$pkgrel-${_arch}$PKGEXT
|
pkgfile=$_pkgname-$pkgver-$pkgrel-${_arch}$PKGEXT
|
||||||
|
|
||||||
if [ ! -f $pkgfile -a -f "$PKGDEST/$pkgfile" ]; then
|
if [ ! -f $pkgfile -a -f "$PKGDEST/$pkgfile" ]; then
|
||||||
pkgfile="$PKGDEST/$pkgfile"
|
pkgfile="$PKGDEST/$pkgfile"
|
||||||
elif [ ! -f $pkgfile ]; then
|
elif [ ! -f $pkgfile ]; then
|
||||||
echo "File $pkgfile doesn't exist"
|
echo "skipping ${_arch}"
|
||||||
# skip to next architecture
|
|
||||||
continue 2
|
continue 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# combine what we know into a variable
|
echo -n 'uploading '
|
||||||
uploadto=staging/$repo/$(basename "$pkgfile")
|
rsync -c -h --progress $rsyncopts "${pkgfile}" -e ssh $server:staging/$repo || abort
|
||||||
# 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"
|
|
||||||
done
|
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
|
archrelease $repo-${_arch} || abort
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "${arch[*]}" == "any" ]; then
|
if [ "${arch[*]}" == "any" ]; then
|
||||||
if [ -d ../repos/$repo-i686 -a -d ../repos/$repo-x86_64 ]; 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-i686
|
||||||
svn rm $repo-x86_64
|
svn rm $repo-x86_64
|
||||||
svn commit -m "removed $repo-i686 and $repo-x86_64 for $pkgname"
|
svn commit -q -m "removed $repo-i686 and $repo-x86_64 for $pkgname"
|
||||||
popd
|
echo 'done'
|
||||||
|
popd >/dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
147
makechrootpkg
147
makechrootpkg
@@ -12,7 +12,7 @@ FORCE="n"
|
|||||||
RUN=""
|
RUN=""
|
||||||
MAKEPKG_ARGS="-sr"
|
MAKEPKG_ARGS="-sr"
|
||||||
REPACK=""
|
REPACK=""
|
||||||
LAYER="rw"
|
COPY="copy"
|
||||||
WORKDIR=$PWD
|
WORKDIR=$PWD
|
||||||
|
|
||||||
update_first="0"
|
update_first="0"
|
||||||
@@ -32,8 +32,8 @@ usage ()
|
|||||||
echo " will be passed to makepkg."
|
echo " will be passed to makepkg."
|
||||||
echo ""
|
echo ""
|
||||||
echo " The chroot dir consists of the following directories:"
|
echo " The chroot dir consists of the following directories:"
|
||||||
echo " <chrootdir>/{root, rw, union} but only 'root' is required"
|
echo " <chrootdir>/{root, copy} but only 'root' is required"
|
||||||
echo " by default. The rest will be created as needed"
|
echo " by default. The working copy will be created as needed"
|
||||||
echo ""
|
echo ""
|
||||||
echo "The chroot 'root' directory must be created via the following"
|
echo "The chroot 'root' directory must be created via the following"
|
||||||
echo "command:"
|
echo "command:"
|
||||||
@@ -44,14 +44,14 @@ usage ()
|
|||||||
echo "Flags:"
|
echo "Flags:"
|
||||||
echo "-h This help"
|
echo "-h This help"
|
||||||
echo "-c Clean the chroot before building"
|
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 " This is useful for rebuilds without dirtying the pristine"
|
||||||
echo " chroot"
|
echo " chroot"
|
||||||
echo "-d Add the package to a local db at /repo after building"
|
echo "-d Add the package to a local db at /repo after building"
|
||||||
echo "-r <dir> The chroot shell to use"
|
echo "-r <dir> The chroot dir to use"
|
||||||
echo "-I <pkg> Install a package into the rw layer of the chroot"
|
echo "-I <pkg> Install a package into the working copy of the chroot"
|
||||||
echo "-l <layer> The directory to use as the rw layer of the union"
|
echo "-l <copy> The directory to use as the working copy of the chroot"
|
||||||
echo " Useful for maintain multiple layers. Default: rw"
|
echo " Useful for maintain multiple copies Default: copy"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,13 +63,14 @@ while getopts 'hcudr:I:l:' arg; do
|
|||||||
d) add_to_db=1 ;;
|
d) add_to_db=1 ;;
|
||||||
r) chrootdir="$OPTARG" ;;
|
r) chrootdir="$OPTARG" ;;
|
||||||
I) install_pkg="$OPTARG" ;;
|
I) install_pkg="$OPTARG" ;;
|
||||||
l) LAYER="$OPTARG" ;;
|
l) COPY="$OPTARG" ;;
|
||||||
*) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;;
|
*) MAKEPKG_ARGS="$MAKEPKG_ARGS -$arg $OPTARG" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
#Get rid of trailing / in chrootdir
|
#Get rid of trailing / in chrootdir
|
||||||
[ "$chrootdir" != "/" ] && chrootdir=$(echo $chrootdir | sed 's#/$##')
|
[ "$chrootdir" != "/" ] && chrootdir=$(echo $chrootdir | sed 's#/$##')
|
||||||
|
copydir="$chrootdir/$COPY"
|
||||||
|
|
||||||
# Pass all arguments after -- right to makepkg
|
# Pass all arguments after -- right to makepkg
|
||||||
MAKEPKG_ARGS="$MAKEPKG_ARGS ${*:$OPTIND}"
|
MAKEPKG_ARGS="$MAKEPKG_ARGS ${*:$OPTIND}"
|
||||||
@@ -104,77 +105,58 @@ if [ ! -d "$chrootdir/root" ]; then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -d "$chrootdir/$LAYER" -a "$clean_first" -eq "1" ] && rm -rf "$chrootdir/$LAYER/"
|
umask 000
|
||||||
[ -d "$chrootdir/$LAYER" ] || mkdir "$chrootdir/$LAYER"
|
if [ ! -d "$copydir" -o "$clean_first" -eq "1" ]; then
|
||||||
[ -d "$chrootdir/union" ] || mkdir "$chrootdir/union"
|
echo -n 'creating clean working copy...'
|
||||||
|
mkdir -p "$copydir"
|
||||||
cleanup ()
|
rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
|
||||||
{
|
echo 'done'
|
||||||
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
|
|
||||||
fi
|
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
|
if [ -n "$install_pkg" ]; then
|
||||||
pkgname="$(basename "$install_pkg")"
|
pkgname="$(basename "$install_pkg")"
|
||||||
echo "installing '$pkgname' in chroot"
|
cp "$install_pkg" "$copydir/$pkgname"
|
||||||
cp "$install_pkg" "$uniondir/$pkgname"
|
mkarchroot -r "pacman -U /$pkgname" "$copydir"
|
||||||
mkarchroot -r "pacman -U /$pkgname" "$uniondir"
|
|
||||||
ret=$?
|
ret=$?
|
||||||
rm "$uniondir/$pkgname"
|
rm "$copydir/$pkgname"
|
||||||
#exit early, we've done all we need to
|
#exit early, we've done all we need to
|
||||||
exit $ret
|
exit $ret
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $update_first -eq 1 ]; then
|
if [ $update_first -eq 1 ]; then
|
||||||
echo "updating chroot"
|
mkarchroot -r "pacman -Syu --noconfirm" "$copydir"
|
||||||
mkarchroot -r "pacman -Syu --noconfirm" "$uniondir"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "moving build files to chroot"
|
[ -d "$copydir/build" ] || mkdir "$copydir/build"
|
||||||
[ -d "$uniondir/build" ] || mkdir "$uniondir/build"
|
|
||||||
|
|
||||||
if [ "$REPACK" != "1" ]; then
|
if [ "$REPACK" != "1" ]; then
|
||||||
#Remove anything in there UNLESS -R (repack) was passed to makepkg
|
#Remove anything in there UNLESS -R (repack) was passed to makepkg
|
||||||
rm -rf "$uniondir/build/"*
|
rm -rf "$copydir/build/"*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -d "$uniondir/pkgdest" ] || mkdir "$uniondir/pkgdest"
|
# Get SRC/PKGDEST from makepkg.conf
|
||||||
if ! grep "PKGDEST=/pkgdest" "$uniondir/etc/makepkg.conf" >/dev/null 2>&1; then
|
SRCDEST=$(grep '^SRCDEST=' /etc/makepkg.conf | cut -d= -f2)
|
||||||
echo "Setting PKGDEST in makepkg.conf"
|
PKGDEST=$(grep '^PKGDEST=' /etc/makepkg.conf | cut -d= -f2)
|
||||||
echo "PKGDEST=/pkgdest" >> "$uniondir/etc/makepkg.conf"
|
|
||||||
|
[ -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
|
fi
|
||||||
|
|
||||||
[ -d "$uniondir/srcdest" ] || mkdir "$uniondir/srcdest"
|
[ -d "$copydir/srcdest" ] || mkdir "$copydir/srcdest"
|
||||||
if ! grep "SRCDEST=/srcdest" "$uniondir/etc/makepkg.conf" >/dev/null 2>&1; then
|
if ! grep "SRCDEST=/srcdest" "$copydir/etc/makepkg.conf" >/dev/null 2>&1; then
|
||||||
echo "Setting SRCDEST in makepkg.conf"
|
echo "SRCDEST=/srcdest" >> "$copydir/etc/makepkg.conf"
|
||||||
echo "SRCDEST=/srcdest" >> "$uniondir/etc/makepkg.conf"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R nobody "$uniondir/build"
|
|
||||||
chown -R nobody "$uniondir/srcdest"
|
|
||||||
chown -R nobody "$uniondir/pkgdest"
|
|
||||||
|
|
||||||
# Copy PKGBUILD and sources
|
# Copy PKGBUILD and sources
|
||||||
source PKGBUILD
|
source PKGBUILD
|
||||||
cp PKGBUILD "$uniondir/build/"
|
cp PKGBUILD "$copydir/build/"
|
||||||
for f in ${source[@]}; do
|
for f in ${source[@]}; do
|
||||||
basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g')
|
basef=$(echo $f | sed 's|::.*||' | sed 's|^.*://.*/||g')
|
||||||
if [ -f "$basef" ]; then
|
if [ -f "$basef" ]; then
|
||||||
cp "$basef" "$uniondir/srcdest/"
|
cp "$basef" "$copydir/srcdest/"
|
||||||
elif [ -f "$SRCDEST/$basef" ]; then
|
elif [ -f "$SRCDEST/$basef" ]; then
|
||||||
cp "$SRCDEST/$basef" "$uniondir/srcdest/"
|
cp "$SRCDEST/$basef" "$copydir/srcdest/"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -188,23 +170,26 @@ done
|
|||||||
for f in $install_files;do
|
for f in $install_files;do
|
||||||
install="${f#"install="}"
|
install="${f#"install="}"
|
||||||
if [ "$install" != "" -a -f "$install" ]; then
|
if [ "$install" != "" -a -f "$install" ]; then
|
||||||
cp "$install" "$uniondir/build/"
|
cp "$install" "$copydir/build/"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -f "ChangeLog" ]; then
|
if [ -f "ChangeLog" ]; then
|
||||||
cp ChangeLog "$uniondir/build/"
|
cp ChangeLog "$copydir/build/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep "^nobody" "$uniondir/etc/sudoers" >/dev/null 2>&1; then
|
chown -R nobody "$copydir/build"
|
||||||
echo "allowing 'nobody' sudo rights in the chroot"
|
chown -R nobody "$copydir/srcdest"
|
||||||
touch "$uniondir/etc/sudoers"
|
chown -R nobody "$copydir/pkgdest"
|
||||||
echo "nobody ALL=(ALL) NOPASSWD: ALL" >> "$uniondir/etc/sudoers"
|
|
||||||
chmod 440 "$uniondir/etc/sudoers"
|
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
|
fi
|
||||||
|
|
||||||
#This is a little gross, but this way the script is recreated every time in the
|
#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
|
(cat <<EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
export LANG=$LOCALE
|
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
|
which namcap &>/dev/null && namcap /build/PKGBUILD /pkgdest/*${PKGEXT} > /pkgdest/namcap.log
|
||||||
exit 0
|
exit 0
|
||||||
EOF
|
EOF
|
||||||
) > "$uniondir/chrootbuild"
|
) > "$copydir/chrootbuild"
|
||||||
chmod +x "$uniondir/chrootbuild"
|
chmod +x "$copydir/chrootbuild"
|
||||||
|
|
||||||
if mkarchroot -r "/chrootbuild" "$uniondir"; then
|
if mkarchroot -r "/chrootbuild" "$copydir"; then
|
||||||
|
for pkgfile in "${copydir}"/pkgdest/*${PKGEXT}; do
|
||||||
# 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
|
|
||||||
[ -e "$pkgfile" ] || continue
|
[ -e "$pkgfile" ] || continue
|
||||||
_pkgname=$(basename "$pkgfile")
|
_pkgname=$(basename "$pkgfile")
|
||||||
if [ "$add_to_db" -eq "1" ]; then
|
if [ "$add_to_db" -eq "1" ]; then
|
||||||
[ -d "${chrootdir}/union/repo" ] || mkdir -p "${chrootdir}/union/repo"
|
[ -d "${copydir}/repo" ] || mkdir -p "${copydir}/repo"
|
||||||
pushd "${chrootdir}/union/repo" >/dev/null
|
pushd "${copydir}/repo" >/dev/null
|
||||||
cp "$pkgfile" .
|
cp "$pkgfile" .
|
||||||
repo-add repo.db.tar.${DB_COMPRESSION} "$_pkgname"
|
repo-add repo.db.tar.gz "$_pkgname"
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$PKGDEST" ]; then
|
if [ -d "$PKGDEST" ]; then
|
||||||
echo "Moving completed ${_pkgname%${PKGEXT}} package file to ${PKGDEST}"
|
|
||||||
mv "$pkgfile" "${PKGDEST}"
|
mv "$pkgfile" "${PKGDEST}"
|
||||||
else
|
else
|
||||||
echo "Moving completed ${_pkgname%${PKGEXT}} package file to ${WORKDIR}"
|
|
||||||
mv "$pkgfile" "${WORKDIR}"
|
mv "$pkgfile" "${WORKDIR}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for f in "${chrootdir}"/union/srcdest/*; do
|
for f in "${copydir}"/srcdest/*; do
|
||||||
[ -e "$f" ] || continue
|
[ -e "$f" ] || continue
|
||||||
if [ -d "$SRCDEST" ]; then
|
if [ -d "$SRCDEST" ]; then
|
||||||
echo "Moving downloaded source file $(basename $f) to ${SRCDEST}"
|
|
||||||
mv "$f" "${SRCDEST}"
|
mv "$f" "${SRCDEST}"
|
||||||
else
|
else
|
||||||
echo "Moving downloaded source file $(basename $f) to ${WORKDIR}"
|
|
||||||
mv "$f" "${WORKDIR}"
|
mv "$f" "${WORKDIR}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for l in "${copydir}"/build/*-{build,package}.log; do
|
||||||
|
[ -f "$l" ] && mv "$l" "${WORKDIR}"
|
||||||
|
done
|
||||||
else
|
else
|
||||||
#just in case. We returned 1, make sure we fail
|
#just in case. We returned 1, make sure we fail
|
||||||
touch "${chrootdir}/union/build/BUILD_FAILED"
|
touch "${copydir}/build/BUILD_FAILED"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "${chrootdir}/union/build/BUILD_FAILED" ]; then
|
if [ -e "${copydir}/build/BUILD_FAILED" ]; then
|
||||||
echo "Build failed, check $chrootdir/$LAYER/build"
|
echo "Build failed, check $copydir/build"
|
||||||
rm "${chrootdir}/union/build/BUILD_FAILED"
|
rm "${copydir}/build/BUILD_FAILED"
|
||||||
else
|
else
|
||||||
rm -rf "${chrootdir}"/union/build/*
|
rm -rf "${copydir}"/build/*
|
||||||
echo "Build complete"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
39
mkarchroot
39
mkarchroot
@@ -13,6 +13,7 @@ RUN=""
|
|||||||
NOCOPY="n"
|
NOCOPY="n"
|
||||||
|
|
||||||
working_dir=""
|
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}")
|
APPNAME=$(basename "${0}")
|
||||||
|
|
||||||
@@ -24,14 +25,15 @@ usage ()
|
|||||||
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"
|
||||||
echo " -f Force overwrite of files in the working-dir"
|
echo " -f Force overwrite of files in the working-dir"
|
||||||
echo " -C <file> location of a pacman config file"
|
echo " -C <file> Location of a pacman config file"
|
||||||
echo " -M <file> location of a makepkg config file"
|
echo " -M <file> Location of a makepkg config file"
|
||||||
echo " -n do not copy config files into the chroot"
|
echo " -n Do not copy config files into the chroot"
|
||||||
|
echo " -c <dir> Set pacman cache. Default: ${cache_dir}"
|
||||||
echo " -h This message"
|
echo " -h This message"
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'r:ufhC:M:' arg; do
|
while getopts 'r:ufnhC:M:c:' arg; do
|
||||||
case "${arg}" in
|
case "${arg}" in
|
||||||
r) RUN="$OPTARG" ;;
|
r) RUN="$OPTARG" ;;
|
||||||
u) RUN="pacman -Syu" ;;
|
u) RUN="pacman -Syu" ;;
|
||||||
@@ -39,6 +41,7 @@ while getopts 'r:ufhC:M:' arg; do
|
|||||||
C) pac_conf="$OPTARG" ;;
|
C) pac_conf="$OPTARG" ;;
|
||||||
M) makepkg_conf="$OPTARG" ;;
|
M) makepkg_conf="$OPTARG" ;;
|
||||||
n) NOCOPY="y" ;;
|
n) NOCOPY="y" ;;
|
||||||
|
c) cache_dir="$OPTARG" ;;
|
||||||
h|?) usage 0 ;;
|
h|?) usage 0 ;;
|
||||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||||
esac
|
esac
|
||||||
@@ -68,45 +71,39 @@ shift 1
|
|||||||
|
|
||||||
chroot_mount ()
|
chroot_mount ()
|
||||||
{
|
{
|
||||||
echo "mounting sysfs : /sys"
|
|
||||||
[ -e "${working_dir}/sys" ] || mkdir "${working_dir}/sys"
|
[ -e "${working_dir}/sys" ] || mkdir "${working_dir}/sys"
|
||||||
mount -t sysfs sysfs "${working_dir}/sys"
|
mount -t sysfs sysfs "${working_dir}/sys"
|
||||||
|
|
||||||
echo "mounting procfs : /proc"
|
|
||||||
[ -e "${working_dir}/proc" ] || mkdir "${working_dir}/proc"
|
[ -e "${working_dir}/proc" ] || mkdir "${working_dir}/proc"
|
||||||
mount -t proc proc "${working_dir}/proc"
|
mount -t proc proc "${working_dir}/proc"
|
||||||
|
|
||||||
echo "binding device nodes : /dev"
|
|
||||||
[ -e "${working_dir}/dev" ] || mkdir "${working_dir}/dev"
|
[ -e "${working_dir}/dev" ] || mkdir "${working_dir}/dev"
|
||||||
mount -o bind /dev "${working_dir}/dev"
|
mount -o bind /dev "${working_dir}/dev"
|
||||||
|
|
||||||
echo "binding pacman cache : /var/cache/pacman"
|
[ -e "${working_dir}/var/cache/pacman/pkg" ] || mkdir -p "${working_dir}/var/cache/pacman/pkg"
|
||||||
[ -e "${working_dir}/var/cache/pacman" ] || mkdir -p "${working_dir}/var/cache/pacman"
|
[ -e "${cache_dir}" ] || mkdir -p "${cache_dir}"
|
||||||
mount -o bind /var/cache/pacman "${working_dir}/var/cache/pacman"
|
mount -o bind "${cache_dir}" "${working_dir}/var/cache/pacman/pkg"
|
||||||
|
|
||||||
trap 'chroot_umount' 0 1 2 15
|
trap 'chroot_umount' 0 1 2 15
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_hostconf ()
|
copy_hostconf ()
|
||||||
{
|
{
|
||||||
echo "copying mtab : /etc/mtab"
|
|
||||||
cp /etc/mtab "${working_dir}/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"
|
cp /etc/resolv.conf "${working_dir}/etc/resolv.conf"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chroot_umount ()
|
chroot_umount ()
|
||||||
{
|
{
|
||||||
echo "cleaning up mounts"
|
|
||||||
umount "${working_dir}/proc"
|
umount "${working_dir}/proc"
|
||||||
umount "${working_dir}/sys"
|
umount "${working_dir}/sys"
|
||||||
umount "${working_dir}/dev"
|
umount "${working_dir}/dev"
|
||||||
umount "${working_dir}/var/cache/pacman"
|
umount "${working_dir}/var/cache/pacman/pkg"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
umask 000
|
||||||
if [ "$RUN" != "" ]; then
|
if [ "$RUN" != "" ]; then
|
||||||
# run chroot {{{
|
# run chroot {{{
|
||||||
#Sanity check
|
#Sanity check
|
||||||
@@ -119,7 +116,6 @@ if [ "$RUN" != "" ]; then
|
|||||||
chroot_mount
|
chroot_mount
|
||||||
copy_hostconf
|
copy_hostconf
|
||||||
|
|
||||||
echo "starting chroot ($RUN)"
|
|
||||||
chroot "${working_dir}" ${RUN}
|
chroot "${working_dir}" ${RUN}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
@@ -143,12 +139,7 @@ else
|
|||||||
pacargs="$pacargs --config=${pac_conf}"
|
pacargs="$pacargs --config=${pac_conf}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -ne 0 ]; then
|
||||||
echo "no packages to install"
|
|
||||||
else
|
|
||||||
echo "installing packages:"
|
|
||||||
for i in $@; do echo -e "\t$i"; done
|
|
||||||
|
|
||||||
op="-Sy"
|
op="-Sy"
|
||||||
if [ "$FORCE" = "y" ]; then
|
if [ "$FORCE" = "y" ]; then
|
||||||
op="${op}f"
|
op="${op}f"
|
||||||
@@ -160,22 +151,18 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "${working_dir}/lib/modules" ]; then
|
if [ -d "${working_dir}/lib/modules" ]; then
|
||||||
echo "running ldconfig"
|
|
||||||
ldconfig -r "${working_dir}"
|
ldconfig -r "${working_dir}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$pac_conf" != "" -a "$NOCOPY" = "n" ]; then
|
if [ "$pac_conf" != "" -a "$NOCOPY" = "n" ]; then
|
||||||
echo "installing custom pacman.conf"
|
|
||||||
cp ${pac_conf} ${working_dir}/etc/pacman.conf
|
cp ${pac_conf} ${working_dir}/etc/pacman.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$makepkg_conf" != "" -a "$NOCOPY" = "n" ]; then
|
if [ "$makepkg_conf" != "" -a "$NOCOPY" = "n" ]; then
|
||||||
echo "installing custom makepkg.conf"
|
|
||||||
cp ${makepkg_conf} ${working_dir}/etc/makepkg.conf
|
cp ${makepkg_conf} ${working_dir}/etc/makepkg.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "${working_dir}/etc/locale.gen" ]; then
|
if [ -e "${working_dir}/etc/locale.gen" ]; then
|
||||||
echo "generating default locales from host system"
|
|
||||||
cp /etc/locale.gen "${working_dir}/etc/locale.gen"
|
cp /etc/locale.gen "${working_dir}/etc/locale.gen"
|
||||||
chroot "${working_dir}" locale-gen
|
chroot "${working_dir}" locale-gen
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user