summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Ismael Haase Hernández <hahj87@gmail.com>2012-01-22 23:06:56 -0600
committerJoshua Ismael Haase Hernández <hahj87@gmail.com>2012-01-22 23:06:56 -0600
commit7a00f2a55b69c39ae8ebad99b3d91a509b614b1b (patch)
tree7ca94ca289c069374cac149545a86234270d8fe6
parent825ac89cfa857e4379e9e1baf6d470cf9e583dde (diff)
parent0985429b68d8da1016bf4a84b2a2d32fb8c3027c (diff)
Merge branch 'master' of gitpar:libretools
-rwxr-xr-xbuildenv28
-rwxr-xr-xchcleanup7
-rw-r--r--fullpkg-find9
-rwxr-xr-xtoru27
-rwxr-xr-xtoru-path32
-rwxr-xr-xtoru-utils86
6 files changed, 166 insertions, 23 deletions
diff --git a/buildenv b/buildenv
new file mode 100755
index 0000000..84a1fc2
--- /dev/null
+++ b/buildenv
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+trap "umount_all" 0 ERR TERM KILL
+
+user=${SUDO_USER:-${1}}
+
+umount_all() {
+ for mp in home/pkgdest home/srcdest home/${user}; do
+ msg "Umounting /$mp"
+ umount $CHROOTDIR/$CHROOT/$mp || error "Couldn't umount"
+ done
+}
+
+source /etc/libretools.conf
+
+for mp in home/pkgdest home/srcdest home/${user} var/lib/toru; do
+ msg "Binding /$mp"
+ mount -o bind /$mp $CHROOTDIR/$CHROOT/$mp || exit 1
+done
+
+for etc in etc/makepkg.conf etc/abs.conf etc/mtab; do
+ msg "Copying config /$etc"
+ cp --remove-destination /$etc $CHROOTDIR/$CHROOT/$etc || exit 1
+done
+
+$(dirname $0)/librechroot $CHROOT
+
+exit $?
diff --git a/chcleanup b/chcleanup
new file mode 100755
index 0000000..83c9f3f
--- /dev/null
+++ b/chcleanup
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+[ ! -f ~/cleansystem ] && exit 1
+
+sudo pacman --noconfirm -Rcs $(comm -23 <(pacman -Qq | sort) <(sort ~/cleansystem))
+
+exit $?
diff --git a/fullpkg-find b/fullpkg-find
index 25565ae..d253913 100644
--- a/fullpkg-find
+++ b/fullpkg-find
@@ -11,6 +11,14 @@ guess_repo() {
basename $(dirname $(pwd))
}
+# 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() {
+ grep -m1 "^${1}:" "${TORUPATH}/paths" 2>/dev/null| \
+ cut -d: -f2 2>/dev/null
+}
+
# return : full version spec, including epoch (if necessary), pkgver, pkgrel
# usage : get_fullver( ${epoch:-0}, $pkgver, $pkgrel )
get_fullver() {
@@ -71,6 +79,7 @@ find_deps() {
for _dep in ${deps[@]}; do
local found=false
+# TODO change for where_is or toru-path
local pkgdir=$(toru -p ${_dep})
if [ -n "$pkgdir" -a -d "${pkgdir}" ]; then
diff --git a/toru b/toru
index 5867bfe..9616119 100755
--- a/toru
+++ b/toru
@@ -12,28 +12,7 @@
# * 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
-
-if [ ! -w "$TORUPATH" ]; then
- error "Toru's path isn't writable. Please check $TORUPATH"
- exit 1
-fi
-
-# Stores the lastsync date
-lastsync() {
- local lastsyncfile
-
- lastsyncfile=$1
-
- [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && {
- error "The sync date can't be saved. ${lastsyncfile} isn't writable."
- return 1
- }
-
- date +%s > ${lastsyncfile}
- touch ${lastsyncfile}
-}
+source $(dirname $0)/toru-utils
# Saves contents on a named cache
# $1 cache name (repo)
@@ -252,7 +231,9 @@ update() {
# See above FIXME
# print_package_array "${updates[@]}" > ${TMPDIR}/updates
- store_cache ${_repo}.updates ${TMPDIR}/updates
+ if [ -r ${TMPDIR}/updates ]; then
+ store_cache ${_repo}.updates ${TMPDIR}/updates
+ fi
else
$quiet || msg "Reading updates from cache..."
diff --git a/toru-path b/toru-path
new file mode 100755
index 0000000..7500aed
--- /dev/null
+++ b/toru-path
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+source $(dirname $0)/toru-utils
+
+LASTSYNCFILE=${TORUPATH}/lastsync.paths
+
+# TODO pass other paths via flags
+pkgbuilds=($(get_pkgbuilds ${ABSROOT}))
+paths=()
+
+msg "Updating path cache"
+msg2 "${#pkgbuilds[@]} PKGBUILDs to update"
+for _pkgbuild in ${pkgbuilds[@]}; do
+ $DEBUG && plain "$_pkgbuild"
+ source ${_pkgbuild} || {
+ error "${_pkgbuild} contains errors, skipping"
+ continue
+ }
+
+ fullpath=$(dirname $(readlink -f ${_pkgbuild}))
+
+ for _pkg in ${pkgname[@]} ${provides[@]}; do
+ paths+=(${_pkg/[<>=]*}:${fullpath})
+ done
+
+ unset pkgname provides
+done
+
+# TODO remove old paths
+echo ${paths[@]} | tr ' ' "\n" | sort >> ${TORUPATH}/paths
+
+lastsync ${LASTSYNCFILE}
diff --git a/toru-utils b/toru-utils
new file mode 100755
index 0000000..bb0aef4
--- /dev/null
+++ b/toru-utils
@@ -0,0 +1,86 @@
+#!/bin/bash
+#!/bin/bash
+
+
+source /etc/abs.conf
+source /etc/libretools.conf
+
+if [ ! -w "$TORUPATH" ]; then
+ error "Toru's path isn't writable. Please check $TORUPATH"
+ exit 1
+fi
+
+LASTSYNCFILE=${TORUPATH}/lastsync
+FORCE=false
+QUIET=false
+DEBUG=false
+
+# usage : in_array( $needle, $haystack )
+function in_array {
+ [[ $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
+}
+
+# Stores the lastsync date
+lastsync() {
+ local lastsyncfile
+
+ lastsyncfile=$1
+
+ [ -e ${lastsyncfile} -a ! -w ${lastsyncfile} ] && {
+ error "The sync date can't be saved. ${lastsyncfile} isn't writable."
+ return 1
+ }
+
+ date +%s > ${lastsyncfile}
+ touch ${lastsyncfile}
+}
+
+get_dbs() {
+ local _db
+ for _db in /var/lib/pacman/sync/*.db; do
+ bsdtar tf ${_db} | cut -d'/' -f1 | sort -u
+ done
+}
+
+# repo paths
+get_pkgbuilds() {
+ pkgbuilds=()
+
+ if [[ $FORCE = true || ! -e ${LASTSYNCFILE} ]]; then
+
+ $QUIET || warning "Forcing upgrade"
+# Get all PKGBUILDs
+ pkgbuilds=($(find $@ -mindepth 2 -maxdepth 3 -type f -name 'PKGBUILD'))
+
+ else
+
+# Only find newer than lastsyncfile and read everything else from cache
+ pkgbuilds=($(find $@ -mindepth 2 -maxdepth 3 -type f -name 'PKGBUILD' -newer ${LASTSYNCFILE}))
+
+ fi
+
+# Return all PKGBUILDs found
+ echo ${pkgbuilds[@]}
+}
+
+# End inmediately but print a useful message
+trap_exit() {
+ error "$@"
+
+ exit 1
+}
+
+# Trap signals from makepkg
+set -E
+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