summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-01-15 21:22:07 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-01-15 21:22:07 (EST)
commit3416232fe0c6b693dd788e3231c4f3c138114855 (patch)
tree0803382d19db5d0fd1ac0c499fb65dd608ef8f26
parent70bfe1b7998896852dff5c8fe0ed0f577965fc19 (diff)
resolve_deps(): Move to src/deps.sh
-rw-r--r--src/deps.sh34
-rw-r--r--src/local.mk1
-rw-r--r--src/pkg.sh51
-rw-r--r--tests/local.mk2
4 files changed, 34 insertions, 54 deletions
diff --git a/src/deps.sh b/src/deps.sh
index 862caff..9a30fe9 100644
--- a/src/deps.sh
+++ b/src/deps.sh
@@ -1,6 +1,6 @@
# Functions for parsing dependency field values
#
-# Copyright (C) 2012, 2014 Patrick "P. J." McDermott
+# Copyright (C) 2012-2014 Patrick "P. J." McDermott
#
# This file is part of the ProteanOS Development Kit.
#
@@ -18,6 +18,38 @@
# along with the ProteanOS Development Kit. If not, see
# <http://www.gnu.org/licenses/>.
+resolve_deps()
+{
+ local new_pkgs="${1}"
+ local deps="${2}"
+ local all_deps=
+ local new_deps=
+ local pkg=
+
+ all_deps=''
+ new_pkgs="${new_pkgs} "
+ while [ "x${new_pkgs}" != 'x' ]; do
+ all_deps="${all_deps}${new_pkgs}"
+ new_deps=''
+ for pkg in ${new_pkgs}; do
+ case "${pkg}" in
+ *[!a-z0-9+.-]*) continue;;
+ esac
+ new_deps="${new_deps} $(printf '%s' "${deps}" | \
+ sed -n "s/^${pkg}: *//p")"
+ done
+ new_deps="$(printf '%s\n' ${new_deps} | sort -u)"
+ new_pkgs=''
+ for pkg in ${new_deps}; do
+ if [ "x${all_deps# ${pkg} }" = "x${all_deps}" ]; then
+ new_pkgs="${new_pkgs}${pkg} "
+ fi
+ done
+ done
+
+ printf '%s\n' "${all_deps% }"
+}
+
parse_dep()
{
local dep="${1}"
diff --git a/src/local.mk b/src/local.mk
index dae4309..331f13c 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -11,7 +11,6 @@ prokit_SOURCES += \
src/substvars.sh \
src/control.sh \
src/feed.sh \
- src/pkg.sh \
src/mutex.sh \
src/session.sh \
src/block.sh \
diff --git a/src/pkg.sh b/src/pkg.sh
deleted file mode 100644
index ee4aa25..0000000
--- a/src/pkg.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-# Functions for handling packages and their dependencies
-#
-# Copyright (C) 2013, 2014 Patrick "P. J." McDermott
-#
-# This file is part of the ProteanOS Development Kit.
-#
-# The ProteanOS Development Kit 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.
-#
-# The ProteanOS Development Kit 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 the ProteanOS Development Kit. If not, see
-# <http://www.gnu.org/licenses/>.
-
-resolve_deps()
-{
- local new_pkgs="${1}"
- local deps="${2}"
- local all_deps=
- local new_deps=
- local pkg=
-
- all_deps=''
- new_pkgs="${new_pkgs} "
- while [ "x${new_pkgs}" != 'x' ]; do
- all_deps="${all_deps}${new_pkgs}"
- new_deps=''
- for pkg in ${new_pkgs}; do
- case "${pkg}" in
- *[!a-z0-9+.-]*) continue;;
- esac
- new_deps="${new_deps} $(printf '%s' "${deps}" | \
- sed -n "s/^${pkg}: *//p")"
- done
- new_deps="$(printf '%s\n' ${new_deps} | sort -u)"
- new_pkgs=''
- for pkg in ${new_deps}; do
- if [ "x${all_deps# ${pkg} }" = "x${all_deps}" ]; then
- new_pkgs="${new_pkgs}${pkg} "
- fi
- done
- done
-
- printf '%s\n' "${all_deps% }"
-}
diff --git a/tests/local.mk b/tests/local.mk
index 397cdc2..6eb9878 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -21,7 +21,7 @@ CLEANFILES += $(tests_parse_control_basic_LDADD)
tests_resolve_deps_basic_SOURCES = \
tests/resolve_deps.basic.sh \
tests/common.sh \
- src/pkg.sh
+ src/deps.sh
tests_resolve_deps_basic_LDADD = $(tests_resolve_deps_basic_SOURCES:.sh=.sho)
CLEANFILES += $(tests_resolve_deps_basic_LDADD)