summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lbu115
1 files changed, 8 insertions, 107 deletions
diff --git a/lbu b/lbu
index 72e8a7a..1af9add 100644
--- a/lbu
+++ b/lbu
@@ -4,31 +4,18 @@
# Copyright (c) 2006 Natanael Copa
# May be distributed under GPL2
-PREFIX=
-. $PREFIX/lib/libalpine.sh
-# this one is from apk-tools
-. $PREFIX/lib/apk/libutil.sh
-
VERSION=1.2
-[ "$SFIC" ] && SFIC="$SFIC -i d"
-# globals
-[ -z "$LBU_DBDIR" ] && LBU_DBDIR="${APK_DATA:-$ROOT/var/lib/apk}"
-CURRENT_TDB="$LBU_DBDIR/current.tdb"
-TMPCURRENT_TDB="$LBU_DBDIR/tmp-current.tdb"
-COMMITED_TDB="$LBU_DBDIR/commited.tdb"
+if [ ! -f ${libalpine:="./libalpine.sh"} ]; then
+ libalpine=/usr/share/lbu/libalpine.sh
+fi
+. $libalpine || exit 1
EXCLUDE_LIST=/etc/lbu/exclude
INCLUDE_LIST=/etc/lbu/include
-PACKAGES_LIST=/etc/lbu/packages.list
-
DEFAULT_CIPHER="aes-256-cbc"
-MASK="Npugsh"
-
-LBUDIRS=`echo "$APK_LBUDIRS" | sed 's/:/ /g'`
-
LBU_CONF=/etc/lbu/lbu.conf
if [ -f "$LBU_CONF" ]; then
. "$LBU_CONF"
@@ -47,7 +34,6 @@ Available subcommands:
list (ls)
package (pkg)
status (stat, st)
- update (up)
list-backup (lb)
revert
@@ -61,8 +47,6 @@ Common options:
cleanup() {
local i
- rm -f "$CURRENT_TDB"
- rm -f "$TMPCURRENT_TDB"
for i in $UMOUNT_LIST; do
umount $i
done
@@ -99,14 +83,6 @@ check_openssl() {
|| die "Cipher $ENCRYPTION is not supported"
}
-gen_current_tdb() {
- # generate current tdb
- rm -f "$CURRENT_TDB"
- mkdir -p "$(dirname \"$CURRENT_TDB\")"
- $SFIC -R -t --mask "$MASK" --old "$APK_DEFAULT_TDB" $LBUDIRS \
- | grep -v ^D | awk '{print $2}' | $SFIC --add "$CURRENT_TDB" --file -
-}
-
# list_add(char *listfile, char* file...)
list_add() {
local list="$1"
@@ -228,24 +204,8 @@ cmd_package() {
tmppkg="$tmpdir/$(basename $pkg)"
- # generate the packages.list
- vecho "Generating $PACKAGES_LIST"
- cd "$ROOT"
- mkdir -p $(dirname $PACKAGES_LIST)
- echo "#This file is generated by 'lbu package' (lbu $VERSION)" \
- > $PACKAGES_LIST
- for i in $(apk_glob '*') ; do
- reqby=$(apk_info -qr $i);
- # only add the packages who has no REQUIRED_BY
- [ -z "$reqby" ] && echo $i
- done | sed 's/-[0-9].*//' >> $PACKAGES_LIST
-
- # Automatically add list and modified files
- currentlist=`VERBOSE="" USE_DEFAULT="-a" cmd_status -a | grep -v ^D | awk '{print $2}'`
-
- # we generate a tmpcurrent before we commit to avoid race condition
- rm -f "$CURRENT_TDB"
- $SFIC --add "$CURRENT_TDB" $currentlist
+ cd "${ROOT:-/}"
+ currentlist=$(apk audit --backup -q)
# create tar archive
[ -f "$EXCLUDE_LIST" ] && excl="-X $EXCLUDE_LIST"
@@ -281,8 +241,6 @@ cmd_package() {
fi
fi
vecho "Created $pkg"
- else
- rm -f "$CURRENT_TDB"
fi
return $rc
}
@@ -414,7 +372,6 @@ cmd_commit() {
[ "$media" = "floppy" ] && sleep 1
# move current to commited.
- [ "$DRYRUN" ] || mv "$CURRENT_TDB" "$COMMITED_TDB"
vecho "Successfully saved apk overlay files"
}
@@ -460,7 +417,7 @@ show_exclude() {
}
#---------------------------------------------------------------------------
-# lbu_status - check what files have been changed since last save
+# lbu_listbackup - Show old commits
usage_listbackup() {
cat <<EOF
$PROGRAM $VERSION
@@ -518,68 +475,16 @@ usage_status() {
echo "$PROGRAM $VERSION
Check what files have been changed since last commit.
-usage: $PROGRAM status|st [-M <MASK>] [-av]
+usage: $PROGRAM status|st [-av]
Options:
- -M Use a different mask for comparing. (see sfic -h)
-a Compare all files, not just since last commit.
-v Also show include and exclude lists.
"
exit 1
}
-cmd_status() {
- cd "$ROOT"
-
- [ "$SFIC" ] || die "Need sfic."
- [ -f "$APK_DEFAULT_TDB" ] || die "$APK_DEFAULT_TDB not found."
-
- # genereate temp tdb
- #gen_temp_tdb
-
- if [ -f "$COMMITED_TDB" ] && [ -z "$USE_DEFAULT" ]; then
- # generate current tdb
- gen_current_tdb
- OLD="$COMMITED_TDB"
- NEW="--new $CURRENT_TDB"
- else
- OLD="$APK_DEFAULT_TDB"
- NEW="-R $LBUDIRS"
- fi
- $SFIC $QUIET $VERBOSE --mask "$MASK" -t --old "$OLD" $NEW
- local retcode=$?
-
- if [ "$VERBOSE" ] ; then
- echo ""
- show_include
- echo ""
- show_exclude
- fi
- return $retcode
-}
-
-#------------------------------------------------
-# lbu_update - Update the database wihtout commit to media.
-usage_update() {
- echo "$PROGRAM $VERSION
-Update the commited database without commit to media.
-
-usage: $PROGRAM update|up [-v] <file> ...
-
-Options:
- -v Verbose mode.
-"
- exit 1
-}
-
-cmd_update() {
- [ $# -lt 1 ] && usage_update
- cd "$ROOT"
- for i in "$@" ; do
- echo $i | sed 's:^/::'
- done | lbu_filter | $SFIC $VERBOSE --add "$COMMITED_TDB" --file -
-}
#-----------------------------------------------------------
# Main
@@ -600,7 +505,6 @@ case "$cmd" in
list|ls) SUBCMD="list";;
package|pkg) SUBCMD="package";;
status|stat|st) SUBCMD="status";;
- update|up) SUBCMD="update";;
list-backup|lb) SUBCMD="listbackup";;
revert) SUBCMD="revert";;
*) usage;;
@@ -620,9 +524,6 @@ while getopts "adehlM:np:qrv" opt ; do
;;
l) LIST="-l"
;;
- M) [ $SUBCMD = status ] || usage_$SUBCMD
- MASK="$OPTARG"
- ;;
n) [ $SUBCMD = commit ] || usage_$SUBCMD
DRYRUN="-n"
;;