From 4da9bf112b07c94a7fd65a729ce62610ade8e5aa Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 15 Jan 2011 01:12:09 +0100 Subject: 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 --- db-functions | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'db-functions') 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}" +} -- cgit v1.2.3