summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/include.sh127
-rw-r--r--lib/local.mk1
2 files changed, 128 insertions, 0 deletions
diff --git a/lib/include.sh b/lib/include.sh
new file mode 100644
index 0000000..ac1000a
--- /dev/null
+++ b/lib/include.sh
@@ -0,0 +1,127 @@
+# pro-archman
+# lib/include.sh
+# Functions for including changes
+#
+# 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 control
+use db
+use locale
+use output
+
+_INCLUDE_CHANGES_FIELDS='Format Source Binary Version Architecture Platform
+Distribution Maintainer Changed-By Date Description Changes Files'
+
+_include_source=
+_include_version=
+_include_distribution=
+_include_files=
+
+include_changes()
+{
+ local changes="${1}"
+ local chan=
+ local dist=
+ local source=
+ local srcver=
+ local old_ver=
+ local bvaps=
+ local size=
+ local sect=
+ local file=
+ local pkg=
+ local binver=
+ local plat=
+ local arch=
+ local pool_file=
+
+ parse_control "${changes}" _include_changes_field \
+ "${_INCLUDE_CHANGES_FIELDS}" ''
+ chan="${conf_incoming_channel}"
+ dist="${_include_distribution}"
+ source="${_include_source}"
+ srcver="${_include_version}"
+
+ info "$(get_msg 'include_including')" "${source}" "${srcver}" \
+ "${chan}" "${dist}"
+
+ old_ver="$(db_get_srcver "${chan}" "${dist}" "${source}")"
+ if [ "x${old_ver}" = 'x' ]; then
+ db_set_srcver "${chan}" "${dist}" "${source}" "${srcver}"
+ else
+ if [ "x${old_ver}" != "x${_include_version}" ]; then
+ remove_source_from_suite "${chan}" "${dist}" "${source}"
+ db_set_srcver "${chan}" "${dist}" \
+ "${source}" "${srcver}"
+ fi
+ fi
+
+ bvaps=''
+ while read -r size file; do
+ if [ "x${file##[ ]}" = 'x' ]; then
+ continue
+ fi
+ sect='base'
+ IFS='_' read -r pkg binver arch plat <<-EOF
+ ${file%.opk}
+ EOF
+ db_add_package "${plat}" "${arch}" "${source}" "${binver}" \
+ "${sect}" "${pkg}"
+ bvaps="${bvaps}${binver} ${plat} ${arch}${LF}"
+ pool_file="pool/$(hash_name "${source}")/${source}"
+ pool_file="${pool_file}/${pkg}_${binver}_${arch}_${plat}.opk"
+ cp -p "$(dirname "${changes}")/${file}" \
+ "${opt_base_dir}/${pool_file}"
+ feed_add_package "${chan}" "${dist}" "${plat}" "${arch}" \
+ "${sect}" "${pkg}" "${size}" "${pool_file}"
+ done <<-EOF
+ ${_include_files}
+ EOF
+
+ while read -r binver plat arch; do
+ remove_packages_from_suite_archplat "${chan}" "${dist}" \
+ "${plat}" "${arch}" "${source}"
+ db_set_binver "${chan}" "${dist}" "${plat}" "${arch}" \
+ "${source}" "${binver}"
+ db_inc_references "${plat}" "${arch}" "${source}" "${binver}" \
+ >/dev/null
+ done <<-EOF
+ $(printf '%s' "${bvaps}" | LC_COLLATE='C' sort | uniq)
+ EOF
+
+ return 0
+}
+
+_include_changes_field()
+{
+ local name="${1}"
+ local value="${2}"
+
+ case "${name}" in
+ 'Source')
+ _include_source="${value}"
+ ;;
+ 'Version')
+ _include_version="${value}"
+ ;;
+ 'Distribution')
+ _include_distribution="${value}"
+ ;;
+ 'Files')
+ _include_files="${value}"
+ ;;
+ esac
+}
diff --git a/lib/local.mk b/lib/local.mk
index 917f022..b7f4542 100644
--- a/lib/local.mk
+++ b/lib/local.mk
@@ -9,5 +9,6 @@ pkglib_srcs = \
lib/db.sh \
lib/index.sh \
lib/garbage.sh \
+ lib/include.sh \
lib/remove.sh \
lib/cmd.sh