summaryrefslogtreecommitdiff
path: root/scripts/repo-add.sh.in
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2009-02-26 20:02:05 +0100
committerXavier Chantry <shiningxc@gmail.com>2009-03-15 18:10:23 +0100
commit994804f20e51ea6dbbb236b919846a420b2d2369 (patch)
treea78530797ca73842cdf2d67a7864e0ead59c2ab6 /scripts/repo-add.sh.in
parentf8bb69c1d22473a3a82c6bab27799e3cada56a0a (diff)
downloadpacman-994804f20e51ea6dbbb236b919846a420b2d2369.tar.xz
repo-add.sh.in : repo-remove improvements
* report when a package entry to be removed is not found * backup and restore eventual "deltas" files * slight optimization when looking for an entry : only look at the entries starting with $pkgname Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Diffstat (limited to 'scripts/repo-add.sh.in')
-rw-r--r--scripts/repo-add.sh.in50
1 files changed, 38 insertions, 12 deletions
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 4520dd4c..80a70de8 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -93,6 +93,20 @@ write_list_entry() {
fi
}
+find_pkgentry()
+{
+ local pkgname=$1
+ local pkgentry
+ for pkgentry in $gstmpdir/$pkgname*; do
+ name=${pkgentry##*/}
+ if [ "${name%-*-*}" = "$pkgname" ]; then
+ echo $pkgentry
+ return 0
+ fi
+ done
+ return 1
+}
+
# write a delta entry to the pacman database
# arg1 - path to delta
db_write_delta()
@@ -186,6 +200,9 @@ db_write_entry()
mkdir "$pkgname-$pkgver"
cd "$pkgname-$pkgver"
+ # restore an eventual deltas file
+ [ -f "../$pkgname.deltas" ] && mv "../$pkgname.deltas" deltas
+
# create desc entry
msg2 "$(gettext "Creating 'desc' db entry...")"
echo -e "%FILENAME%\n$(basename "$1")\n" >>desc
@@ -256,18 +273,20 @@ db_write_entry()
# remove existing entries from the DB
# arg1 - package name
db_remove_entry() {
- pushd "$gstmpdir" 2>&1 >/dev/null
-
- # remove any other package in the DB with same name
- local existing
- for existing in *; do
- if [ "${existing%-*-*}" = "$1" ]; then
- msg2 "$(gettext "Removing existing package '%s'...")" "$existing"
- rm -rf "$existing"
+ local pkgname=$1
+ local notfound=1
+ local pkgentry=$(find_pkgentry $pkgname)
+ while [ -n "$pkgentry" ]; do
+ notfound=0
+ if [ -f "$pkgentry/deltas" ]; then
+ mv "$pkgentry/deltas" "$gstmpdir/$pkgname.deltas"
fi
+ msg2 "$(gettext "Removing existing package '%s'...")" \
+ "$(basename $pkgentry)"
+ rm -rf $pkgentry
+ pkgentry=$(find_pkgentry $pkgname)
done
-
- popd 2>&1 >/dev/null
+ return $notfound
} # end db_remove_entry
check_repo_db()
@@ -307,9 +326,16 @@ add()
remove()
{
- msg "$(gettext "Searching for package '%s'...")" "$arg"
+ pkgname=$1
+ msg "$(gettext "Searching for package '%s'...")" "$pkgname"
- db_remove_entry "$arg"
+ if db_remove_entry "$pkgname"; then
+ rm -f "$gstmpdir/$pkgname.deltas"
+ return 0
+ else
+ error "$(gettext "Package matching '%s' not found.")" "$pkgname"
+ return 1
+ fi
}
# PROGRAM START