summaryrefslogtreecommitdiffstats
path: root/lib/remove.sh
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-07-27 14:39:46 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-07-27 14:39:46 (EDT)
commitcde4391f31c2288a53fb84dcbbb3580593bda8bd (patch)
tree6c212172bbdb47a0f906b1fa4681d21fd1d27a22 /lib/remove.sh
parent7aa5ff9ac61a24f3b8fc7c47352d64a938df316f (diff)
lib/remove.sh: New file.
Diffstat (limited to 'lib/remove.sh')
-rw-r--r--lib/remove.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/lib/remove.sh b/lib/remove.sh
new file mode 100644
index 0000000..f484b19
--- /dev/null
+++ b/lib/remove.sh
@@ -0,0 +1,80 @@
+# pro-archman
+# lib/remove.sh
+# Functions for removing packges
+#
+# Copyright (C) 2013 Patrick "P. J." McDermott
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+use db
+
+remove_source_from_suite()
+{
+ local chan="${1}"
+ local dist="${2}"
+ local source="${3}"
+ local plat=
+ local arch=
+
+ while read -r plat arch; do
+ remove_packages_from_suite_archplat \
+ "${chan}" "${dist}" "${plat}" "${arch}" "${source}"
+ done <<-EOF
+ $(db_get_archplats "${chan}" "${dist}" "${source}")
+ EOF
+
+ db_del_srcver "${chan}" "${dist}" "${source}"
+
+ return 0
+}
+
+remove_packages_from_suite_archplat()
+{
+ local chan="${1}"
+ local dist="${2}"
+ local plat="${3}"
+ local arch="${4}"
+ local source="${5}"
+ local binver=
+ local refs=
+ local sect=
+ local pkg=
+ local file=
+
+ binver="$(db_get_binver "${chan}" "${dist}" "${plat}" "${arch}" \
+ "${source}")"
+ if [ "x${binver}" = 'x' ]; then
+ return 0
+ fi
+ db_del_binver "${chan}" "${dist}" "${plat}" "${arch}" "${source}"
+ refs=$(db_dec_references "${plat}" "${arch}" "${source}" "${binver}")
+
+ while read -r sect pkg; do
+ feed_remove_package "${chan}" "${dist}" "${plat}" "${arch}" \
+ "${sect}" "${pkg}"
+ if [ ${refs} -eq 0 ]; then
+ file="pool/$(hash_name "${source}")/${source}"
+ file="${file}/${pkg}_${binver}_${arch}_${plat}.opk"
+ mark_pool_garbage "${file}"
+ fi
+ done <<-EOF
+ $(db_get_packages "${plat}" "${arch}" "${source}" "${binver}")
+ EOF
+
+ if [ ${refs} -eq 0 ]; then
+ db_del_packages "${plat}" "${arch}" "${source}" "${binver}"
+ fi
+
+ return 0
+}