Commit 055c23a5 authored by Natanael Copa's avatar Natanael Copa

lbu: automatically migrate old include/exclude to lbu.list

parent 4e857d18
...@@ -129,6 +129,7 @@ check_openssl() { ...@@ -129,6 +129,7 @@ check_openssl() {
# our own filter functions # our own filter functions
list_has() { list_has() {
local line= local line=
[ -e "$LBU_LIST" ] || return 1
while read line; do while read line; do
[ "$line" = "$1" ] && return 0 [ "$line" = "$1" ] && return 0
done < "$LBU_LIST" done < "$LBU_LIST"
...@@ -229,6 +230,7 @@ Options: ...@@ -229,6 +230,7 @@ Options:
} }
cmd_include() { cmd_include() {
cmd_migrate_include_exclude
if [ "$LIST" ] ; then if [ "$LIST" ] ; then
[ $# -gt 0 ] && usage_include [ $# -gt 0 ] && usage_include
show_include show_include
...@@ -293,6 +295,7 @@ cmd_package() { ...@@ -293,6 +295,7 @@ cmd_package() {
local suff="apkovl.tar.gz" local suff="apkovl.tar.gz"
local tmpdir tmppkg local tmpdir tmppkg
cmd_migrate_include_exclude
check_openssl check_openssl
init_tmpdir tmpdir init_tmpdir tmpdir
...@@ -316,8 +319,8 @@ cmd_package() { ...@@ -316,8 +319,8 @@ cmd_package() {
cd "${ROOT:-/}" cd "${ROOT:-/}"
# remove old package.list # remove old package.list
if [ -f etc/lbu/packages.list ] && [ -f var/lib/apk/world ]; then if [ -f etc/lbu/packages.list ] && [ -f var/lib/apk/world ]; then
echo "Note: Removing /etc/lbu/packages.list." echo "Note: Removing /etc/lbu/packages.list." >&2
echo " /var/lib/apk/world will be used." echo " /var/lib/apk/world will be used." >&2
rm -f etc/lbu/packages.list rm -f etc/lbu/packages.list
fi fi
# create tar archive # create tar archive
...@@ -382,10 +385,8 @@ usage: $PROGRAM list|ls ...@@ -382,10 +385,8 @@ usage: $PROGRAM list|ls
} }
cmd_list() { cmd_list() {
VERBOSE="-v" cmd_migrate_include_exclude
DRYRUN="-n" _gen_filelist
ENCRYPTION=
cmd_package /dev/null
} }
# #
...@@ -524,6 +525,7 @@ Options: ...@@ -524,6 +525,7 @@ Options:
} }
cmd_exclude() { cmd_exclude() {
cmd_migrate_include_exclude
if [ "$LIST" ] ; then if [ "$LIST" ] ; then
[ $# -gt 0 ] && usage_exclude [ $# -gt 0 ] && usage_exclude
show_exclude show_exclude
...@@ -686,7 +688,38 @@ cmd_diff() { ...@@ -686,7 +688,38 @@ cmd_diff() {
cd "$tmp" && diff -ruN a b cd "$tmp" && diff -ruN a b
} }
# migrate
migrate_conf() {
local pref="$1" conf="$2" line=
echo "Note: Migrating $conf to $LBU_LIST" >&2
echo "# Automatically imported from $conf" >> "$LBU_LIST"
while read line; do
if [ "${line#'#'}" != "$line" ]; then
# dont prefix comments
echo "$line" >> "$LBU_LIST" || return 1
continue
fi
case "$line" in
[a-zA-z0-9._/]*) line="$pref$line";;
*) continue;; # skip files with weird names
esac
if ! list_has "$line"; then
echo "$line" >> "$LBU_LIST" || return 1
fi
done < "$conf"
rm "$conf"
}
#-----------------------------------------------------------
# lbu migrate_config - migrate include/exclude to protected_paths.d
cmd_migrate_include_exclude() {
if [ -e "$INCLUDE_LIST" ]; then
migrate_conf + "$INCLUDE_LIST"
fi
if [ -e "$EXCLUDE_LIST" ]; then
migrate_conf - "$EXCLUDE_LIST"
fi
}
#----------------------------------------------------------- #-----------------------------------------------------------
# Main # Main
...@@ -710,6 +743,7 @@ case "$cmd" in ...@@ -710,6 +743,7 @@ case "$cmd" in
list-backup|lb) SUBCMD="listbackup";; list-backup|lb) SUBCMD="listbackup";;
revert) SUBCMD="revert";; revert) SUBCMD="revert";;
diff) SUBCMD="diff";; diff) SUBCMD="diff";;
migrate_include_exclude) SUBCMD="migrate_include_exclude";;
*) usage;; *) usage;;
esac esac
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment