summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Reynolds <fauno@kiwwwi.com.ar>2011-06-09 21:20:15 -0300
committerNicolas Reynolds <fauno@kiwwwi.com.ar>2011-06-09 21:20:15 -0300
commitd96b9e839c3eca1f6015e967f90e044d5f7ab09e (patch)
treebb083b1f871748cbb32d366ed92bd3b002d5d356
parent4d4439b1b9b5ab83981407e06e3a85bf1144d6cd (diff)
Did some cleanup plus moving things around to make them nicer. No new features.
-rwxr-xr-xfullpkg95
1 files changed, 52 insertions, 43 deletions
diff --git a/fullpkg b/fullpkg
index b4475a8..2e25ba2 100755
--- a/fullpkg
+++ b/fullpkg
@@ -44,9 +44,6 @@ function usage {
# * Add/Remove from queue
# * Check if a package is listed
-# TODO
-# * Check for concurrence # @ fauno: What do you mean?
-
# Get the queue list from the server
get_queue() {
[[ "$OFFLINE" = "true" ]] && return 0
@@ -81,7 +78,7 @@ remove_queue() {
get_queue
grep -Evw "^$(basename $PWD)" $queue_file > $queue_file.2
- mv $queue_file.2 $queue_file
+ cat $queue_file.2 > $queue_file; rm -f $queue_file.2
put_queue && return 0 || return $?
}
@@ -104,6 +101,18 @@ check_queue() {
# END Queue Management #
+## Build order management ##
+
+# Removes a package from the buildorder
+# $1 package name
+# $2 buildorder file
+remove_buildorder() {
+ grep -Evw "$1" $2 > $2.2
+ cat $2.2 > $2; rm -f $2.2
+}
+
+# Guesses the repo name according to the parent dir of the current package
+# assuming the form repo/package/PKGBUILD
guess_repo() {
basename $(dirname $(pwd))
}
@@ -130,27 +139,30 @@ function find_deps {
## Check this level.
source PKGBUILD
local repo=${repo:-$(guess_repo)}
+ local pkgbase=${pkgbase:-${pkgname[0]}}
# If package is built exit
# TODO?: If this package is in force_build: skip this step
- if is_built "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}"; then
+ if is_built "${pkgbase}>=${pkgver}-${pkgrel}"; then
exit 0
fi
# Tell which packages are deeper in deps (even if they are on build_dir)
# so we can build them first.
- echo "${level}:$(basename $PWD)" >> "${build_dir}/BUILDORDER"
+ echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER"
# if pkgbuild directory is on build_dir, do not copy and exit
- if [ -d "${build_dir}/$(basename $PWD)" ]; then
+ if [ -d "${build_dir}/${pkgbase}" ]; then
exit 0
else
- cp -r ../$(basename $PWD) ${build_dir}/
+# Copy dir to build_dir
+ cp -r ../${pkgbase}/ ${build_dir}/
# Info to eval later
- echo "repo=$repo" > "${build_dir}/$(basename $PWD)/.INFO"
+ echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO"
fi
- msg2 "${pkgbase:-${pkgname[0]}}>=${pkgver}-${pkgrel}"
+# Inform the current package
+ msg2 "${pkgbase}-${pkgver}-${pkgrel}"
## Check next levels
# Clean version checking
@@ -165,8 +177,8 @@ function find_deps {
for _dep in ${deps[@]}; do
for _repo in ${REPOS[@]}; do
# try to find $_dep on each repo from dirname
- if [ -e "$ABSROOT/${_repo}/$_dep/PKGBUILD" ]; then
- pushd "$ABSROOT/${_repo}/$_dep" > /dev/null
+ if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then
+ pushd "${ABSROOT}/${_repo}/${_dep}" > /dev/null
$0 -c -d ${build_dir} -l ${next_level}
# Circular deps must fail
@@ -190,7 +202,6 @@ function find_deps {
else
echo "dep_not_found:$_dep:$_repo" >> $build_dir/log
-
fi
done
done
@@ -199,7 +210,7 @@ function find_deps {
# unset PKGBUILD variables
unset pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \
makedepens checkdepends optdepends provides conflicts replaces backup \
- options install changelog source noextract md5sums build check package
+ options install changelog source noextract md5sums build check package
}
function _pkg_build () {
@@ -213,18 +224,13 @@ function _pkg_build () {
source PKGBUILD
msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel"
-# Add mips64el
- if ! grep mips64el PKGBUILD >/dev/null; then
- plain "Adding mips64el arch"
- sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD"
- fi
# Check if pkg is being built
msg2 "Checking build queue"
check_queue || {
echo "someone_is_building:$(basename $PWD)" >> $build_dir/log
- grep -vwh "$(basename $PWD)" $buildorder > $buildorder.2
- mv $buildorder.2 $buildorder
+
+ remove_buildorder "$(basename $PWD)" $buildorder
continue
}
@@ -240,12 +246,11 @@ function _pkg_build () {
# fails with something else if blacklist can't be retrieved
if [ $? -eq 15 ]; then
# log they have nonfree deps and so didn't build
- echo "nonfree:$(basename $PWD)" >> $build_dir/log
+ echo "nonfree:$(basename $PWD)" >> $build_dir/log
# take out package from $buildorder
- grep -vwh "$(basename $PWD)" $buildorder > $buildorder.2
- mv $buildorder.2 $buildorder
+ remove_buildorder "$(basename $PWD)" $buildorder
# continue building next package
- continue
+ continue
fi
}
@@ -282,8 +287,7 @@ function _pkg_build () {
esac
# Package was built or failed: take it out of $buildorder
- grep -vwh "${build_packages[0]}" $buildorder > $buildorder.2
- mv $buildorder.2 $buildorder
+ remove_buildorder "${build_packages[0]}" $buildorder
# Take package out from queue
remove_queue
@@ -293,7 +297,7 @@ function _pkg_build () {
popd > /dev/null
done
- pkgs=$(cat $build_dir/log | grep "nonfree:") && {
+ pkgs=($(grep "nonfree:" $build_dir/log)) && {
error "Those packages contain nonfree deps:"
echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2
}
@@ -332,7 +336,7 @@ trap_exit() {
## Trap signals
# From makepkg
set -E
-trap 'clean_up' 0
+trap 'cleanup' 0
trap 'trap_exit "TERM signal caught. Exiting..."' TERM HUP QUIT
trap 'trap_exit "Aborted by user! Exiting..."' INT
trap 'trap_exit "An unknown error has occurred. Exiting..."' ERR
@@ -365,7 +369,7 @@ while getopts 'ha:bcCd:l:nm:r:o' arg; do
done
# Only on level 0
-[ $level -eq 0 ] && {
+if [ $level -eq 0 ]; then
# if build_dir exist use it, else make a build_dir
build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)}
@@ -391,23 +395,19 @@ done
# Build only
[ $build_only == 'y' ] && {
-# Exit loop on Ctrl+C
- trap "break" INT
-# Remove from queue package being built on error
- trap "remove_queue" EXIT INT QUIT TERM KILL
_pkg_build
exit 0
}
msg "Checking dependencies"
-}
+fi
[ ! -r PKGBUILD ] && {
error "This isn't a build directory"
usage && exit 1
}
-## if $level = 20 there is highly likely there are circular deps
+## if $level = 20 it's highly likely there are circular deps
[ $level -ge $max_level ] && exit 20
@@ -426,19 +426,21 @@ find_deps || {
# check BUILDORDER to not include banned deps and
[ $level -eq 0 -a -d $build_dir ] && {
- # Check for banned deps
+# Check for banned deps
if [ -w $ban_file -a -r $ban_file ]; then
chmod o+rw $ban_file || error "Ban file is not readable/writable ($ban_file)"
else
rsync -e ssh -aq $PARABOLAHOST:mips64el/ban >/dev/null 2>&1 || {
warning "Failed to get ban list" && [ -r $ban_file ] && {
- # continue if download failed but local copy
- search=$(cat $ban_file | tr "\n" "|")
- echo ${@} | tr " " "\n" | egrep -w "$search" $buildorder >> $build_dir/banned
- echo ${@} | tr " " "\n" | egrep -vw "$search" $buildorder > $buildorder.2
- mv $buildorder.2 $buildorder
- unset search
+
+# Continue if download failed but local copy
+# @xihh i don't understand this -- fauno
+ search=$(cat $ban_file | tr "\n" "|")
+ echo ${@} | tr " " "\n" | egrep -w "$search" $buildorder >> $build_dir/banned
+ echo ${@} | tr " " "\n" | egrep -vw "$search" $buildorder > $buildorder.2
+ cat $buildorder.2 > $buildorder
+ unset search
}
}
fi
@@ -453,6 +455,13 @@ msg "Building packages:"
OFFLINE=true
}
+# Add mips64el if missing from arch=() and it isn't an 'any' package
+if ! grep mips64el PKGBUILD >/dev/null; then
+ plain "Adding mips64el arch"
+ sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD"
+fi
+
+# Build the package
_pkg_build
echo