repo-remove: create empty DB when all packages are removed
Rather than creating no database at all, create an empty zipped tar archive in its place. This keeps the download side of repositories a bit more sane as a DB will always exist, and pacman handles this empty case just fine. For this to be fully transparent, we also need to make sure repo-add and repo-remove accept an empty "DB" as an argument, which in reality is a completely void of files .tar.{gz,bz2,xz} archive. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
20aa17c276
commit
7f14f185a2
1 changed files with 11 additions and 5 deletions
|
@ -306,10 +306,15 @@ check_repo_db()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$REPO_DB_FILE" ]; then
|
if [ -f "$REPO_DB_FILE" ]; then
|
||||||
if ! bsdtar -tqf "$REPO_DB_FILE" '*/desc' 2>&1 >/dev/null; then
|
# there are two situations we can have here- a DB with some entries,
|
||||||
|
# or a DB with no contents at all.
|
||||||
|
if ! bsdtar -tqf "$REPO_DB_FILE" '*/desc' >/dev/null 2>&1; then
|
||||||
|
# check empty case
|
||||||
|
if [ -n "$(bsdtar -tqf "$REPO_DB_FILE" '*' 2>/dev/null)" ]; then
|
||||||
error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE"
|
error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
msg "$(gettext "Extracting database to a temporary location...")"
|
msg "$(gettext "Extracting database to a temporary location...")"
|
||||||
bsdtar -xf "$REPO_DB_FILE" -C "$tmpdir"
|
bsdtar -xf "$REPO_DB_FILE" -C "$tmpdir"
|
||||||
else
|
else
|
||||||
|
@ -484,8 +489,9 @@ if [ $success -eq 1 ]; then
|
||||||
if [ -n "$(ls)" ]; then
|
if [ -n "$(ls)" ]; then
|
||||||
bsdtar -c${TAR_OPT}f "$filename" *
|
bsdtar -c${TAR_OPT}f "$filename" *
|
||||||
else
|
else
|
||||||
# the database will be moved to .old below, and there will be no new one to replace it
|
# we have no packages remaining? zip up some emptyness
|
||||||
error "$(gettext "All packages have been removed from the database. Deleting '%s'.")" "$REPO_DB_FILE"
|
warning "$(gettext "No packages remain, creating empty database.")"
|
||||||
|
bsdtar -c${TAR_OPT}f "$filename" -T /dev/null
|
||||||
fi
|
fi
|
||||||
cd "$startdir"
|
cd "$startdir"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue