summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-06-30 18:14:15 -0300
committerNicolás Reynolds <apoyosis@correo.inta.gob.ar>2011-06-30 18:14:15 -0300
commit8a385be009f51b1af2cd8fd82c08b6b7c2c7f8b0 (patch)
tree72e58e38d91827b9a2d116406a26bd894122d91f
parent8dff8b1deac0bd4a832e1dee0173e79c55ab4301 (diff)
parent207a930a564e8157e24c3e7f5fbe987494b73d7b (diff)
Merge branch 'master' of ssh://vparabola/srv/git/projects/libretools
-rw-r--r--TODO7
-rwxr-xr-xcreateworkdir60
-rwxr-xr-xdiff-unfree30
-rwxr-xr-xfullpkg366
-rwxr-xr-xlibrechroot32
-rwxr-xr-xlibrecommit30
-rwxr-xr-xlibrediff32
-rwxr-xr-xlibremakepkg106
-rwxr-xr-xlibrerelease32
-rwxr-xr-xlibrerepkg30
-rwxr-xr-xlibrestage24
-rw-r--r--libretools.conf15
-rw-r--r--mips64el/mips-add6
-rw-r--r--mips64el/mips64el.conf12
-rwxr-xr-xmips64el/mipsrelease (renamed from mipsrelease)0
-rwxr-xr-xpkgbuild-check-nonfree150
-rwxr-xr-xprtools/prfullpkg (renamed from prfullpkg)334
-rwxr-xr-xprtools/prmipsrelease (renamed from prmipsrelease)14
-rw-r--r--prtools/prtools.conf (renamed from prtools.conf)0
-rw-r--r--prtools/prtoru173
-rw-r--r--rePKGBUILD.proto7
-rwxr-xr-xtoru10
22 files changed, 842 insertions, 628 deletions
diff --git a/TODO b/TODO
deleted file mode 100644
index 2f019b2..0000000
--- a/TODO
+++ /dev/null
@@ -1,7 +0,0 @@
-* A tool for repackaging. For instance, some packages need changing that can be
-done without rebuilding everything (OO.o's change of extension dir, for
-instance, changes on default config files)
- What should it do?
- - Retrieve the package from official repos
- - Extract it to pkg/
- - Repackage
diff --git a/createworkdir b/createworkdir
index 53298f6..b443c08 100755
--- a/createworkdir
+++ b/createworkdir
@@ -5,35 +5,46 @@
# Copyright 2010 Nicolás Reynolds
# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
source /etc/libretools.conf
custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
[[ -e $custom_config ]] && source $custom_config
-# Create the WORKDIR
-[[ ! -d ${WORKDIR} ]] && {
+[[ ! -d ${WORKDIR} ]] && { # Create the WORKDIR
+
msg "Creating WORKDIR on ${WORKDIR}"
mkdir -p ${WORKDIR} ||{
- error "Could not create ${WORKDIR}"
- exit 1
+ error "Could not create ${WORKDIR}"; exit 1
}
+
}
+for _repo in ${REPOS[@]}; do # Create the staging dirs
+
+ [[ ! -d ${WORKDIR}/staging/${_repo} ]] && {
+ mkdir -p ${WORKDIR}/staging/${_repo} || {
+ error "Can't create ${WORKDIR}/staging/${_repo}"
+ exit 1
+ }
+ }
+
+done
+
[[ ! -d ${WORKDIR}/abslibre/.git ]] && {
msg "Cloning into ABSLibre"
CMD="git clone ${ABSLIBREGIT} ${WORKDIR}/abslibre"
@@ -46,17 +57,6 @@ custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
}
}
-
-# Create the staging dirs
-for _repo in ${REPOS[@]}; do
- [[ ! -d ${WORKDIR}/staging/${_repo} ]] && {
- mkdir -p ${WORKDIR}/staging/${_repo} || {
- error "Can't create ${WORKDIR}/staging/${_repo}"
- exit 1
- }
- }
-done
-
msg "Finished, your packaging dir tree looks like this now:"
ls --color=always ${WORKDIR}/*/*
diff --git a/diff-unfree b/diff-unfree
index e4004d6..a0a8d63 100755
--- a/diff-unfree
+++ b/diff-unfree
@@ -4,21 +4,21 @@
# Copyright 2010 Nicolás Reynolds
# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
source /etc/libretools.conf
custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
diff --git a/fullpkg b/fullpkg
index cae91da..be26956 100755
--- a/fullpkg
+++ b/fullpkg
@@ -1,25 +1,23 @@
#!/bin/bash
-# TO TEST: (on find_deps)
-# * Detect pkgnames by provides, replaces, etc. instead of dir tree
source /etc/makepkg.conf
source /etc/abs.conf
source /etc/libretools.conf
+source /etc/libretools.d/prtools.conf
-# Avoid /libretools dir doesn't exist errors
-if [ -z $XDG_CONFIG_HOME ]; then
- error "There's no XDG_CONFIG_HOME var set"
- exit 1
-fi
-# set ban_file
-[ -e $XDG_CONFIG_HOME/libretools/libretools.conf ] && \
- source $XDG_CONFIG_HOME/libretools/libretools.conf
-ban_file=$XDG_CONFIG_HOME/libretools/ban
+if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors
+
+ error "There's no XDG_CONFIG_HOME var set"; exit 1
+
+elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then
+
+ source $XDG_CONFIG_HOME/libretools/libretools.conf
+fi
-##### START FUNCTIONS #####
function usage {
+
echo "cd to a dir containing a PKGBUILD and run:"
echo "$0 [options]"
printf "This script will check dependencies, build them if possible "
@@ -30,131 +28,144 @@ function usage {
echo " -a absdir : set absdir as ABSROOT."
echo " -b build_dir : use a fullpkg build_dir and only build."
echo " -c : check deps only, do not build."
+ echo " -C : cleanup the build_dir."
echo " -d build_dir : use this dir to build. Defaults to mktemp."
echo " -n : don't update pacman db."
echo " -m max_level : check deps until this level"
echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\""
echo
exit 1
-}
-## Build order management ##
+}
-# Removes a package from the buildorder
+function remove_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}
+
}
-# Guesses the repo name according to the parent dir of the current package
-# assuming the form repo/package/PKGBUILD
-guess_repo() {
- basename $(dirname $(pwd))
+function guess_repo { # Get repo name. Asumes ${ABSROOT}/repo/package/PKGBUILD
+
+ basename $(dirname $(pwd)) # Variable in prfullpkg
+
}
-##
-# usage : get_full_version( $epoch, $pkgver, $pkgrel )
-# return : full version spec, including epoch (if necessary), pkgver, pkgrel
-##
-get_full_version() {
+function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel
+
+# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel )
+
if [[ $1 -eq 0 ]]; then
# zero epoch case, don't include it in version
echo $2-$3
else
echo $1:$2-$3
fi
+
}
-# Usage: cleanup [ $(basename $PWD) ] from PKGBUILD dir
-# cleans the build_dir
-function cleanup {
-# Do nothing OR
-# Already cleaned
- [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0
+function cleanup { # Cleans the build_dir.
+
+ [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0 # Do nothing or already cleaned.
-# Only do cleanup on level 0
msg "Cleaning up..."
- [ $level -eq 0 ] && rm -rf $build_dir/*
+ [ $level -eq 0 ] && rm -rf $build_dir/* # Only do cleanup on level 0.
+
}
-# Check PKGBUILD and find non built or outdated deps
-# on ABSROOT which should be abslibre-misp64el
-function find_deps {
- ## Check this level.
- source PKGBUILD
+function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated.
+
+ source PKGBUILD ## Check this level.
+
local repo=${repo:-$(guess_repo)}
local pkgbase=${pkgbase:-${pkgname[0]}}
local epoch=${epoch:-0}
- local fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel})
+ local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel})
-# If package and correct ${fullver} is built exit
if is_built "${pkgbase}>=${fullver}"; then
- exit 0
+ exit 0 # pkg is built and updated
fi
-# Tell which packages are deeper in deps (even if they are on build_dir)
-# so we can build them first.
- echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER"
+ echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first
+
+ if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there
-# if pkgbuild directory is on build_dir, do not copy and exit
- if [ -d "${build_dir}/${pkgbase}" ]; then
exit 0
- else
-# Copy dir to build_dir
+
+ else # Copy dir to build_dir
+## variable block for prfullpkg
+
cp -r ../${pkgbase}/ ${build_dir}/
-# Info to eval later
- echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO"
+
+ echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later
fi
-# Inform the current package plus a space for every level for indent
- msg2 "%${level}s${pkgbase}-${fullver}"
+ msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level
+
+ declare -i next_level=$level+1 ## Check next levels
-## Check next levels
-# Clean version checking
deps=$(echo "${depends[@]} ${makedepends[@]}" | \
sed "s/[=<>]\+[^ ]\+//g" | \
tr ' ' "\n" | \
- sort -u)
-
-# Increase build level
- declare -i next_level=$level+1
+ sort -u) # All deps in separate line, only once, without version.
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
- $0 -c -d ${build_dir} -l ${next_level}
+ local found=false
+
+ for _repo in ${REPOS[@]}; do
- # Circular deps must fail
- [ $? -eq 20 ] && return 20
+ if [ -e "${ABSROOT}/${_repo}/${_dep}/PKGBUILD" ]; then # ABSROOT/repo/package
+
+ 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
- break 1 # found, go to next dep
- fi
- done
-# if search pkgname in repo doesn't work
-# this should find pkgsplits
- 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}
-# Circular deps must fail
- [ $? -eq 20 ] && return 20
- popd > /dev/null
- break 1 # found, go to next dep
- else
- echo "dep_not_found:$_dep:$_repo" >> $build_dir/log
+ local found=true
+ break 1 # found, end cycle
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
+ else
+ echo "dep_not_found:$_dep" >> $build_dir/log
+ fi
+
done
+## End variable block
+
unset next_level dir
# unset PKGBUILD variables
unset pkgname pkgver pkgrel epoch pkgdesc arch url license groups depends \
@@ -162,67 +173,64 @@ function find_deps {
options install changelog source noextract md5sums build check package
}
-function _pkg_build () {
+function __build () {
pushd ${build_dir} > /dev/null
- # packages to build are on $buildorder
- # greater levels must be built first
- build_packages=($(sort -gr $buildorder | cut -d: -f2))
+
+ build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first
while [ ${#build_packages[@]} -ge 1 ]; do
pushd $build_dir/${build_packages[0]} > /dev/null
- source PKGBUILD
+ source PKGBUILD
msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel"
msg2 "Checking for non free deps"
pkgbuild-check-nonfree || {
if [ $? -eq 15 ]; then # this error means nonfree others means fail.
-# log they have nonfree deps and so didn't build
+
echo "nonfree:$(basename $PWD)" >> $build_dir/log
-# take out package from $buildorder
- remove_buildorder "$(basename $PWD)" $buildorder
-# continue building next package
- continue
+
+ remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder
+
+ continue # build next package
fi
}
msg2 "Building $(basename $PWD)"
-# this buildcmd is on libretools.conf
- $FULLBUILDCMD; r=$?
+
+ $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf
+
case $r in
-###### Succesfull Build ######
- 0)
+
+ 0) ## Succesfull build
+
plain "The build was succesful."
- source .INFO && [ -n $repo ] && {
+ if source .INFO && [ -n $repo ]; then
-# Calls a local release script if it's used
- [ -z $HOOKLOCALRELEASE ] || \
- find -name "*.pkg.tar.?z" -print0 | \
- xargs -0 $HOOKLOCALRELEASE $repo
+ # Calls a local release script if it's used
+ if [ ! -z $HOOKLOCALRELEASE ]; then
+ find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo
+ fi
-# Stage for releasing
- 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
;;
-###### Failed Build ######
- *)
- error "There were errors while trying to build the package."
+
+ *) ## Build failed
+ error "There were errors while trying to build the package."
echo "failed:$(basename $PWD)" >> $build_dir/log
;;
esac
-# Package was built or failed: take it out of $buildorder
remove_buildorder "${build_packages[0]}" $buildorder || true
-# Set build_packages before next cycle run
- build_packages=($(sort -gr $buildorder | cut -d: -f2))
+ build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package?
popd > /dev/null
done
@@ -249,8 +257,7 @@ function _pkg_build () {
popd > /dev/null
}
-# End inmediately but print a useful message
-trap_exit() {
+function trap_exit { # End inmediately but print a useful message
error "$@"
warning "Leftover files left on $build_dir"
@@ -258,16 +265,14 @@ trap_exit() {
exit 1
}
-## END FUNCTIONS ##
-
-## Trap signals
-# From makepkg
+# Trap signals from makepkg
set -E
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
+trap 'trap_exit "(prfullpkg:${level}) TERM signal caught. Exiting..."' TERM HUP QUIT
+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='n'
@@ -275,26 +280,24 @@ build_only='n'
check_deps_only='n'
do_cleanup='n'
max_level=21
-OFFLINE=false
+
while getopts 'ha:b:cCd:l:nm:r:' arg; do
case $arg in
h) usage ;;
a) ABSROOT="$OPTARG" ;;
- b) build_only='y'
+ b) build_only='y'
build_dir="$OPTARG"
- [ -z ${build_dir} ] && {
+ if [ -z ${build_dir} ]; then
usage
- }
- [ ! -r ${build_dir}/BUILDORDER ] && {
+ fi
+ if [ ! -r ${build_dir}/BUILDORDER ] ; then
error "${build_dir}/BUILDORDER doesn't exist."
exit 1
- };;
+ fi;;
c) check_deps_only='y' ;;
C) do_cleanup='y';;
d) build_dir="$OPTARG" ;;
-# hidden option to know what to build first.
-# if $level > 0 it will not build
- l) level=$OPTARG ;;
+ l) level=$OPTARG ;; # hidden option to know dep level.
n) noupdate='y';;
m) max_level=$OPTARG ;;
r) FULLBUILDCMD="$OPTARG" ;;
@@ -303,92 +306,95 @@ done
if [ ${build_only} == 'n' ]; then
-# Check if we are actually on a build directory
-# Do this early
-
- [ ! -r PKGBUILD ] && {
+ [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early.
error "This isn't a build directory"
usage
}
-# Add mips64el if missing from arch=() and it isn't an 'any' package
- if ! grep mips64el PKGBUILD >/dev/null; then
- warning "Adding mips64el arch"
- sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD"
+ if [ ! -z "$HOOKPKGBUILDMOD" ]; then
+ "$HOOKPKGBUILDMOD"
fi
fi
-# Only on level 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)}
- mkdir -p ${build_dir} # in case of -d option
-# make files for log and buildorder
- touch ${build_dir}/{log,BUILDORDER}
+ build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp
+
+ if [ ! -d ${build_dir} ]; then # in case of custom -d option
+ mkdir -p ${build_dir}
+ else
+ cleanup # files already there can screw find_deps
+ fi
+
+ touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder
buildorder=${build_dir}/BUILDORDER
- [ ${noupdate} = 'n' ] && {
+ if [ ${noupdate} = 'n' ]; then
+
msg "Updating pacman db and packages"
sudo pacman -Syu --noconfirm || true
- }
-# Build only
- [ ${build_only} == 'y' ] && {
+ fi
+
+ if [ ${build_only} == 'y' ]; then
+
msg "Build Packages"
- _pkg_build
+
+ __build
+
exit 0
- }
+
+ fi
msg "Checking dependencies"
fi
-## if $level = 20 it's highly likely there are circular deps
-[ $level -ge $max_level ] && exit 20
+[ $level -ge $max_level ] && exit 20 # Probable circular deps
-# Tries to find deps and build order
-find_deps || {
- # if find_deps finds circular deps
- # it should exit with status 20
- [ $? -eq 20 ] && {
- # only show message on level 0
- [ $level -eq 0 ] && error "Check for circular deps on $build_dir/BUILDORDER";
- }
- exit 20
+find_deps || {
+
+ if [ $? -eq 20 ]; then # Probable circular deps
+
+ if [ $level -eq 0 ]; then # Show error only on level 0
+ error "Check for circular deps on $build_dir/BUILDORDER";
+ fi
+
+ fi
+ exit 20 # Pass message 20
}
-# levels greater than 0 must only check deps
-[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0
+[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0
+
+if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check
+
+ if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions
-# check BUILDORDER to not include banned deps and
-[ $level -eq 0 -a -d $build_dir ] && {
-# 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)"
+ chmod a+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} ] && {
-# Use local copy of ban file if it is avaliable and continue.
+ warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist
+
search=$(cat ${ban_file} | tr "\n" "|")
-# Keep track of banned files
- egrep -w "$search" ${buildorder} >> ${build_dir}/banned
-# Take banned packages out from buildorder
- egrep -vw "$search" ${buildorder} > ${buildorder}2
+
+ egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files
+
+ egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder
+
mv -f ${buildorder}2 ${buildorder}
+
unset search
}
}
fi
-}
+fi
-## START Building
msg "Building packages:"
-# Build the package
-_pkg_build
+__build # Build the packages
echo
msg2 "Check if your system works fine and librerelease if it does"
diff --git a/librechroot b/librechroot
index b308b7d..8071ca9 100755
--- a/librechroot
+++ b/librechroot
@@ -5,21 +5,21 @@
# Copyright 2010 Nicolás Reynolds
# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
source /etc/libretools.conf
@@ -32,7 +32,7 @@ function usage {
while getopts 'h' arg; do
case $arg in
- h) usage; exit 0 ;;
+ h) usage; exit 0 ;;
esac
done
diff --git a/librecommit b/librecommit
index d9a9164..d3ddbff 100755
--- a/librecommit
+++ b/librecommit
@@ -2,21 +2,21 @@
# Copyright 2010 Nicolás Reynolds
# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
source /etc/libretools.conf
diff --git a/librediff b/librediff
index 59a9791..1f39eb9 100755
--- a/librediff
+++ b/librediff
@@ -4,21 +4,21 @@
# Copyright 2010 Nicolás Reynolds
# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
usage() {
echo "Usage: $0 <pkgname> [<pkgname2> ...]"
@@ -54,7 +54,7 @@ for package in $@; do
continue
}
- source ./${package}-libre/PKGBUILD
+ source ./${package}-libre/PKGBUILD
[[ -z ${pkgbase} ]] && pkgbase=${pkgname}
# Generate a diff file, no -r since we don't want to patch src/ nor pkg/
diff --git a/libremakepkg b/libremakepkg
index b2f8aa8..13e7617 100755
--- a/libremakepkg
+++ b/libremakepkg
@@ -22,7 +22,8 @@
source /etc/libretools.conf
source /etc/makepkg.conf
-function usage {
+function usage { # Display message and exit
+
echo 'cd to a dir containing a PKGBUILD and run:'
echo '$0 [options] [makepkg args]'
echo 'This script will build your package on a chroot.'
@@ -32,30 +33,25 @@ function usage {
echo ' -h show this message.'
echo ' -c cleans the chroot before building.'
echo ' -u updates the chroot before building.'
- echo ' -U copy pacman, makepkg, and mtag config files to the chroot'
echo ' -n use this dir instead of "${CHCOPY}".'
echo ' -M <--arg> passes long args to makepkg, use it as many times as needed.'
echo
+ exit 1
}
-function buildenv {
+function buildenv { # Mounts *DEST from makepkg.conf
+
msg "Building env"
- for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do
+ for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST}; do
msg2 "binding ${mp} to ${CHROOTDIR}/${CHCOPY}${mp}"
mkdir -p "${CHROOTDIR}/${CHCOPY}${mp}"
mount -o bind ${mp} "${CHROOTDIR}/${CHCOPY}${mp}" || exit 1
done
- if [ "$update_config" = 'y' ] ; then
- for config in etc/makepkg.conf etc/pacman.conf etc/mtab; do
- msg2 "copying config /$config to ${CHROOTDIR}/${CHCOPY}/${config}"
- cp --remove-destination /${config} ${CHROOTDIR}/${CHCOPY}/${config} || exit 1
- done
- fi
}
-# Clean packages with pacman
-function clean_chroot {
+function clean_chroot { # Clean packages with pacman
+
plain "making list of packages in ${CHROOTDIR}/${CHROOTNAME}/root/"
cp "/etc/libretools.d/cleansystem" "${CHROOTDIR}/${CHROOTNAME}/root/cleansystem"
(cat <<EOF
@@ -79,22 +75,33 @@ EOF
) > "${CHROOTDIR}/${CHROOTNAME}/clean"
chmod +x "${CHROOTDIR}/${CHROOTNAME}/clean"
mkarchroot -r "/clean" "${CHROOTDIR}/${CHROOTNAME}"
+
+}
+
+function copy_log { # copy logs if they exist
+
+ if [ "${USE_LOG}" == 'y' ]; then
+ find ${CHROOTDIR}/${CHROOTNAME}/build/ -name "*\.log" -exec cp {} ./ \;
+ fi
+
}
-# End inmediately but print a useful message
-trap_exit() {
+function trap_exit { # End inmediately but print a useful message
+
+# args are treated as part of the message
- for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST} ${WORKDIR}; do
+ for mp in ${SRCDEST} ${PKGDEST} ${SRCPKGDEST}; do
umount "${CHROOTDIR}/${CHCOPY}${mp}"
done
+ copy_log
+
error "$@"
exit 1
}
-## Trap signals
-# From makepkg
+# Trap signals from makepkg
set -E
trap 'trap_exit "(libremakepkg): TERM signal caught. Exiting..."' TERM HUP QUIT
trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT
@@ -106,19 +113,15 @@ UPDATE_FIRST="n"
USE_LOG='n'
CHROOTNAME=${CHCOPY}
MAKEPKG_ARGS=""
-update_config='n'
-#libremakepkg own args
-libremakepkgargs='hcuUn:I:M:'
-#now makepkg args
-libremakepkgargs+='ACdefiLmop:rRs'
+libremakepkgargs='hcuUn:I:M:' # libremakepkg own args
+libremakepkgargs+='ACdefiLmop:rRs' # makepkg args
while getopts ${libremakepkgargs} arg ; do
case "${arg}" in
- h) usage; exit 0 ;;
+ h) usage ;;
c) CLEAN_FIRST="y" ;;
u) UPDATE_FIRST="y" ;;
- U) update_config='y' ;;
n) CHROOTNAME="$OPTARG" ;;
M) MAKEPKG_ARGS+=" $OPTARG" ;;
L) MAKEPKG_ARGS+=" -$arg $OPTARG"
@@ -132,35 +135,54 @@ if [ ${UID} -ne 0 ]; then
exit 1
fi
+if [ ! -r PKGBUILD ]; then # Check if we are actually on a build directory. Do this early.
+
+ error "This isn't a build directory"; usage
+
+fi
+
msg "Checking PKGBUILD for non-free issues"
-pkgbuild-check-nonfree ||{
- if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree
+if ! pkgbuild-check-nonfree; then
+
+ if [[ $? -eq 15 ]]; then # other errors mean fail, not nonfree
error "PKGBUILD contains non-free issues"
exit 15
else
true
fi
-}
-
-buildenv
-if [ "${UPDATE_FIRST}" = 'y' ]; then
- msg "Updating the chroot in use..."
-# -c option in mkarchroot indicates cache
- mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}"
fi
-if [ "${CLEAN_FIRST}" = 'y' ]; then
- msg "Cleaning"
- clean_chroot
-fi
+buildenv
msg "Creating the package"
-makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}"
-ev=$? # exit value
+if [ -d "${CHROOTDIR}/${CHROOTNAME}" ]; then # use chroot
-if [ "${USE_LOG}" == 'y' ]; then
- find ${CHROOTDIR}/${CHROOTNAME}/build/ -name "*\.log" -exec cp {} ./ \;
-}
+ if [ "${UPDATE_FIRST}" = 'y' ]; then
+ msg "Updating the chroot in use..."
+ mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOTNAME}" # -c option is for cache
+ fi
+
+ if [ "${CLEAN_FIRST}" = 'y' ]; then
+ msg "Cleaning"
+ clean_chroot
+ fi
+
+ makechrootpkg -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}"
+ ev=$? # exit value
+
+else # build new chroot before using
+
+ if [ "${UPDATE_FIRST}" = 'y' ]; then # update CHROOT
+ msg "Updating the chroot in use..."
+ mkarchroot -c ${CACHEDIR} -u "${CHROOTDIR}/${CHROOT}" # -c option is for cache
+ fi
+
+ makechrootpkg -c -r "${CHROOTDIR}" -l "${CHROOTNAME}" -- "${MAKEPKG_ARGS}"
+ ev=$? # exit value
+
+fi
+
+copy_log
exit $ev
diff --git a/librerelease b/librerelease
index ed221c8..169ca0e 100755
--- a/librerelease
+++ b/librerelease
@@ -1,25 +1,25 @@
- #!/bin/bash
+#!/bin/bash
# Librerelease
# Uploads packages into [staging]
# Copyright 2010 Nicolás Reynolds
# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
source /etc/libretools.conf
custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
diff --git a/librerepkg b/librerepkg
index 1da4b8e..90e68ae 100755
--- a/librerepkg
+++ b/librerepkg
@@ -2,21 +2,21 @@
# Copyright 2011 Joshua Ismael Haase Hernandez
# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
source /etc/libretools.conf
custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
diff --git a/librestage b/librestage
index 07e9ca9..d1784ab 100755
--- a/librestage
+++ b/librestage
@@ -6,20 +6,20 @@
# ---------- GNU General Public License 3 ----------
-# This file is part of Parabola.
+# This file is part of Parabola.
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
source /etc/libretools.conf
custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
@@ -88,7 +88,7 @@ for _arch in ${ARCHES[@]}; do
if [ -e "${pkgpath}" ]; then
msg "Found ${pkgfile}"
- canonical=""
+ canonical=""
for _repo in ${repos[@]}; do
[[ -z "$canonical" ]] && {
diff --git a/libretools.conf b/libretools.conf
index 18284a0..fa5d4b2 100644
--- a/libretools.conf
+++ b/libretools.conf
@@ -35,13 +35,6 @@ PARABOLAHOST=parabola
## Run a command before releasing a package (ie. SSH connection, SSH tunnel, etc.)
HOOKPRERELEASE="ssh -fN parabola"
-## Run a command for local releasing of packages
-# Useful for mass packaging (ie. mips port)
-# Must accept the following parameters even if the command won't use them:
-# $1 repo name
-# $2+ packages
-HOOKLOCALRELEASE="mipsrelease"
-
## Server destination of libre packages
# Don't change unless you know what you're doing and you won't screw
# anything ;)
@@ -75,6 +68,14 @@ done
source /usr/bin/libremessages
+## These are architecture specific files.
+## Uncomment them if you installed libretools-arch
+#source /etc/libretools.d/mips64el.conf
+#source /etc/libretools.d/x86_64.conf
+#source /etc/libretools.d/i686.conf
+
+
+
## Recommended SSH Config follows
# SSH host, it's better if you have it configured on ~/.ssh/config
# with ControlMaster auto (and a shell opened somewhere else)
diff --git a/mips64el/mips-add b/mips64el/mips-add
new file mode 100644
index 0000000..0d4e494
--- /dev/null
+++ b/mips64el/mips-add
@@ -0,0 +1,6 @@
+#!/bin/bash
+if ! grep mips64el PKGBUILD >/dev/null; then # Add mips64el in ${arch} array if it isn't 'any'
+ warning "Adding mips64el arch"
+ sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD"
+ librecommit PKGBUILD
+fi
diff --git a/mips64el/mips64el.conf b/mips64el/mips64el.conf
new file mode 100644
index 0000000..48674b2
--- /dev/null
+++ b/mips64el/mips64el.conf
@@ -0,0 +1,12 @@
+## Arquitecture specific commands
+
+## Run a command for PKGBUILD modifications before building
+## Like adding 'mips64el' to arch if it's not there
+HOOKPKGBUILDMOD="mipsadd"
+
+## Run a command for local releasing of packages
+# Useful for mass packaging (ie. mips port)
+# Must accept the following parameters even if the command won't use them:
+# $1 repo name
+# $2+ packages
+HOOKLOCALRELEASE="mipsrelease"
diff --git a/mipsrelease b/mips64el/mipsrelease
index dae489c..dae489c 100755
--- a/mipsrelease
+++ b/mips64el/mipsrelease
diff --git a/pkgbuild-check-nonfree b/pkgbuild-check-nonfree
index 5ecb5f7..21842ac 100755
--- a/pkgbuild-check-nonfree
+++ b/pkgbuild-check-nonfree
@@ -3,82 +3,96 @@
# Copyright 2010 Joshua Ismael Haase Hernández, Joseph Graham
# ---------- GNU General Public License 3 ----------
-
-# This file is part of Parabola.
-
-# Parabola is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# Parabola is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-source /etc/libretools.conf
-[[ -f $XDG_CONFIG_HOME/libretools/libretools.conf ]] && \
- source $XDG_CONFIG_HOME/libretools/libretools.conf
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
-mkdir -p $XDG_CONFIG_HOME/libretools
-pushd $XDG_CONFIG_HOME/libretools/ >/dev/null
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
-# This is the exit status.
-ev=0
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-# Check if the blacklist variable is empty, and if so error.
-[[ ${#BLACKLIST} -eq 0 ]] && {
- error "BLACKLIST variable is not set your libretools.conf file"
- exit 1
+function in_array { # usage : in_array( $needle, $haystack )
+
+ [[ $2 ]] || return 1 # Not found
+ local needle=$1; shift
+ local item
+ for item in "$@"; do
+ [[ ${item#@} = $needle ]] && return 0 # Found
+ done
+ return 1 # Not Found
}
-# Download the blacklist.
-msg "Downloading the blacklist of proprietary software packages."
-wget -N -q -O blacklist.txt "${BLACKLIST}" 2>/dev/null || {
- [ -e $XDG_CONFIG_HOME/libretools/blacklist.txt ] || {
- error "Download failed, exiting"
- exit 1
- }
- warning "Using local copy of blacklist"
+
+function get_blacklist { # Download the blacklist.
+
+ msg "Downloading the blacklist of proprietary software packages."
+ wget -N -q -O blacklist.txt "${BLACKLIST}" 2>/dev/null || {
+ [ -e $XDG_CONFIG_HOME/libretools/blacklist.txt ] || {
+ error "Download failed, exiting"
+ exit 1
+ }
+ warning "Using local copy of blacklist"
}
-# Get everything before the `:' in the blacklist (that's the names of the
-# packages).
-unfree=($(cut -d: -f1 blacklist.txt))
-freerep=($(cut -d: -f2 blacklist.txt))
-
-popd >/dev/null
-
-source /etc/rc.d/functions # We want the `in_array' function.
-source ./PKGBUILD
-
-# The following piece of code will check whether a package is, or depends on;
-# any non free package(s).
-
-# The `pkgname', `depends', `makedepends' arrays have been sourced from
-# ./PKGBUILD.
-msg "Looking for unfree dependencies"
-for item in ${pkgname[@]} ${depends[@]} ${makedepends[@]} ; do
-# We cycle through all of the programs in the array (if any), and check if
-# they are in the `unfree' array.
- if in_array $item ${unfree[@]} ; then
-# If the package has a replacement of the same name, skip
- if in_array $item ${freerep[@]} ; then
- warning "$item is repackaged with the same name."
- ev=0
- continue
-# if item has a free replacement, use error 16.
- elif in_array $item-libre ${freerep[@]} ; then
- warning "$item -> $item-libre"
- ev=16
- else
- ev=15
- msg2 "found $item"
+function check_deps { # Check wheter a package depends on non-free
+
+ pushd $XDG_CONFIG_HOME/libretools/ >/dev/null
+ local unfree=($(cut -d: -f1 blacklist.txt)) # pkgname:free-replacement:comments
+ local freerep=($(cut -d: -f2 blacklist.txt)) # pkgname:free-replacement:comments
+ popd >/dev/null
+
+ msg "Looking for unfree dependencies"
+ for item in ${pkgname[@]} ${depends[@]} ${makedepends[@]} ; do
+
+ if in_array $item ${unfree[@]} ; then
+
+ if in_array $item ${freerep[@]} ; then
+ warning "$item is repackaged with the same name."
+ continue
+
+ elif in_array $item-libre ${freerep[@]} ; then
+ warning "$item -> $item-libre"
+ continue
+ else
+ ev=15
+ msg2 "found $item"
+ fi
fi
- fi
-done
+ done
+}
+
+source /etc/libretools.conf
+
+if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors
+ error "There's no XDG_CONFIG_HOME var set"; exit 1
+elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then
+ source $XDG_CONFIG_HOME/libretools/libretools.conf
+fi
+
+if [ -z "${BLACKLIST}" ]; then
+ error "BLACKLIST variable is not set your libretools.conf file"; exit 1
+fi
+
+if [ -r PKGBUILD ]; then
+ source PKGBUILD
+else
+ error "There is no PKGBUILD in dir"; exit 1
+fi
+
+if [ ! -d "$XDG_CONFIG_HOME/libretools" ]; then
+ mkdir -p $XDG_CONFIG_HOME/libretools
+fi
+
+get_blacklist
+
+check_deps
exit $ev
diff --git a/prfullpkg b/prtools/prfullpkg
index 2ec9661..e3a022b 100755
--- a/prfullpkg
+++ b/prtools/prfullpkg
@@ -1,26 +1,23 @@
#!/bin/bash
-# TO TEST: (on find_deps)
-# * Detect pkgnames by provides, replaces, etc. instead of dir tree
source /etc/makepkg.conf
source /etc/abs.conf
source /etc/libretools.conf
source /etc/libretools.d/prtools.conf
-# Avoid /libretools dir doesn't exist errors
-if [ -z $XDG_CONFIG_HOME ]; then
- error "There's no XDG_CONFIG_HOME var set"
- exit 1
-fi
-# set ban_file
-[ -e $XDG_CONFIG_HOME/libretools/libretools.conf ] && \
- source $XDG_CONFIG_HOME/libretools/libretools.conf
-ban_file=$XDG_CONFIG_HOME/libretools/ban
+if [ -z $XDG_CONFIG_HOME ]; then # Avoid /libretools dir doesn't exist errors
+
+ error "There's no XDG_CONFIG_HOME var set"; exit 1
+
+elif [ -e $XDG_CONFIG_HOME/libretools/libretools.conf ]; then
+
+ source $XDG_CONFIG_HOME/libretools/libretools.conf
+fi
-##### START FUNCTIONS #####
function usage {
+
echo "cd to a dir containing a PKGBUILD and run:"
echo "$0 [options]"
printf "This script will check dependencies, build them if possible "
@@ -35,131 +32,136 @@ function usage {
echo " -n : don't update pacman db."
echo " -m max_level : check deps until this level"
echo " -r \"command\" : use this instead of \"$FULLBUILDCMD\""
-# echo " -t : build from testing"
echo
exit 1
-}
+}
-## Build order management ##
-
-# Removes a package from the buildorder
+function remove_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}
+
}
-# Guesses the repo name according to the parent dir of the current package
-# assuming the form ${ABSROOT}/package/repo/PKGBUILD
-guess_repo() {
+function guess_repo { # Get repo name. Asumes ${ABSROOT}/package/repo/PKGBUILD
+
basename $(pwd)
+
}
-##
-# usage : get_full_version( $epoch, $pkgver, $pkgrel )
-# return : full version spec, including epoch (if necessary), pkgver, pkgrel
-##
-get_full_version() {
+function get_fullver { # return : full version spec, including epoch (if necessary), pkgver, pkgrel
+
+# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel )
+
if [[ $1 -eq 0 ]]; then
# zero epoch case, don't include it in version
echo $2-$3
else
echo $1:$2-$3
fi
+
}
-# Usage: cleanup [ $(basename $PWD) ] from PKGBUILD dir
-# cleans the build_dir
-function cleanup {
-# Do nothing OR
-# Already cleaned
- [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0
+function cleanup { # Cleans the build_dir.
+
+ [[ "${do_cleanup}" = "n" || ! -d ${build_dir} ]] && return 0 # Do nothing or already cleaned.
-# Only do cleanup on level 0
msg "Cleaning up..."
- [ $level -eq 0 ] && rm -rf $build_dir/*
+ [ $level -eq 0 ] && rm -rf $build_dir/* # Only do cleanup on level 0.
+
}
-# Check PKGBUILD and find non built or outdated deps
-# on ABSROOT which should be abslibre-misp64el
-function find_deps {
- ## Check this level.
- source PKGBUILD
+function find_deps { # Checks ABSROOT and look for target pkg deps. Adds them if not built or outdated.
+
+ source PKGBUILD ## Check this level.
+
local repo=${repo:-$(guess_repo)}
local pkgbase=${pkgbase:-${pkgname[0]}}
local epoch=${epoch:-0}
- local fullver=$(get_full_version ${epoch} ${pkgver} ${pkgrel})
+ local fullver=$(get_fullver ${epoch} ${pkgver} ${pkgrel})
-# If package and correct ${fullver} is built exit
if is_built "${pkgbase}>=${fullver}"; then
- exit 0
+ exit 0 # pkg is built and updated
fi
-# Tell which packages are deeper in deps (even if they are on build_dir)
-# so we can build them first.
- echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER"
+ echo "${level}:${pkgbase}" >> "${build_dir}/BUILDORDER" # greater levels are built first
+
+ if [ -d "${build_dir}/${pkgbase}" ]; then # PKGBUILD is already there
-# if pkgbuild directory is on build_dir, do not copy and exit
- if [ -d "${build_dir}/${pkgbase}" ]; then
exit 0
- else
-# Copy dir to build_dir
+
+ else # Copy dir to build_dir
+
mkdir ${build_dir}/${pkgbase}
cp -r $(pwd)/* ${build_dir}/${pkgbase}
-# Info to eval later
- echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO"
+
+ echo "repo=$repo" > "${build_dir}/${pkgbase}/.INFO" # to identify repo later
fi
-
-# Inform the current package plus a space for every level for indent
- msg2 "%${level}s${pkgbase}-${fullver}"
-## Check next levels
-# Clean version checking
+ msg2 "%${level}s${pkgbase}-${fullver}" # current package plus a space for every level
+
+ declare -i next_level=$level+1 ## Check next deps level.
+
deps=$(echo "${depends[@]} ${makedepends[@]}" | \
sed "s/[=<>]\+[^ ]\+//g" | \
tr ' ' "\n" | \
- sort -u)
+ sort -u) # All deps in separate line, only once, without version.
- # Increase build level
- declare -i next_level=$level+1
-
for _dep in ${deps[@]}; do
- if [ -d "${ABSROOT}/${_dep}" ]; then
- # search in REPOS array order
- for _repo in ${REPOS[@]}; do
+
+ local found=false
+
+ if [ -d "${ABSROOT}/${_dep}" ]; then # ABSROOT/package/repo
+
+ for _repo in ${REPOS[@]}; do # Use PKGBUILD from repo in REPOS array order
+
if [ -e "${ABSROOT}/${_dep}/${_repo}/PKGBUILD" ]; then
pushd "${ABSROOT}/${_dep}/${_repo}" > /dev/null
- $0 -c -d ${build_dir} -l ${next_level}
- [ $? -eq 20 ] && return 20 # probable circular deps
+ $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
- break 1 # found, go to next dep
-
+ local found=true
+ break 1 # found, go to next dep
fi
+
done
- else # pkgsplit, needs guess
+ else # pkgsplit, needs guess
for _repo in ${REPOS[@]}; do
+
if _dir=($(find "$ABSROOT/" -type f \
-wholename "*/${_repo}/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}
- [ $? -eq 20 ] && return 20 # probable circular dep
+ $0 -c -d ${build_dir} -l ${next_level} # run this cmd on dep's PKGBUILD dir
+ [ $? -eq 20 ] && return 20 # probable circular dep
popd > /dev/null
+ local found=true
break 1 # found, go to next dep
fi
+
done
+
fi
+
+ if ( ${found} ); then
+ continue 1 # go to next dep
+ else
+ echo "dep_not_found:$_dep" >> $build_dir/log
+ fi
+
done
unset next_level dir
@@ -169,67 +171,63 @@ function find_deps {
options install changelog source noextract md5sums build check package
}
-function _pkg_build () {
+function __build () {
pushd ${build_dir} > /dev/null
- # packages to build are on $buildorder
- # greater levels must be built first
- build_packages=($(sort -gr $buildorder | cut -d: -f2))
+
+ build_packages=($(sort -gr $buildorder | cut -d: -f2)) # greater levels must be built first
while [ ${#build_packages[@]} -ge 1 ]; do
pushd $build_dir/${build_packages[0]} > /dev/null
- source PKGBUILD
+ source PKGBUILD
msg2 "${pkgbase:-${pkgname[0]}} $pkgver-$pkgrel"
msg2 "Checking for non free deps"
pkgbuild-check-nonfree || {
if [ $? -eq 15 ]; then # this error means nonfree others means fail.
-# log they have nonfree deps and so didn't build
+
echo "nonfree:$(basename $PWD)" >> $build_dir/log
-# take out package from $buildorder
- remove_buildorder "$(basename $PWD)" $buildorder
-# continue building next package
- continue
+
+ remove_buildorder "$(basename $PWD)" $buildorder # take out package from $buildorder
+
+ continue # build next package
fi
}
msg2 "Building $(basename $PWD)"
-# this buildcmd is on libretools.conf
- $FULLBUILDCMD; r=$?
+
+ $FULLBUILDCMD; r=$? # this buildcmd is on libretools.conf
+
case $r in
-###### Succesfull Build ######
- 0)
+
+ 0) ## Succesfull build
+
plain "The build was succesful."
- source .INFO && [ -n $repo ] && {
+ if source .INFO && [ -n $repo ]; then
-# Calls a local release script if it's used
- [ -z $HOOKLOCALRELEASE ] || \
- find -name "*.pkg.tar.?z" -print0 | \
- xargs -0 $HOOKLOCALRELEASE $repo
+ if [ ! -z $HOOKLOCALRELEASE ]; then # Calls a local release script if it's used
+ find -name "*.pkg.tar.?z" -print0 | xargs -0 $HOOKLOCALRELEASE $repo
+ fi
-# Stage for releasing
- 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
;;
-###### Failed Build ######
- *)
- error "There were errors while trying to build the package."
+
+ *) ## Build failed
+ error "There were errors while trying to build the package."
echo "failed:$(basename $PWD)" >> $build_dir/log
;;
esac
-# Package was built or failed: take it out of $buildorder
remove_buildorder "${build_packages[0]}" $buildorder || true
-# Set build_packages before next cycle run
- build_packages=($(sort -gr $buildorder | cut -d: -f2))
+ build_packages=($(sort -gr $buildorder | cut -d: -f2)) # which is next package?
popd > /dev/null
done
@@ -256,8 +254,7 @@ function _pkg_build () {
popd > /dev/null
}
-# End inmediately but print a useful message
-trap_exit() {
+function trap_exit { # End inmediately but print a useful message
error "$@"
warning "Leftover files left on $build_dir"
@@ -265,43 +262,37 @@ trap_exit() {
exit 1
}
-## END FUNCTIONS ##
-
-## Trap signals
-# From makepkg
+# Trap signals from makepkg
set -E
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
+trap 'trap_exit "(prfullpkg:${level}) TERM signal caught. Exiting..."' TERM HUP QUIT
+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='n'
build_only='n'
check_deps_only='n'
-do_cleanup='n'
max_level=21
-OFFLINE=false
-while getopts 'ha:b:cCd:l:nm:r:' arg; do
+
+while getopts 'ha:b:cd:l:nm:r:' arg; do
case $arg in
h) usage ;;
a) ABSROOT="$OPTARG" ;;
- b) build_only='y'
+ b) build_only='y'
build_dir="$OPTARG"
- [ -z ${build_dir} ] && {
+ if [ -z ${build_dir} ]; then
usage
- }
- [ ! -r ${build_dir}/BUILDORDER ] && {
+ fi
+ if [ ! -r ${build_dir}/BUILDORDER ] ; then
error "${build_dir}/BUILDORDER doesn't exist."
exit 1
- };;
+ fi;;
c) check_deps_only='y' ;;
- C) do_cleanup='y';;
d) build_dir="$OPTARG" ;;
-# hidden option to know what to build first.
-# if $level > 0 it will not build
- l) level=$OPTARG ;;
+ l) level=$OPTARG ;; # hidden option to know dep level.
n) noupdate='y';;
m) max_level=$OPTARG ;;
r) FULLBUILDCMD="$OPTARG" ;;
@@ -310,92 +301,95 @@ done
if [ ${build_only} == 'n' ]; then
-# Check if we are actually on a build directory
-# Do this early
-
- [ ! -r PKGBUILD ] && {
+ [ ! -r PKGBUILD ] && { # Check if we are actually on a build directory. Do this early.
error "This isn't a build directory"
usage
}
-
- # Add mips64el if missing from arch=() and it isn't an 'any' package
- if ! grep mips64el PKGBUILD >/dev/null; then
- warning "Adding mips64el arch"
- sed -i "s/^\(arch=([^)anym]\+\))/\1 'mips64el')/" "PKGBUILD"
+
+ if [ ! -z "$HOOKPKGBUILDMOD" ]; then
+ "$HOOKPKGBUILDMOD"
fi
fi
-# Only on level 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)}
- mkdir -p ${build_dir} # in case of -d option
- # make files for log and buildorder
- touch ${build_dir}/{log,BUILDORDER}
+ build_dir=${build_dir:-$(mktemp -d /tmp/fullpkg.XXXXXX)} # use -d option or else mktemp
+
+ if [ ! -d ${build_dir} ]; then # in case of custom -d option
+ mkdir -p ${build_dir}
+ else
+ cleanup # files already there can screw find_deps
+ fi
+
+ touch ${build_dir}/{log,BUILDORDER} ${ban_file} # make files for log and buildorder
buildorder=${build_dir}/BUILDORDER
- [ ${noupdate} = 'n' ] && {
+ if [ ${noupdate} = 'n' ]; then
+
msg "Updating pacman db and packages"
sudo pacman -Syu --noconfirm || true
- }
-# Build only
- [ ${build_only} == 'y' ] && {
+ fi
+
+ if [ ${build_only} == 'y' ]; then
+
msg "Build Packages"
- _pkg_build
+
+ __build
+
exit 0
- }
+
+ fi
msg "Checking dependencies"
fi
-## if $level = 20 it's highly likely there are circular deps
-[ $level -ge $max_level ] && exit 20
+[ $level -ge $max_level ] && exit 20 # Probable circular deps
-# Tries to find deps and build order
-find_deps || {
- # if find_deps finds circular deps
- # it should exit with status 20
- [ $? -eq 20 ] && {
- # only show message on level 0
- [ $level -eq 0 ] && error "Check for circular deps on $build_dir/BUILDORDER";
- }
- exit 20
+find_deps || {
+
+ if [ $? -eq 20 ]; then # Probable circular deps
+
+ if [ $level -eq 0 ]; then # Show error only on level 0
+ error "Check for circular deps on $build_dir/BUILDORDER";
+ fi
+
+ fi
+ exit 20 # Pass message 20
}
-# levels greater than 0 must only check deps
-[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0
+[ $check_deps_only = 'y' -o $level -gt 0 ] && exit 0 # only build on level 0
+
+if [ $level -eq 0 -a -d $build_dir ]; then # Sanity check
+
+ if [ ! -w $ban_file -o ! -r $ban_file ]; then # Check ban_file permisions
-# check BUILDORDER to not include banned deps and
-[ $level -eq 0 -a -d $build_dir ] && {
-# 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)"
+ chmod a+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} ] && {
-# Use local copy of ban file if it is avaliable and continue.
+ warning "Failed to get ban list" && [ -r ${ban_file} ] && { # use local copy if it exist
+
search=$(cat ${ban_file} | tr "\n" "|")
-# Keep track of banned files
- egrep -w "$search" ${buildorder} >> ${build_dir}/banned
-# Take banned packages out from buildorder
- egrep -vw "$search" ${buildorder} > ${buildorder}2
+
+ egrep -w "$search" ${buildorder} >> ${build_dir}/banned # Keep track of banned files
+
+ egrep -vw "$search" ${buildorder} > ${buildorder}2 # Take banned packages out of buildorder
+
mv -f ${buildorder}2 ${buildorder}
+
unset search
}
}
fi
-}
+fi
-## START Building
msg "Building packages:"
-# Build the package
-_pkg_build
+__build # Build the packages
echo
msg2 "Check if your system works fine and librerelease if it does"
diff --git a/prmipsrelease b/prtools/prmipsrelease
index 29da6e0..1fbd696 100755
--- a/prmipsrelease
+++ b/prtools/prmipsrelease
@@ -1,4 +1,4 @@
- #!/bin/bash
+#!/bin/bash
# Lic: GPLv3+
# Author: Nicolas Reynolds <fauno@kiwwwi.com.ar>
# Local release of mips64el packages + clean ABS sync
@@ -32,12 +32,12 @@
}
repo=$1; shift
- repo-add ${PKGDEST}/stage3.db.tar.gz $@
+ repo-add "${PKGDEST}/stage3.db.tar.gz" $@
# Get all needed sources
source PKGBUILD
fullver=$(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})
- pkgbase=${pkgbase:-$pkgname[0]}
+ pkgbase=${pkgbase:-$pkgname}
msg "Adding packages to [stage3]..."
repo-add $@
@@ -51,10 +51,9 @@
msg "Adding clean source to $WORKDIR/abs/${CARCH}/$repo/$pkgbase"
dest_dir="$WORKDIR/abs/${CARCH}/$repo/$pkgbase"
mkdir -p ${dest_dir} >/dev/null
- rm -rf ${dest_dir}/* #if package existed already there
+ rm -rf ${dest_dir}/* # if package existed already there
-# Set target CARCH as it might be used within the PKGBUILD to select correct sources
- eval $(grep '^CARCH=' "$copydir/etc/makepkg.conf")
+ eval $(grep '^CARCH=' "$copydir/etc/makepkg.conf") # CARCH might be used in PKGBUILD to select sources.
export CARCH
source=($(. "PKGBUILD"; echo ${source[@]}))
cp --remove-destination "PKGBUILD" "${dest_dir}" || echo "copy 1"
@@ -90,8 +89,7 @@
git add "${dest_dir}/." # add using .gitignore
- git commit -m "${pkgbase}-${fullver} ${repo}" >/dev/null && \
- msg2 "${pkgbase} ${fullver} ${repo}"
+ git commit -m "${pkgbase}-${fullver} ${repo}" >/dev/null && msg2 "${pkgbase} ${fullver} ${repo}"
popd >/dev/null
diff --git a/prtools.conf b/prtools/prtools.conf
index 5b41216..5b41216 100644
--- a/prtools.conf
+++ b/prtools/prtools.conf
diff --git a/prtools/prtoru b/prtools/prtoru
new file mode 100644
index 0000000..2898b66
--- /dev/null
+++ b/prtools/prtoru
@@ -0,0 +1,173 @@
+#!/bin/bash
+# Queries the ABS
+# License: GPL3
+
+## TODO
+# * Add license text
+# * Create symlinks from pkgbase to pkgname[@] for easy package finding
+# * Use lastsync to store processed packages
+
+## GOALS
+# * Have a searchable database of PKGBUILD metadata
+# * Have an interface for source-only builds
+# * Possibility to hook up ABS dirs besides ABSROOT (low priority)
+# * Tell updates and non available binary packages (working on this)
+
+source /etc/abs.conf
+source /etc/libretools.conf
+source /etc/libretools.d/prtools.conf
+
+# Stores the lastsync date
+lastsync() {
+ [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && {
+ error "The sync date can't be saved. ${lastsyncfile} isn't writable."
+ return 1
+ }
+
+ date +%s > "$lastsyncfile"
+ touch "$lastsyncfile"
+}
+
+##
+# usage : get_full_version( $epoch, $pkgver, $pkgrel )
+# return : full version spec, including epoch (if necessary), pkgver, pkgrel
+##
+get_full_version() {
+ if [[ $1 -eq 0 ]]; then
+ # zero epoch case, don't include it in version
+ echo $2-$3
+ else
+ echo $1:$2-$3
+ fi
+}
+
+# Outputs an ordered package-fullpkgver array
+print_package_array() {
+ echo "$@" | tr " " "\n" | sort -V -u
+}
+
+
+# Gets repo.db contents
+# $1 repo
+get_db_contents() {
+ [ ! -r /var/lib/pacman/sync/$1.db ] && return 0
+
+ bsdtar -tf /var/lib/pacman/sync/$1.db | \
+ cut -d'/' -f1 | \
+ sort -V -u
+}
+
+
+extract_pkgname() {
+ echo "$@" | tr " " "\n" | sed "s/^\(.\+\)-[^-]\+-[^-]\+$/\1/"
+}
+
+extract_fullpkgver() {
+ echo "$@" | tr " " "\n" | sed "s/^.\+-\([^-]\+-[^-]\+\)$/\1/"
+}
+
+
+# Updates the database by finding all PKGBUILDS
+# Workflow:
+# * Find all PKGBUILDs on the ABS repo specified
+# * Get all packages already on package repos
+# * Compare them
+# Args:
+update() {
+# The PKGBUILDs found
+ local pkgbuilds=()
+# The list of pkgname-fullpkgver
+ local packages_to_sync=()
+ local packages_in_sync=()
+ local needed_updates=()
+ local old_versions=()
+
+# Find all the PKGBUILDs newer than the last update
+# Update newer, otherwise everything
+ if [ $force ] || [ ! -e ${lastsyncfile} ]; then
+ $quiet || msg "Forcing upgrade"
+ pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD'))
+ else
+ pkgbuilds=($(find ${@} -maxdepth 2 -type f -name 'PKGBUILD' -newer ${lastsyncfile}))
+ fi
+
+# Inform how many PKGBUILDS were found and quit immediately if none
+ $quiet || msg "Found $((${#pkgbuilds[*]}-1)) packages to update"
+ [ ${#pkgbuilds[*]} -eq 1 ] && {
+ $quiet || msg2 "There's nothing to be done. Phew!"
+ exit 0
+ }
+
+ for _pkgbuild in ${pkgbuilds[@]}; do
+
+# The repo name is guessed
+# You *must* use repo/pkgbase structure
+ _pkgpath=$(dirname "${_pkgbuild}")
+ _pkgbase=$(basename "${_pkgpath}")
+ _pkgrepo=$(basename $(dirname "${_pkgpath}"))
+
+ source ${_pkgbuild}
+
+ for _pkg in ${pkgname[@]}; do
+# Fill the list of packages to find
+ packages_to_sync+=($_pkg-$(get_full_version ${epoch:-0} $pkgver $pkgrel))
+ done
+
+ unset pkgbase pkgname pkgver pkgrel source epoch
+ done
+
+# Get repo database contents
+ packages_in_sync=($(get_db_contents ${_pkgrepo}))
+ print_package_array "${packages_to_sync[@]}" > ${TMPDIR}/packages_to_sync
+ print_package_array "${packages_in_sync[@]}" > ${TMPDIR}/packages_in_sync
+
+# We've orderer the files!
+ needed_updates=($(comm --nocheck-order -32 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync))
+ old_versions=($(comm --nocheck-order -31 ${TMPDIR}/packages_to_sync ${TMPDIR}/packages_in_sync))
+
+ $quiet || msg "This packages are available to update"
+ for _update in ${needed_updates[@]}; do
+ pkg=$(extract_pkgname $_update)
+
+ $quiet && echo $pkg
+ $quiet || {
+ ver=$(extract_fullpkgver $_update)
+ oldver=$(extract_fullpkgver $(grep -w $pkg ${TMPDIR}/packages_in_sync))
+
+ msg2 "$pkg $oldver => $ver"
+ }
+
+ done
+
+# lastsync
+
+}
+
+## MAIN
+commands=()
+repos=()
+quiet=false
+force=false
+while getopts 'hqfu' arg; do
+ case $arg in
+ h) usage; exit 0 ;;
+ q) quiet=true ;;
+ f) force=true ;;
+ u) commands+=(update);;
+ esac
+
+ shift $((OPTIND-1))
+done
+
+# This is the syncfile, stores the last date as content and mtime
+lastsyncfile=${ABSROOT}/toru.lastsync
+
+TMPDIR=$(mktemp -d)
+
+[[ -z ${TMPDIR} ]] && exit 1
+
+${commands[0]} ${@}
+
+rm -rf ${TMPDIR}
+
+exit $?
diff --git a/rePKGBUILD.proto b/rePKGBUILD.proto
index ef3f037..c8b19bf 100644
--- a/rePKGBUILD.proto
+++ b/rePKGBUILD.proto
@@ -6,10 +6,11 @@
# Maintainer: Your Name <youremail@domain.com>
source PKGBUILD
unset build package md5sums source
-_repo= # Put the repo here
+_repo= # Put the repo here
+_mirror=http://mirrors.kernel.org/archlinux # Put mirror here
source=(PKGBUILD
- http://mirrors.kernel.org/archlinux/${_repo}/os/${CARCH}/${pkgname%-libre}-$pkgver-$pkgrel-$CARCH$PKGEXT
- # files for pkg modifications
+ "${_mirror}/${_repo}/os/${CARCH}/${pkgname%-libre}-$pkgver-$pkgrel-$CARCH$PKGEXT"
+ # files for pkg modifications below this line
)
build() {
diff --git a/toru b/toru
index e211878..94cd220 100755
--- a/toru
+++ b/toru
@@ -1,4 +1,4 @@
- #!/bin/bash
+#!/bin/bash
# Queries the ABS
# License: GPL3
@@ -16,12 +16,6 @@
source /etc/abs.conf
source /etc/libretools.conf
-#[ ! -w / ] && {
-# error "This script must be run as root."
-# exit 1
-#}
-
-
# Stores the lastsync date
lastsync() {
[ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && {
@@ -46,7 +40,7 @@
fi
}
-# Outputs an ordered package-fullpkgver array
+# Outputs an ordered package-fullpkgver array
print_package_array() {
echo "$@" | tr " " "\n" | sort -V -u
}