summaryrefslogtreecommitdiffstats
path: root/db-functions
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-01-15 01:12:09 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-01-15 01:12:09 +0100
commit4da9bf112b07c94a7fd65a729ce62610ade8e5aa (patch)
tree326b793a2b8a2bacc43be518d0f209557d8afd03 /db-functions
parent7519447709e1ac9a5b5edaa04b32c03ac09ee2ef (diff)
downloaddbscripts-4da9bf112b07c94a7fd65a729ce62610ade8e5aa.tar.gz
dbscripts-4da9bf112b07c94a7fd65a729ce62610ade8e5aa.tar.xz
Move repo manipulation code into common functions
repo-add and repo-remove is now indirectly called by arch_repo_add/remove. This simplifies future extensions like incremental file list creations. See FS#11302
Diffstat (limited to 'db-functions')
-rw-r--r--db-functions28
1 files changed, 28 insertions, 0 deletions
diff --git a/db-functions b/db-functions
index 8ac9e63..7d431fc 100644
--- a/db-functions
+++ b/db-functions
@@ -450,3 +450,31 @@ set_repo_permission() {
error "You don't have permission to change ${dbfile}"
fi
}
+
+arch_repo_add() {
+ local repo=$1
+ local arch=$2
+ local pkgs=(${@:3})
+
+ # package files might be relative to repo dir
+ pushd "${FTP_BASE}/${repo}/os/${arch}" >/dev/null
+ /usr/bin/repo-add -q "${repo}${DBEXT}" ${pkgs[@]} >/dev/null \
+ || error "repo-add ${repo}${DBEXT} ${pkgs[@]}"
+ popd >/dev/null
+ set_repo_permission "${repo}" "${arch}"
+}
+
+arch_repo_remove() {
+ local repo=$1
+ local arch=$2
+ local pkgs=(${@:3})
+ local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}"
+
+ if [ ! -f "${dbfile}" ]; then
+ error "No database found at '${dbfile}'"
+ return 1
+ fi
+ /usr/bin/repo-remove -q "${dbfile}" ${pkgs[@]} >/dev/null \
+ || error "repo-remove ${dbfile} ${pkgs[@]}"
+ set_repo_permission "${repo}" "${arch}"
+}