diff options
-rw-r--r-- | db-functions | 28 | ||||
-rwxr-xr-x | db-move | 9 | ||||
-rwxr-xr-x | db-remove | 7 | ||||
-rwxr-xr-x | db-repo-add | 3 | ||||
-rwxr-xr-x | db-repo-remove | 7 | ||||
-rwxr-xr-x | db-update | 6 |
6 files changed, 34 insertions, 26 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}" +} @@ -106,13 +106,8 @@ done for tarch in ${ARCHES[@]}; do if [ -n "${add_pkgs[${tarch}]}" ]; then - /usr/bin/repo-add -q "${ftppath_to}/${tarch}/${repo_to}${DBEXT}" ${add_pkgs[${tarch}]} >/dev/null \ - || error "repo-add ${tarch}/${repo_to}${DBEXT} ${add_pkgs[${tarch}]}" - set_repo_permission "${repo_to}" "${tarch}" - - /usr/bin/repo-remove -q "${ftppath_from}/${tarch}/${repo_from}${DBEXT}" ${remove_pkgs[${tarch}]} >/dev/null \ - || error "repo-remove ${tarch}/${repo_from}${DBEXT} ${remove_pkgs[${tarch}]}" - set_repo_permission "${repo_from}" "${tarch}" + arch_repo_add "${repo_to}" "${tarch}" ${add_pkgs[${tarch}]} + arch_repo_remove "${repo_from}" "${tarch}" ${remove_pkgs[${tarch}]} fi done @@ -41,11 +41,6 @@ else fi for tarch in ${tarches[@]}; do - if [ ! -f "$ftppath/$tarch/$repo$DBEXT" ]; then - die "No database found at '$ftppath/$tarch', nothing more to do" - fi - - /usr/bin/repo-remove -q "$ftppath/$tarch/$repo$DBEXT" ${pkgnames[@]} >/dev/null - set_repo_permission "${repo}" "${tarch}" + arch_repo_remove "${repo}" "${tarch}" ${pkgnames[@]} repo_unlock $repo $tarch done diff --git a/db-repo-add b/db-repo-add index b6dd8b8..53cfc84 100755 --- a/db-repo-add +++ b/db-repo-add @@ -34,7 +34,6 @@ for tarch in ${tarches[@]}; do if [ ! -f "${pkgfile}" ]; then die "Package file ${pkgfile} not found" fi - /usr/bin/repo-add -q "$ftppath/$tarch/$repo$DBEXT" ${pkgfile} >/dev/null - set_repo_permission "${repo}" "${tarch}" + arch_repo_add "${repo}" "${tarch}" ${pkgfile} repo_unlock $repo $tarch done diff --git a/db-repo-remove b/db-repo-remove index 6fa0e05..b01910f 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -31,11 +31,6 @@ done msg "Removing $pkgname from [$repo]..." for tarch in ${tarches[@]}; do - if [ ! -f "$ftppath/$tarch/$repo$DBEXT" ]; then - die "No database found at '$ftppath/$tarch', nothing more to do" - fi - - /usr/bin/repo-remove -q "$ftppath/$tarch/$repo$DBEXT" ${pkgname} >/dev/null - set_repo_permission "${repo}" "${tarch}" + arch_repo_remove "${repo}" "${tarch}" ${pkgname} repo_unlock $repo $tarch done @@ -67,11 +67,7 @@ for repo in ${repos[@]}; do add_pkgs[${#add_pkgs[*]}]=${pkgfile} done if [ ${#add_pkgs[@]} -ge 1 ]; then - pushd "$FTP_BASE/$repo/os/${pkgarch}" >/dev/null - /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ - || die "repo-add $repo$DBEXT ${add_pkgs[@]}" - popd >/dev/null - set_repo_permission "${repo}" "${pkgarch}" + arch_repo_add "${repo}" "${pkgarch}" ${add_pkgs[@]} fi done done |