devtools/rebuildpkgs.in

98 lines
2.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# This script rebuilds a list of packages in order
# and reports anything that fails
#
# Due to sudo usage, it is recommended to allow makechrootpkg
# to be run with NOPASSWD in your sudoers file
#
# FIXME
# Currently uses $(pwd)/rebuilds as the directory for rebuilding...
# TODO make this work for community too
m4_include(lib/common.sh)
if (( $# < 1 )); then
echo "Usage: $(basename $0) <chrootdir> <packages to rebuild>"
2010-02-13 19:47:16 +01:00
echo " example: $(basename $0) ~/chroot readline bash foo bar baz"
exit 1
fi
# Source makepkg.conf; fail if it is not found
if [[ -r '/etc/makepkg.conf' ]]; then
2010-02-13 19:47:16 +01:00
source '/etc/makepkg.conf'
else
die '/etc/makepkg.conf not found!'
fi
2010-02-13 19:47:16 +01:00
bump_pkgrel() {
# Get the current pkgrel from SVN and update the working copy with it
# This prevents us from incrementing out of control :)
pbuild='.svn/text-base/PKGBUILD.svn-base'
oldrel=$(grep 'pkgrel=' $pbuild | cut -d= -f2)
2010-02-13 19:47:16 +01:00
#remove decimals
rel=$(echo $oldrel | cut -d. -f1)
2010-02-13 19:47:16 +01:00
newrel=$(($rel + 1))
sed -i "s/pkgrel=$oldrel/pkgrel=$newrel/" PKGBUILD
}
2010-02-13 19:47:16 +01:00
pkg_from_pkgbuild() {
# we want the sourcing to be done in a subshell so we don't pollute our current namespace
export CARCH PKGEXT
(source PKGBUILD; echo "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT")
}
chrootdir="$1"; shift
pkgs="$@"
SVNPATH='svn+ssh://repos.archlinux.org/srv/repos/svn-packages/svn'
msg "Work will be done in $(pwd)/rebuilds"
REBUILD_ROOT="$(pwd)/rebuilds"
mkdir -p "$REBUILD_ROOT"
cd "$REBUILD_ROOT"
/usr/bin/svn co -N $SVNPATH
FAILED=""
for pkg in $pkgs; do
2010-02-13 19:47:16 +01:00
cd "$REBUILD_ROOT/svn-packages"
msg2 "Building '$pkg'"
2010-02-13 19:47:16 +01:00
/usr/bin/svn update "$pkg"
if [[ ! -d "$pkg/trunk" ]]; then
2010-02-13 19:47:16 +01:00
FAILED="$FAILED $pkg"
warning "$pkg does not exist in SVN"
2010-02-13 19:47:16 +01:00
continue
fi
cd "$pkg/trunk/"
bump_pkgrel
if ! sudo makechrootpkg -u -d -r "$chrootdir" -- --noconfirm; then
FAILED="$FAILED $pkg"
error "$pkg Failed!"
2010-02-13 19:47:16 +01:00
else
pkgfile=$(pkg_from_pkgbuild)
if [[ -e $pkgfile ]]; then
msg2 "$pkg Complete"
2010-02-13 19:47:16 +01:00
else
FAILED="$FAILED $pkg"
error "$pkg Failed, no package built!"
2010-02-13 19:47:16 +01:00
fi
fi
done
cd "$REBUILD_ROOT"
if [[ -n $FAILED ]]; then
msg 'Packages failed:'
2010-02-13 19:47:16 +01:00
for pkg in $FAILED; do
msg2 "$pkg"
2010-02-13 19:47:16 +01:00
done
fi
msg 'SVN pkgbumps in svn-packages/ - commit when ready'