summaryrefslogtreecommitdiff
path: root/fullpkg
diff options
context:
space:
mode:
Diffstat (limited to 'fullpkg')
-rwxr-xr-xfullpkg130
1 files changed, 72 insertions, 58 deletions
diff --git a/fullpkg b/fullpkg
index 6fb580c..bda55e7 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,27 +100,33 @@ 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})
+# Check if the package is already built
if is_built "${pkgbase}>=${fullver}"; then
# pkg is built and updated
exit 0
fi
# greater levels are built first
- echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER"
+ echo "${level}:${pkgbase}" >>"${build_dir}/BUILDORDER"
# PKGBUILD is already there
if [ -d "${build_dir}/${pkgbase}" ]; then
-
exit 0
-
# Copy dir to build_dir
else
-
cp -r ../${pkgbase}/ ${build_dir}/
# to identify repo later
@@ -118,40 +140,30 @@ find_deps() {
declare -i next_level=$level+1
# All deps in separate line, only once, without version.
- deps=$(echo "${depends[@]} ${makedepends[@]}" | \
+ deps=($(echo "${depends[@]} ${makedepends[@]}" | \
sed "s/[=<>]\+[^ ]\+//g" | \
tr ' ' "\n" | \
- sort -u)
+ sort -u))
for _dep in ${deps[@]}; do
local found=false
+ local pkgdir=$(where_is ${_dep})
-# TODO ask toru where the pkgbuild is
- for _repo in ${REPOS[@]}; do
+ if [ -d "${pkgdir}" ]; then
+ found=true
-# ABSROOT/repo/package
- if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then
+ pushd "${pkgdir}" > /dev/null
+# runs itself on dep's PKGBUILD dir
+ $0 -c -d ${build_dir} -l ${next_level}
- pushd "${ABSROOT}/${_repo}/${_dep}" > /dev/null
-# 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
-# found, end cycle
- break 1
- fi
-
- done
-
+ [ $? -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
@@ -159,20 +171,16 @@ 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
# 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"
@@ -182,7 +190,7 @@ __build() {
# this error means nonfree others means fail.
if [ $? -eq 15 ]; then
- echo "nonfree:$(basename $PWD)" >> $build_dir/log
+ echo "nonfree:$(basename $PWD)" >>$build_dir/log
# take out package from $buildorder
remove_buildorder "$(basename $PWD)" $buildorder
@@ -210,20 +218,20 @@ __build() {
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
*)
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
@@ -254,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"
@@ -273,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
@@ -288,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" ;;
@@ -306,7 +316,7 @@ while getopts 'ha:b:cCd:l:nm:r:' arg; do
esac
done
-if [[ ! ${build_only} ]]; then
+if ! (( build_only )); then
# Check if we are actually on a build directory. Do this early.
if [ ! -r PKGBUILD ]; then
@@ -314,31 +324,33 @@ if [[ ! ${build_only} ]]; then
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
# use -d option or else mktemp
- build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)}
+ build_dir="${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)}"
# in case of custom -d option
- if [ ! -d ${build_dir} ]; then
- mkdir -p ${build_dir}
+ if [ ! -d "${build_dir}" ]; then
+ mkdir -p "${build_dir}"
else
# files already there can screw find_deps
cleanup
fi
# make files for log and buildorder
- touch ${build_dir}/{log,BUILDORDER} ${ban_file}
- buildorder=${build_dir}/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
@@ -346,7 +358,7 @@ if [ $level -eq 0 ]; then
if (( build_only )); then
- msg "Build Packages"
+ msg "Building Packages"
__build
@@ -360,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
@@ -376,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