summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-10-09 16:52:50 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-10-09 16:52:50 (EDT)
commit292139f281ab11e79f6545b1dd8d95a6d9366cc2 (patch)
tree626e6fdb75d65d90805cce126dfcb924a3156149
parent29c2633f107ab3cdd1e205979502acba39f236fa (diff)
Delete opkhelper library.
libopkbuild.1 is the library now.
-rw-r--r--Makefile.in9
-rwxr-xr-xconfigure2
-rw-r--r--lib/Makefile.in76
-rw-r--r--lib/architecture.sh71
-rw-r--r--lib/cache.sh37
-rw-r--r--lib/changelog.sh170
-rw-r--r--lib/control.sh247
-rw-r--r--lib/locale.sh57
-rw-r--r--lib/messages.sh85
-rw-r--r--lib/util.sh29
10 files changed, 1 insertions, 782 deletions
diff --git a/Makefile.in b/Makefile.in
index db32e3f..f9ec445 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -49,8 +49,6 @@ distfiles = configure Makefile.in COPYING README INSTALL ChangeLog TODO
all:
@printf 'Making executable files...\n'
@cd src && $(MAKE) $(MACROS) all
- @printf 'Making library files...\n'
- @cd lib && $(MAKE) $(MACROS) all
@printf 'Making locales...\n'
@cd locale && $(MAKE) $(MACROS) all
@printf 'Making manual pages...\n'
@@ -59,8 +57,6 @@ all:
clean:
@printf 'Cleaning executable files...\n'
@cd src && $(MAKE) $(MACROS) clean
- @printf 'Cleaning library files...\n'
- @cd lib && $(MAKE) $(MACROS) clean
@printf 'Cleaning locales...\n'
@cd locale && $(MAKE) $(MACROS) clean
@printf 'Cleaning manual pages...\n'
@@ -69,8 +65,6 @@ clean:
install: all
@printf 'Installing executable files...\n'
@cd src && $(MAKE) $(MACROS) install
- @printf 'Installing libary files...\n'
- @cd lib && $(MAKE) $(MACROS) install
@printf 'Installing locales...\n'
@cd locale && $(MAKE) $(MACROS) install
@printf 'Installing manual pages...\n'
@@ -79,8 +73,6 @@ install: all
uninstall:
@printf 'Uninstalling executable files...\n'
@cd src && $(MAKE) $(MACROS) uninstall
- @printf 'Uninstalling library files...\n'
- @cd lib && $(MAKE) $(MACROS) uninstall
@printf 'Uninstalling locales...\n'
@cd locale && $(MAKE) $(MACROS) uninstall
@printf 'Uninstalling manual pages...\n'
@@ -90,7 +82,6 @@ $(distdir):
@mkdir -p '$(distdir)'
@cp -pR $(distfiles) '$(distdir)'
@cd src && $(MAKE) '../$(distdir)/src'
- @cd lib && $(MAKE) '../$(distdir)/lib'
@cd locale && $(MAKE) '../$(distdir)/locale'
@cd man && $(MAKE) '../$(distdir)/man'
diff --git a/configure b/configure
index 2e4ce98..1972190 100755
--- a/configure
+++ b/configure
@@ -309,7 +309,7 @@ write_makefiles()
_sed_script="${_sed_script}s&@${_var}@&$(eval echo \$\{"${_var}"\})&g;"
done
- for _dir in . src lib locale man; do
+ for _dir in . src locale man; do
mkdir -p "${_dir}"
sed "${_sed_script}" "${srcdir}/${_dir}/Makefile.in" >"${_dir}/Makefile"
done
diff --git a/lib/Makefile.in b/lib/Makefile.in
deleted file mode 100644
index d13a909..0000000
--- a/lib/Makefile.in
+++ /dev/null
@@ -1,76 +0,0 @@
-# opkhelper
-# Makefile.in
-# Input Makefile for configure.
-#
-# Copyright (C) 2012 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/>.
-
-package_name = @package_name@
-package_version= @package_version@
-
-srcdir = @srcdir@
-prefix = @prefix@
-libdir = @libdir@
-datadir = @datadir@
-localedir = @localedir@
-
-sed_script = s&@@PACKAGE_NAME@@&$(package_name)&;\
- s&@@PACKAGE_VERSION@@&$(package_version)&;\
- s&@@LIBDIR@@&$(libdir)&;\
- s&@@LOCALEDIR@@&$(localedir)&;
-
-.SUFFIXES:
-.SUFFIXES: .sh
-
-SRCS = control.sh \
- changelog.sh \
- locale.sh \
- messages.sh \
- cache.sh \
- util.sh
-OBJS = $(SRCS:.sh=)
-
-distdir = ../$(package_name)-$(package_version)/lib
-distfiles = Makefile.in $(SRCS)
-
-all: $(OBJS)
-
-$(OBJS):
- @printf ' SED lib/%s\n' '$@'
- @sed '$(sed_script)' '$(srcdir)/lib/$@.sh' >'$@'
-
-clean:
- @for obj in $(OBJS); do \
- printf ' RM lib/%s\n' "$${obj}"; \
- rm -f "$${obj}"; \
- done
-
-install: all
- @for obj in $(OBJS); do \
- printf ' INSTALL lib/%s\n' "$${obj}"; \
- mkdir -p '$(DESTDIR)/$(libdir)'; \
- cp "$${obj}" "$(DESTDIR)/$(libdir)/$${obj}"; \
- chmod 644 "$(DESTDIR)/$(libdir)/$${obj}"; \
- done
-
-uninstall:
- @for obj in $(OBJS); do \
- printf ' RM %s\n' "$${obj}"; \
- rm -f "$(DESTDIR)/$(libdir)/opkhelper/$${obj}"; \
- done
-
-$(distdir):
- @mkdir -p '$(distdir)'
- @cp -pR $(distfiles) '$(distdir)'
diff --git a/lib/architecture.sh b/lib/architecture.sh
deleted file mode 100644
index 17d839e..0000000
--- a/lib/architecture.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#!@@SHELL@@
-#
-# opkhelper
-# lib/architecture
-# Functions for determining the target architecture.
-#
-# Copyright (C) 2012 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/>.
-
-. @@LIBDIR@@/opkhelper/controlfields
-
-oh_is_buildable()
-{
- _pkgarch=$(oh_get_field "${1}" Architecture)
-
- # "all" or "any".
- if [ "${_pkgarch}" = all -o "${_pkgarch}" = any ]; then
- return 0
- fi
-
- # Platform.
- if [ -n "$(echo "${_pkgarch}" | grep -E '^[^-]+$')" ]; then
- return [ "${_pkgarch}" = "${OH_HOST_PLATFORM}" ]
- fi
-
- # Tokenize the 3-tuple binary architecture.
- IFS=- read _pkgcpu _pkgkernel _pkglibs <<EOF
-${_pkgarch}
-EOF
-
- # Test each element of the tuple.
- [ "${_pkgcpu}" != any -a "${_pkgcpu}" != "${OH_HOST_ARCH_CPU}" ] &&
- return 1
- [ "${_pkgkernel}" != any -a "${_pkgkernel}" != "${OH_HOST_ARCH_KERNEL}" ] &&
- return 1
- [ "${_pkglibs}" != any -a "${_pkglibs}" != "${OH_HOST_ARCH_LIBS}" ] &&
- return 1
-
- return 0
-}
-
-oh_get_package_architecture()
-{
- _pkgarch=$(oh_get_field "${1}" Architecture)
-
- # "all".
- if [ "${_pkgarch}" = all ]; then
- echo all
- return 0
- fi
-
- if [ -n "${OH_HOST_PLATFORM}" ]; then
- echo "${OH_HOST_PLATFORM}"
- else
- echo "${OH_HOST_ARCH_DIST}"
- fi
-
- return 0
-}
diff --git a/lib/cache.sh b/lib/cache.sh
deleted file mode 100644
index a87646b..0000000
--- a/lib/cache.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-# opkhelper
-# lib/cache
-# Cache property functions.
-#
-# Copyright (C) 2012 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/>.
-
-[ -n "${_OH_CACHE_SH}" ] && return 0
-_OH_CACHE_SH=true
-
-. @@LIBDIR@@/util
-
-oh_cache()
-{
- _property="${1}"
- shift
-
- mkdir -p "${OH_SOURCE_DIR}/tmp/.cache"
-
- if [ ${#} -eq 0 ]; then
- cat "${OH_SOURCE_DIR}/tmp/.cache/${_property}" 2>/dev/null
- else
- echo "${*}" >"${OH_SOURCE_DIR}/tmp/.cache/${_property}"
- fi
-}
diff --git a/lib/changelog.sh b/lib/changelog.sh
deleted file mode 100644
index 01e4644..0000000
--- a/lib/changelog.sh
+++ /dev/null
@@ -1,170 +0,0 @@
-# opkhelper
-# lib/changelog
-# Functions for parsing changelogs.
-#
-# Copyright (C) 2012 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/>.
-
-[ -n "${_OH_CHANGELOG_SH}" ] && return 0
-_OH_CHANGELOG_SH=true
-
-. @@LIBDIR@@/messages
-. @@LIBDIR@@/locale
-. @@LIBDIR@@/util
-
-# Constant global parameters:
-OH_SOURCE_RE='^[a-z0-9][a-z0-9+.-]+$'
-OH_SOURCE_VERSION_ID_RE='^'
-OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'[0-9a-z.~]+'
-OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'(\+sip[1-9][0-9]*)?'
-OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'(-[1-9][0-9]*)?'
-OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'(\+[a-z0-9]+-[1-9][0-9]*)?'
-OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'$'
-
-_changelog_parse_error()
-{
- _line_nr="${1}"
- _error="${2}"
- shift 2
-
- _file_info=$(printf '%20s(l%d):' "${OH_SOURCE_DIR}/changelog" "${_line_nr}")
- oh_warn "${_file_info} ${_error}" "${@}"
-}
-
-_changelog_get_expect_str()
-{
- eval echo \$\{oh_str_changelog_expect_"${1}"\}
-}
-
-oh_changelog_parse()
-{
- # Parsing logic based on that of dpkg.
-
- _cb="${1}"
-
- _expect=first_heading
- _line_nr=0
- _entries=0
-
- while IFS= read _line; do
- _line_nr=$(($_line_nr + 1))
- if [ -z "${_line}" ]; then
- if [ "${_expect}" = start_changes ]; then
- OH_CHANGELOG_CHANGES="${OH_CHANGELOG_CHANGES}
-${_line}"
- elif [ "${_expect}" = next_or_eof ]; then
- :
- elif [ "${_expect}" != changes_or_trailer ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_blank_line}" \
- "$(_changelog_get_expect_str "${_expect}")"
- else
- _blank_lines="${_blank_lines}
-${_line}"
- fi
- elif [ "${_line# }" = "${_line}" ]; then
- if [ "${_expect}" != first_heading -a \
- "${_expect}" != next_or_eof ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_heading}" \
- "$(_changelog_get_expect_str "${_expect}")"
- fi
- _source="${_line%% (*}"
- _line_="${_line#* (}"
- _distribution="${_line_##*) }"
- _line_="${_line_%) *}"
- _version="${_line_}"
- if [ -z "${_source}" -o -z "${_distribution}" -o \
- -z "${_version}" -o \
- "${_version% *}" != "${_version}" ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_heading}"
- OH_CHANGELOG_SOURCE=
- OH_CHANGELOG_VERSION=
- OH_CHANGELOG_DISTRIBUTION=
- OH_CHANGELOG_CHANGES=
- else
- echo "${_source}" | \
- grep -E "${OH_SOURCE_RE}" >/dev/null 2>&1
- if [ "${?}" -ne 0 ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_source}" "${source}"
- fi
- echo "${_version}" | \
- grep -E "${OH_SOURCE_VERSION_ID_RE}" >/dev/null 2>&1
- if [ "${?}" -ne 0 ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_source_version}" "${_version}"
- fi
- OH_CHANGELOG_SOURCE="${_source}"
- OH_CHANGELOG_VERSION="${_version}"
- OH_CHANGELOG_DISTRIBUTION="${_distribution}"
- OH_CHANGELOG_CHANGES="${_line}"
- fi
- _expect=start_changes
- _blank_lines=
- elif [ "${_line# -- }" != "${_line}" ]; then
- if [ "${_expect}" != changes_or_trailer ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_trailer}" \
- "$(_changelog_get_expect_str "${_expect}")"
- fi
- _line="${_line# -- }"
- _maintainer="${_line%% *}"
- _date="${_line#* }"
- if [ -z "${_maintainer}" -o -z "${_date}" -o \
- "${_maintainer}" = "${_date}" ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_trailer}"
- OH_CHANGELOG_MAINTAINER=
- OH_CHANGELOG_DATE=
- elif [ -n "${OH_CHANGELOG_SOURCE}" ]; then
- OH_CHANGELOG_MAINTAINER="${_maintainer}"
- OH_CHANGELOG_DATE="${_date}"
- _entries=$(($_entries + 1))
- "${_cb}"
- [ ${?} -ne 0 ] && return ${_entries}
- fi
- _expect=next_or_eof
- _blank_lines=
- elif [ "${_line# --}" != "${_line}" ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_trailer}"
- elif [ "${_line## }" != "${_line}" ]; then
- if [ "${_expect}" != start_changes -a \
- "${_expect}" != changes_or_trailer ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_change}" \
- "$(_changelog_get_expect_str "${_expect}")"
- fi
- OH_CHANGELOG_CHANGES="${OH_CHANGELOG_CHANGES}
-${_blank_lines}${_line}"
- _expect=changes_or_trailer
- _blank_lines=
- else
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_line}"
- _blank_lines=
- fi
- done <"${OH_SOURCE_DIR}/changelog"
-
- if [ "${_expect}" != next_or_eof ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_eof}" \
- "$(_changelog_get_expect_str "${_expect}")"
- fi
-
- return ${_entries}
-}
diff --git a/lib/control.sh b/lib/control.sh
deleted file mode 100644
index f8d826d..0000000
--- a/lib/control.sh
+++ /dev/null
@@ -1,247 +0,0 @@
-# opkhelper
-# lib/control
-# Functions for parsing control files.
-#
-# Copyright (C) 2012 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/>.
-
-[ -n "${_OH_CONTROL_SH}" ] && return 0
-_OH_CONTROL_SH=true
-
-. @@LIBDIR@@/messages
-. @@LIBDIR@@/locale
-. @@LIBDIR@@/util
-
-# Constant global parameters:
-OH_CONTROL_SOURCE_FIELDS_REQUIRED='Maintainer'
-OH_CONTROL_SOURCE_FIELDS_OPTIONAL='Build-Depends Homepage'
-OH_CONTROL_BINARY_FIELDS_REQUIRED='Architecture Platform Priority Description'
-OH_CONTROL_BINARY_FIELDS_OPTIONAL='Essential Depends Recommends Suggests '\
-'Pre-Depends Conflicts Provides Replaces'
-OH_CONTROL_SOURCE_FIELD_MAINTAINER=
-OH_CONTROL_SOURCE_FIELD_BUILD_DEPENDS=
-OH_CONTROL_SOURCE_FIELD_HOMEPAGE=
-OH_CONTROL_BINARY_FIELD_ARCHITECTURE=
-OH_CONTROL_BINARY_FIELD_PLATFORM=
-OH_CONTROL_BINARY_FIELD_PRIORITY=
-OH_CONTROL_BINARY_FIELD_DESCRIPTION=
-OH_CONTROL_BINARY_FIELD_ESSENTIAL=
-OH_CONTROL_BINARY_FIELD_DEPENDS=
-OH_CONTROL_BINARY_FIELD_RECOMMENDS=
-OH_CONTROL_BINARY_FIELD_SUGGESTS=
-OH_CONTROL_BINARY_FIELD_PRE_DEPENDS=
-OH_CONTROL_BINARY_FIELD_CONFLICTS=
-OH_CONTROL_BINARY_FIELD_PROVIDES=
-OH_CONTROL_BINARY_FIELD_REPLACES=
-
-oh_control_parse_source()
-{
- _control_parse "${OH_SOURCE_DIR}/control" 'SOURCE'
-}
-
-oh_control_parse_binary()
-{
- _control_parse "${OH_SOURCE_DIR}/${1}.pkg/control" 'BINARY'
-}
-
-oh_control_gen_source()
-{
- _old_package="${OH_CONTROL_BINARY_FIELD_PACKAGE}"
- _old_version="${OH_BINARY_VERSION}"
- _old_architecture="${OH_CONTROL_BINARY_FIELD_ARCHITECTURE}"
- _old_recommends="${OH_CONTROL_BINARY_FIELD_RECOMMENDS}"
- _old_description="${OH_CONTROL_BINARY_FIELD_DESCRIPTION}"
-
- OH_CONTROL_BINARY_FIELD_PACKAGE="src:${OH_SOURCE}"
- OH_BINARY_VERSION="${OH_SOURCE_VERSION}"
- OH_CONTROL_BINARY_FIELD_ARCHITECTURE='all'
- OH_CONTROL_BINARY_FIELD_RECOMMENDS="${OH_CONTROL_SOURCE_FIELD_BUILD_DEPENDS}"
- OH_CONTROL_BINARY_FIELD_DESCRIPTION="${OH_SOURCE} source package"
-
- _control_gen 'SOURCE' \
- "src:${OH_SOURCE}.control/control" "src:${OH_SOURCE}.data"
-
- OH_CONTROL_BINARY_FIELD_PACKAGE="${_old_package}"
- OH_BINARY_VERSION="${_old_version}"
- OH_CONTROL_BINARY_FIELD_ARCHITECTURE="${_old_architecture}"
- OH_CONTROL_BINARY_FIELD_RECOMMENDS="${_old_recommends}"
- OH_CONTROL_BINARY_FIELD_DESCRIPTION="${_old_description}"
-}
-
-oh_control_gen_binary()
-{
- _control_gen 'BINARY' \
- "${1}.control/control" "${1}.data"
-}
-
-_control_parse()
-{
- _control="${1}"
- _type="${2}"
- _req=" $(eval echo \$\{OH_CONTROL_"${_type}"_FIELDS_REQUIRED\}) "
- _opt=" $(eval echo \$\{OH_CONTROL_"${_type}"_FIELDS_OPTIONAL\}) "
- _all="${_req}${_opt}"
- _got=' '
-
- # Initialize fields.
- for _name in ${_all}; do
- _param="OH_CONTROL_${_type}_FIELD_$(echo "${_name}" | \
- LC_CTYPE=C tr '[:lower:]-' '[:upper:]_')"
- eval "${_param}="
- done
- _param=
-
- _line_nr=0
-
- while IFS= read -r _line; do
- _line_nr=$(($_line_nr + 1))
- if [ "${_line# }" = "${_line}" ]; then
- # "Name: Value" line.
- _name="${_line%%:*}"
- _value="${_line#*: }"
- if [ -z "${_name}" -o "${_name}" = "${_line}" \
- -o -z "${_value}" ]; then
- # Badly formatted control field.
- _control_parse_error "${_control}" "${_line_nr}" \
- "${oh_str_control_bad_nv}"
- continue
- fi
- if [ "${_all% ${_name} *}" = "${_all}" ]; then
- # Unknown field.
- _control_parse_error "${_control}" "${_line_nr}" \
- "${oh_str_control_unknown_field}" \
- "${_name}"
- else
- # Remove field from list of required fields.
- _req="$(echo "${_req}" | sed "s/${_name}//")"
- fi
- if [ "${_got% ${_name} }" != "${_got}" ]; then
- # Duplicate field.
- _control_parse_error "${_control}" "${_line_nr}" \
- "${oh_str_control_duplicate_field}" \
- "${_field}"
- else
- _got="${_got}${_field} "
- fi
- _param="OH_CONTROL_${_type}_FIELD_$(echo "${_name}" | \
- LC_CTYPE=C tr '[:lower:]-' '[:upper:]_')"
- # Escape the value.
- _value="$(echo "${_value}" | sed "s/'/'\\\\''/g")"
- eval "${_param}='${_value}'"
- else
- # Continuation line.
- if [ -z "${_param}" ]; then
- # Expecting a "Name: Value" line.
- _control_parse_error "${_control}" "${_line_nr}" \
- "${oh_str_control_found_continuation}"
- continue
- fi
- _value="${_line# }"
- _value="$(echo "${_value}" | sed "s/'/'\\\\''/g")"
- eval "${_param}='${_param}
-${_value}'"
- fi
- done <"${_control}"
-
- _req="${_req## }"
- _req="${_req%% }"
- if [ -n "${_req}" ]; then
- # Missing required control fields.
- _control_parse_error "${_control}" 0 \
- "${oh_str_control_missing_fields}" \
- "$(echo "${_req}" | sed 's/ / /g' | \
- sed "s/ /${oh_str_list_item_separator}/g")"
- fi
-}
-
-_control_parse_error()
-{
- _file="${1}"
- _line_nr="${2}"
- _error="${3}"
- shift 3
-
- if [ "${_line_nr}" -eq 0 ]; then
- _file_info=$(printf '%20s:' "${_file}")
- else
- _file_info=$(printf '%20s(l%d):' "${_file}" "${_line_nr}")
- fi
- oh_warn "${_file_info} ${_error}" "${@}"
-}
-
-_control_gen()
-{
- _type="${1}"
- _control="${2}"
- _data="${3}"
-
- # TODO: Handle platforms and architectures like "any" and "any-linux-any".
-
- # Calculate installed size.
- # Don't use du, since that considers the allocated size of files, symbolic
- # links, and directories (i.e. actual file sizes plus the filesystem
- # overhead on the build system).
- # See the following for more information:
- # <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/du.html>
- # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630533>
- # <https://www.gnu.org/software/coreutils/manual/html_node/du-invocation.html>
- _sizes="$(find "${_data}" -type f -exec wc -c '{}' ';' | cut -d ' ' -f 1)"
- _inst_size=0
- for _size in ${_sizes}; do
- _inst_size=$(($_inst_size + $_size))
- done
- # Convert bytes to kibibytes and round up.
- # Note: There is an inconsistency between the Debian Policy Manual and opkg
- # in the units of this field. Debian Policy defines this field in units of
- # kibibytes:
- # The disk space is given as the integer value of the estimated installed
- # size in bytes, divided by 1024 and rounded up.
- # However, opkg apparently attempts to convert this value from bytes to
- # kibibytes in its determination of whether the package's data will fit on
- # the system:
- # pkg_size_kbs = (pkg->installed_size + 1023)/1024;
- # TODO: Further investigate opkg's disk space calculation and, if necessary,
- # patch opkg and submit a bug report.
- _inst_size=$((($_inst_size + 1023) / 1024))
-
- mkdir -p "${_control%/*}"
-
- cat >"${_control}" <<EOF
-Package: ${OH_CONTROL_BINARY_FIELD_PACKAGE}
-Source: ${OH_SOURCE}
-Version: ${OH_BINARY_VERSION}
-Architecture: ${_arch}
-EOF
-
- for _name in Essential Depends Recommends Suggests Pre-Depends Conflicts \
- Provides Replaces; do
- _param="OH_CONTROL_BINARY_FIELD_$(echo "${_name}" | \
- LC_CTYPE=C tr '[:lower:]-' '[:upper:]_')"
- _value="$(eval echo \$\{"${_param}"\})"
- if [ -n "${_value}" ]; then
- printf '%s: %s\n' "${_name}" "${_value}" >>"${_control}"
- fi
- done
-
- cat >>"${_control}" <<EOF
-Installed-Size: ${_inst_size}
-Description:$(echo "${OH_CONTROL_BINARY_FIELD_DESCRIPTION}" | sed 's/^/ /')
-EOF
-
- if [ -n "${OH_CONTROL_SOURCE_FIELD_HOMEPAGE}" ]; then
- printf '%s: %s\n' 'Homepage' "${OH_CONTROL_SOURCE_FIELD_HOMEPAGE}" \
- >>"${_control}"
- fi
-}
diff --git a/lib/locale.sh b/lib/locale.sh
deleted file mode 100644
index 6e57fc3..0000000
--- a/lib/locale.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-# opkhelper
-# lib/locale
-# Locale functions.
-#
-# Copyright (C) 2012 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/>.
-
-[ -n "${_OH_LOCALE_SH}" ] && return 0
-_OH_LOCALE_SH=true
-
-. @@LOCALEDIR@@/en_US
-
-oh_locale_set()
-{
- _locale="${1}"
-
- # Detect the system locale.
- # The test command's -z option doesn't work here?
- if [ ${#_locale} -eq 0 ]; then
- if [ -n "${LC_ALL}" ]; then
- _locale="${LC_ALL}"
- elif [ -n "${LC_MESSAGES}" ]; then
- _locale="${LC_MESSAGES}"
- elif [ -n "${LANG}" ]; then
- _locale="${LANG}"
- else
- _locale='en_US'
- fi
- fi
-
- # Try to load the locale.
- if [ -f "@@LOCALEDIR@@/${_locale%.*}" ]; then
- LC_ALL="${_locale%.*}"
- LC_MESSAGES="${LC_ALL}"
- . "@@LOCALEDIR@@/${LC_MESSAGES}"
- elif [ -f "@@LOCALEDIR@@/${_locale%_*}" ]; then
- LC_ALL="${_locale%_*}"
- LC_MESSAGES="${LC_ALL}"
- . "@@LOCALEDIR@@/${LC_MESSAGES}"
- else
- LC_ALL=en_US
- LC_MESSAGES="${LC_ALL}"
- . "@@LOCALEDIR@@/${LC_MESSAGES}"
- fi
-}
diff --git a/lib/messages.sh b/lib/messages.sh
deleted file mode 100644
index 5a2139f..0000000
--- a/lib/messages.sh
+++ /dev/null
@@ -1,85 +0,0 @@
-# opkhelper
-# lib/messages
-# Functions for printing error and warning messages.
-#
-# Copyright (C) 2012 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/>.
-
-[ -n "${_OH_MESSAGES_SH}" ] && return 0
-_OH_MESSAGES_SH=true
-
-. @@LIBDIR@@/locale
-
-# TODO: Which of these should print to the standard error stream – just
-# oh_error() and oh_warn()?
-
-oh_error()
-{
- printf '%s: Error: ' "${0##*/}"
- printf "${@}"
- printf '\n'
- exit 1
-}
-
-oh_warn()
-{
- printf '%s: Warning: ' "${0##*/}"
- printf "${@}"
- printf '\n'
- return 0
-}
-
-oh_info()
-{
- printf '%s: ' "${0##*/}"
- printf "${@}"
- printf '\n'
- return 0
-}
-
-oh_usage()
-{
- _util="$(echo "${0##*/}" | sed 's/-/_/g')"
-
- # Prevent field splitting in the evaluated echo command.
- _old_ifs="${IFS}"
- IFS=
- _usage_str="$(eval echo \$\{oh_str_usage_"${_util}"\})"
- IFS="${_old_ifs}"
-
- : "${_usage_str:=${oh_str_usage_none}}"
- printf '%s\n' "${_usage_str}"
-}
-
-oh_help()
-{
- _util="$(echo "${0##*/}" | sed 's/-/_/g')"
-
- # Prevent field splitting in the evaluated echo command.
- _old_ifs="${IFS}"
- IFS=
- _help_str="$(eval echo \$\{oh_str_help_"${_util}"\})"
- IFS="${_old_ifs}"
- : "${_help_str:=${oh_str_help_none}}"
-
- oh_usage
- printf '%s\n' "${_help_str}"
-}
-
-oh_version()
-{
- printf "${oh_str_version}\n" \
- "${0##*/}" '@@PACKAGE_NAME@@' '@@PACKAGE_VERSION@@'
-}
diff --git a/lib/util.sh b/lib/util.sh
deleted file mode 100644
index 3f348d9..0000000
--- a/lib/util.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-# opkhelper
-# lib/util
-# Common functions for utilities.
-#
-# Copyright (C) 2012 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/>.
-
-[ -n "${_OH_UTIL_SH}" ] && return 0
-_OH_UTIL_SH=true
-
-# Global parameters:
-OH_SOURCE_DIR=.
-
-oh_set_source_dir()
-{
- OH_SOURCE_DIR="${1}"
-}