summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2015-08-26 22:40:54 -0300
committercoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2015-08-26 22:40:54 -0300
commit97a608633fd3fe187af5b1269fcc3398add75901 (patch)
tree28254b8a4267c3eefad7f584a2b786f51c952fca
parent913e47da5665f51137902c6caccb6be3f716b5f6 (diff)
porting db-pkg-rm (db-repo-remove) from xbs, fix comments from db-pkg-add, db-init and fix db-pkg-add
-rwxr-xr-xsrc/bin/db-init2
-rwxr-xr-xsrc/bin/db-pkg-add14
-rwxr-xr-xsrc/bin/db-pkg-rm57
3 files changed, 67 insertions, 6 deletions
diff --git a/src/bin/db-init b/src/bin/db-init
index 73b467f..489c845 100755
--- a/src/bin/db-init
+++ b/src/bin/db-init
@@ -23,7 +23,7 @@ for '_platform' in "${PLATFORMS[@]}"; do
mkdir -p -- "${PKG_MAIN_POOLS}" "${SRC_MAIN_POOLS}" "${CLEANUP_DESTDIR}" "${SOURCE_CLEANUP_DESTDIR}" "${STAGING}"
else
- die "This ${plataform} doesn't exist"
+ die "This %s plataform doesn't exist" "${plataform}"
fi
donw
fi
diff --git a/src/bin/db-pkg-add b/src/bin/db-pkg-add
index 6b9e154..8f961ee 100755
--- a/src/bin/db-pkg-add
+++ b/src/bin/db-pkg-add
@@ -6,7 +6,7 @@ source "${CONFIG_DIR}/xbs.cfg"
source "${SHARE_DIR}/db-functions"
if [ "${#}" -lt '4' ]; then
- "usage: %s <platform> <repo> <arch> <pkgfile> ..." "${0##*/}"
+ msg "usage: %s <platform> <repo> <arch> <pkg_file> ..." "${0##*/}"
exit 1
fi
@@ -36,11 +36,15 @@ for '_platform' in "${PLATFORMS[@]}"; do
for 'tarch' in "${tarches[@]}"; do
if [[ ! -d "${repo_path} ]]; then
- die "This ${repo} doesn't exist"
+ die "This [%s] doesn't exist" "${repo}"
elif [[ ! -d "${repo_path}/${tarch}" ]]; then
- die "This ${repo} doesn't support ${arch} archictecture"
+ die "This [%s] doesn't support %s archictecture" "${repo}" "${arch}"
+ else
+ repo_lock "${repo}" "${tarch}" || exit 1
fi
- repo_lock "${repo}" "${tarch}" || exit 1
+ done
+
+ for 'tarch' in "${tarches[@]}"; do
for 'pkg_file' in "${pkg_files[@]}"; do
if [[ ! -f "${repo_path}/${arch}/${pkg_file##*/}" ]]; then
die "Package file %s not found in %s" "${pkg_file##*/}" "${repo_path}/${arch}/"
@@ -52,6 +56,6 @@ for '_platform' in "${PLATFORMS[@]}"; do
repo_unlock "${repo}" "${tarch}"
done
else
- die "This ${plataform} doesn't exist"
+ die "This %s plataform doesn't exist" "${plataform}"
fi
done
diff --git a/src/bin/db-pkg-rm b/src/bin/db-pkg-rm
new file mode 100755
index 0000000..a2d5de1
--- /dev/null
+++ b/src/bin/db-pkg-rm
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+CONFIG_DIR="$(dirname "$(readlink -e "${0}")")/etc"
+
+source "${CONFIG_DIR}/xbs.cfg"
+source "${SHARE_DIR}/db-functions"
+
+if [ "${#}" -lt '4' ]; then
+ msg "usage: %s <platform> <repo> <arch> <pkg_name> ..." "${0##*/}"
+ exit 1
+fi
+
+plataform="${1}"
+repo="${2}"
+arch="${3}"
+pkg_names=("${@:4}")
+
+for '_platform' in "${PLATFORMS[@]}"; do
+ # Rename ("${plataform}") to easily script usage
+ _platform_name="${plataform/\//+}" _platform_name="${_platform_name,,}"
+
+ if [ "${_platform_name}" == "${_platform}" ]; then
+ source "${CONFIG_DIR}/xbs.d/${_platform}.cfg"
+
+ repo_path="${REPO_DIR}/${_platform}/${repo}/os"
+
+ if ! check_repo_permission "${repo}"; then
+ die "You don't have permission to remove packages to %s" "${repo}"
+ fi
+
+ if [ "${arch}" == "{any}" ]; then
+ tarches=("${ARCHES[@]}")
+ else
+ tarches=("${arch}")
+ fi
+
+ for 'tarch' in "${tarches[@]}"; do
+ if [[ ! -d "${repo_path} ]]; then
+ die "This [%s] doesn't exist" "${repo}"
+ elif [[ ! -d "${repo_path}/${tarch}" ]]; then
+ die "This [%s] doesn't support %s archictecture" "${repo}" "${arch}"
+ else
+ repo_lock "${repo}" "${tarch}" || exit 1
+ fi
+ done
+
+ for 'tarch' in "${tarches[@]}"; do
+ for 'pkg_name' in "${pkg_names[@]}"; do
+ msg "Removing %s from [%s]..." "${pkg_name}" "${repo}"
+ done
+ arch_repo_remove "${repo}" "${tarch}" "${pkgnames[@]}"
+ repo_unlock "${repo}" "${tarch}"
+ done
+ else
+ die "This %s plataform doesn't exist" "${plataform}"
+ fi
+done