From b4341ef8e90abe99d188dc444ff837a7aba756fa Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 28 May 2013 18:56:45 -0600 Subject: librechroot: didn't always create repo.db symlink Fix this and remove code duplication by pulling the relevant code into a function. --- src/chroot-tools/librechroot | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/chroot-tools/librechroot') diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 5afce05..ed00688 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -32,6 +32,13 @@ normshell() ( "$@" ) +make_emtpy_repo() { + local copydir=$1 + mkdir -p "${copydir}/repo" + bsdtar -czf "${copydir}/repo/repo.db.tar.gz" -T /dev/null + ln -s "repo.db.tar.gz" "${copydir}/repo/repo.db" +} + cmd=${0##*/} usage() { echo "Usage: $cmd [OPTIONS] COMMAND [ARGS...]" @@ -168,8 +175,7 @@ main() { set +u # if archroot_args is empty, it counts as unbound archroot "${archroot_args[@]}" -m "$rootdir" base-devel set -u - mkdir -p "${rootdir}/repo" - bsdtar -czf "${rootdir}/repo/repo.db.tar.gz" -T /dev/null + make_empty_repo "$copydir" fi if [[ ! -d $copydir ]] || [[ $mode == sync ]]; then @@ -232,9 +238,7 @@ main() { enter) archroot -r "$copydir" bash;; clean-repo) rm -rf "${copydir}/repo/*" - mkdir -p "${copydir}/repo" - bsdtar -czf "${copydir}/repo/repo.db.tar.gz" -T /dev/null - ln -s "repo.db.tar.gz" "${copydir}/repo/repo.db" + make_empty_repo "$copydir" ;; *) error "Unrecognized command: \`$mode'" -- cgit v1.2.3-54-g00ecf