[go: up one dir, main page]

Menu

[r8]: / trunk / apk_backup  Maximize  Restore  History

Download this file

72 lines (58 with data), 1.5 kB

#!/bin/sh

VERSION=0.0.9
echo "To be continued..."

#read the apklib funfctions
. ${APKLIBS:="/lib/apk"}/apkfuncs.sh

eecho() {
	echo "$*" >&2
}

usage() {
	eecho "apk_backup $VERSION"
	eecho "usage: apk_backup [ -v ] [ PACKAGE [ ...]] | PACKAGE [ ... ]"
	eecho "   -I           If any backup scripts (pre-backup or post-backup) exist"
	eecho "                for a given package, do not execute them."
	eecho "   -n           Don't actually backup a package, just report the steps that"
	eecho "                would be taken if it was."
	eecho "   -v           Turn on verbose output."
#	eecho "   -r           Use the remote fetching feature."
	eecho "   -h           Display this help"
#	echo "   -f PKGFILE   Install packages listed in PKGFILE"

	exit 1
}

#parse args here
unset vflag
unset rflag
unset Iflag
unset nflag
set -- `getopt hIvrn "$@"`
[ $# -lt 1 ] && exit 1	# getopt failed
while [ $# -gt 0 ] ; do
	case "$1" in 
		-h) usage;;
		-v) vflag="on";;
		-r) rflag="on";;
		-I) Iflag="on";;
		-n) nflag="on";;
		--) shift; break;;
		-*) usage;;
		*)  break;;
	esac
	shift
done
		

# create the apkdb dir if it does not exist
mkdir -p ${APKDB}

unset pkglist
while [ $# -gt 0 ] ; do
	pkgv=`get_installed_pkgv $1`
	[ -z "$pkgv" ] && die "$1 is not installed"
	[ `echo "$pkgv" | wc -l` -gt 1 ] && die "more than one version of $1 is istalled"
	pkglist="$pkglist $pkgv"
	shift
done

load_backupmod
backup_init

for i in $pkglist ; do
	backup_package $i
done

backup_cleanup
exit 0