summaryrefslogtreecommitdiff
path: root/fullpkg
diff options
context:
space:
mode:
authorNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-09-19 11:02:54 -0300
committerNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-09-19 11:02:54 -0300
commit0663c0c58a8d04a35f5ba9ab6de068a3f6c09b40 (patch)
tree46bc1b0b26d75db7aeb17c24615e5ef83d32355b /fullpkg
parent1cc99571dd8b5f250909025a1c4df73510087899 (diff)
parent32acbf2d80898a1139325f3d058753b125c0bd7e (diff)
Merge branch 'master' of ssh://gparabola/libretools
Conflicts: librerelease
Diffstat (limited to 'fullpkg')
-rwxr-xr-xfullpkg184
1 files changed, 116 insertions, 68 deletions
diff --git a/fullpkg b/fullpkg
index 6cdae31..f242039 100755
--- a/fullpkg
+++ b/fullpkg
@@ -19,7 +19,6 @@ elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then
fi
-
usage() {
echo "cd to a dir containing a PKGBUILD and run:"
@@ -41,6 +40,23 @@ usage() {
}
+# Finds a PKGBUILD on toru's path cache
+# Look in all caches but pick the first one
+# TODO move to a toru flag (-p?)
+where_is() {
+ local _repo
+ local _path
+ for _repo in ${REPOS[@]}; do
+ _path=$(grep "^${1}:" "${TORUPATH}/${_repo}.paths.cache" 2>/dev/null| \
+ cut -d: -f2 2>/dev/null)
+
+ [ -n "${_path}" ] && break
+ done
+
+ echo ${_path}
+
+}
+
# Removes a package from the buildorder
# $1 package name
# $2 buildorder file
@@ -84,55 +100,70 @@ find_deps() {
# Check this level
source PKGBUILD
+# unset PKGBUILD variables
+ unset pkgdesc url license groups optdepends provides conflicts replaces \
+ backup options install changelog source noextract md5sums build \
+ check package
+ for _pkg in ${pkgname[@]}; do
+ unset package_${_pkg} >/dev/null 2>&1
+ done
+
local repo=${repo:-$(guess_repo)}
local pkgbase=${pkgbase:-${pkgname[0]}}
+# Provide a default 0 to epoch
local epoch=${epoch:-0}
local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel})
- if is_built "${pkgbase}>=${fullver}"; then # pkg is built and updated
+# Check if the package is already built
+ if is_built "${pkgbase}>=${fullver}"; then
+# 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
+# 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
+# current package plus a space for every level
+ msg2 "%${level}s${pkgbase}-${fullver}"
- declare -i next_level=$level+1 ## Check next levels
+## Check next levels
+ declare -i next_level=$level+1
- deps=$(echo "${depends[@]} ${makedepends[@]}" | \
+# 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
+ local pkgdir=$(where_is ${_dep})
- for _repo in ${REPOS[@]}; do # TODO ask toru where the pkgbuild is
-
- if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then # ABSROOT/repo/package
+ if [ -d "${pkgdir}" ]; then
+ found=true
- 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
- popd > /dev/null
- local found=true
- break 1 # found, end cycle
- fi
+ pushd "${pkgdir}" > /dev/null
+# runs itself on dep's PKGBUILD dir
+ $0 -c -d ${build_dir} -l ${next_level}
- done
+# probable circular deps
+ [ $? -eq 20 ] && return 20
+ popd > /dev/null
+ fi
- if ${found}; then # go to next dep
- continue 1
- else
- echo "dep_not_found:$_dep" >> $build_dir/log
+ if ! (( found )); then
+ echo "dep_not_found:$_dep" >>$build_dir/log
fi
done
@@ -140,68 +171,74 @@ find_deps() {
## End variable block
unset next_level dir
-# 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
}
__build() {
- pushd ${build_dir} > /dev/null
+ 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
+ pushd $build_dir/${build_packages[0]} >/dev/null
source PKGBUILD
msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel"
msg2 "Checking for non free deps"
pkgbuild-check-nonfree || {
+# this error means nonfree others means fail.
+ if [ $? -eq 15 ]; then
- if [ $? -eq 15 ]; then # this error means nonfree others means fail.
+ echo "nonfree:$(basename $PWD)" >>$build_dir/log
- echo "nonfree:$(basename $PWD)" >> $build_dir/log
+# take out package from $buildorder
+ remove_buildorder "$(basename $PWD)" $buildorder
- remove_buildorder "$(basename $PWD)" $buildorder # take out package from $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
- if [ ! -z $HOOKLOCALRELEASE ]; then # Calls a local release script
+# Calls a local release script if it's used
+ if [ ! -z $HOOKLOCALRELEASE ]; then
find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo
fi
- librestage $repo || echo "unstaged:$(basename $PWD)" >> $build_dir/log
+ librestage $repo || echo "unstaged:$(basename $PWD)" >>$build_dir/log
msg "Updating pacman db and packages"
sudo pacman -Sy || true
fi
- echo "built:$(basename $PWD)" >> $build_dir/log
+ 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
+ echo "failed:$(basename $PWD)" >>$build_dir/log
;;
esac
remove_buildorder "${build_packages[0]}" $buildorder || true
- build_packages=($(sort -gr $buildorder | cut -d: -f2)) # find out next package
+# which is next package?
+ build_packages=($(sort -gr $buildorder | cut -d: -f2))
popd > /dev/null
done
@@ -225,12 +262,11 @@ __build() {
echo ${pkgs[@]} | tr " " "\n" | cut -d: -f2
}
- popd > /dev/null
+ popd >/dev/null
}
# End inmediately but print a useful message
trap_exit() {
-
error "$@"
warning "Leftover files left on $build_dir"
@@ -244,7 +280,6 @@ trap 'trap_exit "(prfullpkg:${level}) TERM signal caught. Exiting..."' TERM HUP
trap 'trap_exit "(prfullpkg:${level}) Aborted by user! Exiting..."' INT
trap 'trap_exit "(prfullpkg:${level}) An unknown error has occurred. Exiting..."' ERR
-ban_file=$XDG_CONFIG_HOME/libretools/ban
force_build=""
level=0
noupdate=false
@@ -259,13 +294,17 @@ while getopts 'ha:b:cCd:l:nm:r:' arg; do
a) ABSROOT="$OPTARG" ;;
b) build_only=true
build_dir="$OPTARG"
- if [ -z ${build_dir} ]; then
+
+ if [ -z "${build_dir}" ]; then
usage
fi
- if [ ! -r ${build_dir}/BUILDORDER ] ; then
+
+ if [ ! -r "${build_dir}/BUILDORDER" ] ; then
error "${build_dir}/BUILDORDER doesn't exist."
exit 1
- fi;;
+ fi
+
+ ;;
c) check_deps_only=true ;;
C) do_cleanup=true;;
d) build_dir="$OPTARG" ;;
@@ -277,34 +316,41 @@ while getopts 'ha:b:cCd:l:nm:r:' arg; do
esac
done
-if ! (( ${build_only} )); then
+if ! (( build_only )); then
- if [ ! -r PKGBUILD ]; then # Check if we are actually on a build directory. Do this early.
+# Check if we are actually on a build directory. Do this early.
+ if [ ! -r PKGBUILD ]; then
error "This isn't a build directory"
usage
fi
- if [ ! -z "$HOOKPKGBUILDMOD" ]; then
- "$HOOKPKGBUILDMOD"
+# Run the pre build hook
+ if [ ! -z "${HOOKPKGBUILDMOD}" ]; then
+ ${HOOKPKGBUILDMOD}
fi
fi
-if [ $level -eq 0 ]; then
+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
- buildorder=${build_dir}/BUILDORDER
+# make files for log and buildorder
+ touch "${build_dir}"/{log,BUILDORDER}
+ buildorder="${build_dir}/BUILDORDER"
if ! (( noupdate )); then
+# Always return true
msg "Updating pacman db and packages"
sudo pacman -Syu --noconfirm || true
@@ -312,7 +358,7 @@ if [ $level -eq 0 ]; then
if (( build_only )); then
- msg "Build Packages"
+ msg "Building Packages"
__build
@@ -326,6 +372,7 @@ fi
# Probable circular deps
[ $level -ge $max_level ] && exit 20
+# Find the dependencies on the ABS itself
find_deps || {
# Probable circular deps
@@ -342,14 +389,15 @@ find_deps || {
}
# only build on level 0
-$( (( check_deps_only )) || [ $level -gt 0 ] ) && exit 0
-
-msg "Building packages:"
+if (( check_deps_only )) || [ $level -gt 0 ]; then
+ exit 0
+fi
# Build the packages
+msg "Building packages:"
__build
echo
-msg2 "Check if your system works fine and librerelease if it does"
+msg2 "Check if your system works fine and librerelease if it does."
exit 0