summaryrefslogtreecommitdiff
path: root/fullpkg
diff options
context:
space:
mode:
authorNicolas Reynolds <fauno@kiwwwi.com.ar>2011-07-15 01:28:18 -0300
committerNicolas Reynolds <fauno@kiwwwi.com.ar>2011-07-15 01:28:18 -0300
commitff5ed6438c949dfee674902d3510a92443248d0a (patch)
tree9a3665f790f33552656a02952a7b5499730906c4 /fullpkg
parent28b4957fc3de418938d518067a51c353959226cc (diff)
FullPkg moved oddly placed code comments and prtools leftovers
Diffstat (limited to 'fullpkg')
-rwxr-xr-xfullpkg201
1 files changed, 109 insertions, 92 deletions
diff --git a/fullpkg b/fullpkg
index be26956..bd9ecfe 100755
--- a/fullpkg
+++ b/fullpkg
@@ -1,9 +1,12 @@
#!/bin/bash
+# Builds packages from ABS recursively. It tries to find dependencies that
+# aren't built or need update and then makepkg them in order.
+
+# TODO move __build to chroot
source /etc/makepkg.conf
source /etc/abs.conf
source /etc/libretools.conf
-source /etc/libretools.d/prtools.conf
if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors
@@ -38,27 +41,26 @@ function usage {
}
-function remove_buildorder { # Removes a package from the buildorder
+# Removes a package from the buildorder
# $1 package name
# $2 buildorder file
-
+remove_buildorder() {
grep -Evw "${1}" ${2} > ${2}2
mv -f ${2}2 ${2}
+ return $?
}
-function guess_repo { # Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD
-
- basename $(dirname $(pwd)) # Variable in prfullpkg
-
+# Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD
+guess_repo() {
+ basename $(dirname $(pwd))
}
-function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel
-
+# return : full version spec, including epoch (if necessary), pkgver, pkgrel
# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel )
-
+get_fullver() {
if [[ $1 -eq 0 ]]; then
- # zero epoch case, don't include it in version
+# zero epoch case, don't include it in version
echo $2-$3
else
echo $1:$2-$3
@@ -66,18 +68,21 @@ function get_fullver { # return : full version spec, including epoch (if necessa
}
-function cleanup { # Cleans the build_dir.
-
- [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0 # Do nothing or already cleaned.
+# Cleans the build_dir.
+cleanup() {
+# Do nothing or already cleaned.
+ [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0
+# Only do cleanup on level 0.
msg "Cleaning up..."
- [ $level -eq 0 ] && rm -rf $build_dir/* # Only do cleanup on level 0.
+ [ $level -eq 0 ] && rm -rf $build_dir/*
}
-function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated.
-
- source PKGBUILD ## Check this level.
+# Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated.
+find_deps() {
+# Check this level
+ source PKGBUILD
local repo=${repo:-$(guess_repo)}
local pkgbase=${pkgbase:-${pkgname[0]}}
@@ -85,79 +90,65 @@ function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them i
local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel})
if is_built "${pkgbase}>=${fullver}"; then
- exit 0 # pkg is built and updated
+# pkg is built and updated
+ exit 0
fi
- echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first
-
- if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there
+# greater levels are built first
+ echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER"
+# PKGBUILD is already there
+ if [ -d "${build_dir}/${pkgbase}" ]; then
exit 0
- else # Copy dir to build_dir
-## variable block for prfullpkg
+# Copy dir to build_dir
+ else
cp -r ../${pkgbase}/ ${build_dir}/
- echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later
+# to identify repo later
+ echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO"
fi
-
- msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level
- declare -i next_level=$level+1 ## Check next levels
+# current package plus a space for every level
+ msg2 "%${level}s${pkgbase}-${fullver}"
+## Check next levels
+ declare -i next_level=$level+1
+
+# All deps in separate line, only once, without version.
deps=$(echo "${depends[@]} ${makedepends[@]}" | \
sed "s/[=<>]\+[^ ]\+//g" | \
tr ' ' "\n" | \
- sort -u) # All deps in separate line, only once, without version.
+ sort -u)
for _dep in ${deps[@]}; do
local found=false
-
+
+# TODO ask toru where the pkgbuild is
for _repo in ${REPOS[@]}; do
- if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then # ABSROOT/repo/package
-
+# ABSROOT/repo/package
+ if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then
+
pushd "${ABSROOT}/${_repo}/${_dep}" > /dev/null
- $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir
- [ $? -eq 20 ] && return 20 # probable circular deps
+# run this cmd on dep's PKGBUILD dir
+ $0 -c -d ${build_dir} -l ${next_level}
+# probable circular deps
+ [ $? -eq 20 ] && return 20
popd > /dev/null
local found=true
- break 1 # found, end cycle
+# found, end cycle
+ break 1
fi
done
-
- if ( ${found} ); then
-
- continue 1 # go to next dep
-
- else # pkgsplit, needs guess
-
- for _repo in ${REPOS[@]}; do
- if _dir=($(find "$ABSROOT/${_repo}" -type f \
- -name PKGBUILD -print0 2>/dev/null | \
- "xargs" -0 -e grep -HEw "pkgname=|pkgbase=|provides=" | \
- grep -w "$_dep" 2>&1));
-
- then
-
- _dir=$(dirname $(echo $_dir | cut -d: -f1))
- plain "guess for $_dep -> $_dir"
-
- pushd "$_dir" > /dev/null
- $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir
- [ $? -eq 20 ] && return 20 # probable circular deps
- popd > /dev/null
- local found=true
- break 1 # found, end cycle
- fi
- done
if ( ${found} ); then
- continue 1 # go to next dep
+# go to next dep
+ continue 1
else
echo "dep_not_found:$_dep" >> $build_dir/log
fi
@@ -167,16 +158,17 @@ function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them i
## End variable block
unset next_level dir
- # unset PKGBUILD variables
+# 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
}
-function __build () {
+__build() {
pushd ${build_dir} > /dev/null
- build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first
+# greater levels must be built first
+ build_packages=($(sort -gr $buildorder | cut -d: -f2))
while [ ${#build_packages[@]} -ge 1 ]; do
pushd $build_dir/${build_packages[0]} > /dev/null
@@ -186,28 +178,33 @@ function __build () {
msg2 "Checking for non free deps"
pkgbuild-check-nonfree || {
- if [ $? -eq 15 ]; then # this error means nonfree others means fail.
+# this error means nonfree others means fail.
+ if [ $? -eq 15 ]; then
echo "nonfree:$(basename $PWD)" >> $build_dir/log
- remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder
+# take out package from $buildorder
+ remove_buildorder "$(basename $PWD)" $buildorder
- continue # build next package
+# build next package
+ continue
fi
}
msg2 "Building $(basename $PWD)"
- $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf
+# this buildcmd is on libretools.conf
+ $FULLBUILDCMD; r=$?
case $r in
- 0) ## Succesfull build
+## Succesfull build
+ 0)
plain "The build was succesful."
if source .INFO && [ -n $repo ]; then
- # Calls a local release script if it's used
+# Calls a local release script if it's used
if [ ! -z $HOOKLOCALRELEASE ]; then
find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo
fi
@@ -222,7 +219,8 @@ function __build () {
echo "built:$(basename $PWD)" >> $build_dir/log
;;
- *) ## Build failed
+## Build failed
+ *)
error "There were errors while trying to build the package."
echo "failed:$(basename $PWD)" >> $build_dir/log
;;
@@ -230,7 +228,8 @@ function __build () {
remove_buildorder "${build_packages[0]}" $buildorder || true
- build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package?
+# which is next package?
+ build_packages=($(sort -gr $buildorder | cut -d: -f2))
popd > /dev/null
done
@@ -257,7 +256,8 @@ function __build () {
popd > /dev/null
}
-function trap_exit { # End inmediately but print a useful message
+# End inmediately but print a useful message
+trap_exit() {
error "$@"
warning "Leftover files left on $build_dir"
@@ -297,7 +297,8 @@ while getopts 'ha:b:cCd:l:nm:r:' arg; do
c) check_deps_only='y' ;;
C) do_cleanup='y';;
d) build_dir="$OPTARG" ;;
- l) level=$OPTARG ;; # hidden option to know dep level.
+# hidden option to know dep level.
+ l) level=$OPTARG ;;
n) noupdate='y';;
m) max_level=$OPTARG ;;
r) FULLBUILDCMD="$OPTARG" ;;
@@ -306,7 +307,8 @@ done
if [ ${build_only} == 'n' ]; then
- [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early.
+# Check if we are actually on a build directory. Do this early.
+ [ ! -r PKGBUILD ] && {
error "This isn't a build directory"
usage
}
@@ -319,15 +321,19 @@ fi
if [ $level -eq 0 ]; then
- build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp
+# use -d option or else mktemp
+ build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)}
- if [ ! -d ${build_dir} ]; then # in case of custom -d option
- mkdir -p ${build_dir}
+# in case of custom -d option
+ if [ ! -d ${build_dir} ]; then
+ mkdir -p ${build_dir}
else
- cleanup # files already there can screw find_deps
+# files already there can screw find_deps
+ cleanup
fi
- touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder
+# make files for log and buildorder
+ touch ${build_dir}/{log,BUILDORDER} ${ban_file}
buildorder=${build_dir}/BUILDORDER
if [ ${noupdate} = 'n' ]; then
@@ -350,25 +356,32 @@ if [ $level -eq 0 ]; then
msg "Checking dependencies"
fi
-[ $level -ge $max_level ] && exit 20 # Probable circular deps
+# Probable circular deps
+[ $level -ge $max_level ] && exit 20
find_deps || {
- if [ $? -eq 20 ]; then # Probable circular deps
+# Probable circular deps
+ if [ $? -eq 20 ]; then
- if [ $level -eq 0 ]; then # Show error only on level 0
+# Show error only on level 0
+ if [ $level -eq 0 ]; then
error "Check for circular deps on $build_dir/BUILDORDER";
fi
fi
- exit 20 # Pass message 20
+# Pass message 20
+ exit 20
}
-[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0
+# only build on level 0
+[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0
-if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check
+# Sanity check
+if [ $level -eq 0 -a -d $build_dir ]; then
- if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions
+# Check ban_file permisions
+ if [ ! -w $ban_file -o ! -r $ban_file ]; then
chmod a+rw $ban_file || error "Ban file is not readable/writable ($ban_file)"
@@ -376,13 +389,16 @@ if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check
rsync -e ssh -aq $PARABOLAHOST:mips64el/ban >/dev/null 2>&1 || {
- warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist
+# use local copy if it exist
+ warning "Failed to get ban list" && [ -r ${ban_file} ] && {
search=$(cat ${ban_file} | tr "\n" "|")
- egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files
+# Keep track of banned files
+ egrep -w "$search" ${buildorder} >> ${build_dir}/banned
- egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder
+# Take banned packages out of buildorder
+ egrep -vw "$search" ${buildorder} > ${buildorder}2
mv -f ${buildorder}2 ${buildorder}
@@ -394,7 +410,8 @@ fi
msg "Building packages:"
-__build # Build the packages
+# Build the packages
+__build
echo
msg2 "Check if your system works fine and librerelease if it does"