diff options
48 files changed, 752 insertions, 297 deletions
diff --git a/FEATURES-BY-VERSION b/FEATURES-BY-VERSION new file mode 100644 index 0000000..567910d --- /dev/null +++ b/FEATURES-BY-VERSION @@ -0,0 +1,65 @@ +This document helps package maintainers write `Build-Depends` fields +that ensure that the installed version of opkbuild supports features +needed by a source package. Read this document from top to bottom, and +as soon as you find a criterion that applies to your source package, you +can add the specified versioned build dependency and stop reading. + +Add `opkbuild (>= 4.2.2+dev)` to your `Build-Depends` if... + + * Your binary packages don't list in their `Depends` fields the binary + package that provides source package documentation. + * Your ProteanOS source package version contains an epoch, e.g. + `1:2.0-1`. + * Any two or more of your binary packages would have the same name if + all characters except letters and numbers were removed, e.g. + `libc-1` and `libc++.1`. + +Add `opkbuild (>= 4.2.2)` to your `Build-Depends` if... + + * Any of your substitution variables are used in binary package + dependency fields and contain dependency restrictions or newline + characters. This is common for example in platform configuration + source packages that use `platconf-pkg-tools` which generates binary + package control files that get `Depends` field values from + substitution variables. + +Add `opkbuild (>= 4.2.1)` to your `Build-Depends` if... + + * Your `Build-Depends` field contains newline characters. + +Add `opkbuild (>= 4.2.0)` to your `Build-Depends` if... + + * Any of your binary packages has a `Section` field. + +Add `opkbuild (>= 4.1.4)` to your `Build-Depends` if... + + * Your ProteanOS source package version indicates an upload of a new + upstream version to a non-trunk distribution (e.g. version + `2019a-0+rs1~1`) or an upload of a backport to a non-trunk + distribution (e.g. version `3.0-2+bpu1+1`). + +Add `opkbuild (>= 4.0.2)` to your `Build-Depends` if... + + * Your ProteanOS source package upstream version contains a plus sign, + e.g. `1.4+git20141115.146bff1-1`. + +Add `opkbuild (>= 4.0.1)` to your `Build-Depends` if... + + * You use binary package substitution variables files in the build + work area, e.g. with opkhelper's oh-shlibdeps utility. If you use + oh-shlibdeps on ProteanOS, you should also add + `opkhelper-3.0 (>= 3.1.4)` to your `Build-Depends`. + +Add `opkbuild (>= 4.0.0)` to your `Build-Depends` if... + + * Your upstream source archive is compressed using xz. + +Copyright Information +--------------------- + +Copyright (C) 2023 Patrick McDermott + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without any warranty. diff --git a/Makefile.am b/Makefile.am index 3cbf383..f8219e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,6 +35,10 @@ endif # * Our release target PACKAGE_STRING = $(PACKAGE_NAME) $(PACKAGE_VERSION_GIT) +# Automake lib/am/check.am since version 1.16.3 defines this with single quotes, +# which breaks PACKAGE_VERSION_GIT above. +AM_TESTSUITE_SUMMARY_HEADER = " for $(PACKAGE_STRING)" + SUFFIXES = .sh .sho SHOBJEXT = sho @@ -63,6 +67,7 @@ helperdir = $(pkgdatadir)/helpers CLEANFILES = extra_sources = EXTRA_DIST = \ + FEATURES-BY-VERSION \ NEWS.opkhelper \ TODO \ autogen.sh \ @@ -1,8 +1,140 @@ -opkbuild version 4.1.4+dev +opkbuild version 4.2.2+dev -------------------------- Released: ????-??-?? +Utilities: + + * ob-gencontrol now automatically lists the binary package that + provides source package documentation as a dependency (with version + restrictions) of all other binary packages built from the same + source package. + +libopkbuild: + + * ProteanOS source package versions may now contain epochs. This + complies with the latest draft of SPF 2.0. + * A new ob_clean_name() function has been added. + ob_get_binary_packages() no longer complains about duplicate "clean" + binary package names such as "libc-1" and "libc++.1". This will + allow SPF 2.0 to remove the restriction on "binary package clean + names". + +Build system: + + * The test suite summary is fixed, after being broken by GNU Automake + since version 1.16.3. + +opkbuild version 4.2.2 +---------------------- + +Released: 2021-01-02 + +Utilities: + + * ob-buildopk now sets the modification time of the "control.tar.gz" + and "data.tar.gz" files after compression rather than before, + because BusyBox's gzip doesn't preserve modification times. + * ob-buildenv now adds "-ffile-prefix-map" options to CFLAGS and + CXXFLAGS. It also now sets "TZ='UTC0'" and "LC_ALL='C'". + * ob-gencontrol now reduces and normalizes binary package dependencies + after substituting variables. Otherwise, substitution variables may + contain dependency restrictions or newline characters that are + passed through to the binary package's control file. + +libopkbuild: + + * ob_iso8601_gmtime() and ob_touch_t_gmtime() no longer trigger an + infinite loop when passed times on January 1. This time bomb broke + ob-buildopk one day every year. + +Locales: + + * "C" and "POSIX" locales have been added. They are identical to the + "en_US" locale. + +opkbuild version 4.2.1 +---------------------- + +Released: 2020-12-08 + +"Now winterized to prevent freezing in December!" + +Utilities: + + * ob-gencontrol now strips newlines from "Build-Depends" fields + instead of generating invalid control files. All spacing of + dependency control fields is now normalized using ob_parse_dep(). + +libopkbuild: + + * ob_iso8601_gmtime() and ob_touch_t_gmtime() no longer trigger an + infinite loop when passed times in December. This time bomb + introduced in opkbuild version 4.1.1 broke ob-buildopk one month + every year. + +opkbuild version 4.2.0 +---------------------- + +Released: 2020-07-10 + +The major new features in this version are the utilization of package +archive sections and the architecture qualification of the names of +coinstallable packages, both necessary for multiarch (and therefore +cross building) in ProteanOS. + +Utilities: + + * ob-buildopk now correctly checks for the BusyBox tar reverse + ordering bug. + * ob-gencontrol now generates a "Format" field to indicate the source + package format version. + * ob-gencontrol now generates a "Section" field when defined for a + binary package. + * ob-genchanges now organizes source packages into section "src" + instead of "base". + * ob-genchanges now organizes binary packages into sections specified + by "Section" field when present. + * Names of packages in certain sections ("lib" on ProteanOS) are now + qualified with their host architectures (in the form + "<pkg>:<arch>"): + - ob-installdocs qualifies names in package documentation + directories. + - ob-gencontrol qualifies names in "Package" fields. + - ob-buildopk and ob-genchanges qualify names in "*.opk" file names. + * ob-buildopk no longer sets the owner and group of all data files to + 0:0, as done since version 4.1.0. This is not expected to change + file owners or groups in any ProteanOS packages at this time, + because: + - oh-fixperms (used in most packages) also sets owners and groups + - "build" makefile "install" targets are run with (fake) superuser + privileges. + * opkbuild now runs the "build" makefile's "install" target and all + ob-* commands under the same (fake) superuser environment. This was + the behavior in versions 3.0.0-alpha1 through 3.0.0-beta7. Since + version 4.0.0, commands were run in separate (fake) superuser + environments, which may not preserve superuser ownership of files. + * Source package names are now prefixed with "src:" instead of "src-". + pro-archman has supported this in its package name hashing since + version 2.0.0. + * With ob_get_binary_packages() becoming always pure (see below), all + utilities now scan the file system for binary packages only once. + +libopkbuild: + + * ob_get_source_parameter() now supports a "Format" field to get the + source package formate version. + * An optional "Section" control field has been added to source package + format 2.x. + * The modification time in manual pages is now parsed and formatted + correctly. + * New functions ob_validate_section() and ob_qualify_package_name() + have been added. + * ob_get_binary_packages() is now always pure (without side effects + that would preclude use in a subshell environment). Side effects + have been factored out into a new internal function called by + ob_init_package(). + opkbuild version 4.1.4 ---------------------- @@ -482,7 +614,7 @@ before opkbuild was split into its own package. Copyright Information --------------------- -Copyright (C) 2012-2014, 2018 Patrick McDermott +Copyright (C) 2012-2014, 2018-2021, 2023 Patrick McDermott Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -4,7 +4,50 @@ Future Tasks Functional Changes ------------------ - * ob-buildopk, ob-genchanges, ob-gencontrol, opkbuild: s/src-/src:/ + * Support a field for annotating transitional packages, to help notify + maintainers when their source packages depend on development packages for + old library SONAME versions. + - Add optional `Deprecated: yes[ <replacement-pkg>]` binary package field to + SPF 2.0. Note that this does not replace package relationship fields like + `Depends`. + - (Debian uses `Section: oldlibs` for this, but ProteanOS uses `Section` to + separate packages into smaller indices that not all systems use, so we + shouldn't just dump all transitional packages into one big section. Also, + ProteanOS uses `Section` to determine whether to architecture-qualify + names of multiarch coinstallable packages.) + - Add `Deprecated` to `lib/package/2.sh` `_OB_BINARY_FIELDS_OPTIONAL_2`. + - Add an option to opkbuild to disable build dependency deprecation + failures. Maybe replace `-D`. Set an environment variable for + ob-checkbuilddeps. + - Run `opkg info` instead of `opkg status` in ob-checkbuilddeps + `check_dep()`. If a `Deprecated` field exists, call `ob_error()` with the + name of the replacement package (if any). If build dependency deprecation + failures are enabled, exit with an error status. + * Make binary package `Description` fields architecture- and platform- + independent (so a packages index Web site can show one description for a + binary package for all its architectures and platforms). + - Specify in SPF 2.0 #substvars-defined that `Host-Arch` and `Host-Plat` + substitution variables shall not be set for `Description` fields. + - `ob_set_source_substvar()` needs a third optional (for API compatibility) + `archplat_dep` parameter (default `false`) that, if `true`, causes + variable to be stored in a separate array. + - `ob_set_package_substvars()` needs a second optional (for API + compatibility) `archplat_indep` parameter (default `false`) that, if + `false`, enables checking for variables in the aforementioned separate + array. + - In `_ob_set_package_substvars_2()`, replace: + ob_set_source_substvar 'Host-Arch' "${OPK_HOST_ARCH}" + ob_set_source_substvar 'Host-Plat' "${OPK_HOST_PLAT}" + with: + ob_set_source_substvar 'Host-Arch' "${OPK_HOST_ARCH}" true + ob_set_source_substvar 'Host-Plat' "${OPK_HOST_PLAT}" true + - In ob-gencontrol, replace: + desc="$(ob_substvars "${desc}" "${pkg}")" + with: + desc="$(ob_substvars "${desc}" "${pkg}" true)" + - Add `${Host-Arch}` (which should be copied verbatim to output control + file) to `Description` in tests **BEFORE** above changes to verify correct + behavior. * Split distribution packaging from upstream sources in source packages. - Non-native package: * `src:foo` is the distribution packaging, and it depends on @@ -22,7 +65,7 @@ Functional Changes Copyright ========= -Copyright (C) 2018, 2019 Patrick McDermott +Copyright (C) 2018, 2019, 2023 Patrick McDermott Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/config.sh.in b/config.sh.in index c7fc608..a1017f8 100644 --- a/config.sh.in +++ b/config.sh.in @@ -1,5 +1,6 @@ PACKAGE='@PACKAGE@' PACKAGE_NAME='@PACKAGE_NAME@' +SH='@SH@' FAKEROOT='@FAKEROOT@' OPKG='@OPKG@' TOUCH='@TOUCH@' diff --git a/configure.ac b/configure.ac index cf33d29..d5f35e4 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with opkbuild. If not, see <http://www.gnu.org/licenses/>. -AC_INIT([opkbuild], [4.1.4+dev], +AC_INIT([opkbuild], [4.2.2+dev], [mailto:proteanos-dev@lists.proteanos.com], [opkbuild], [http://www.proteanos.com/dev/opkbuild/]) AC_SUBST([PACKAGE_DESCRIPTION], ['opkbuild']) diff --git a/lib/control.sh b/lib/control.sh index 35913aa..76ba516 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -245,8 +245,7 @@ ob_set_binary_substvar() value="$(printf '%s' "${value}" | sed -n "${_OB_SUBSTVAR_TRIM_SED}")" # Convert package name to clean form. - package="$(printf '%s' "${package}" | tr 'A-Z' 'a-z' | \ - tr -C 'a-z0-9' '_')" + package="$(ob_clean_name "${package}")" # TODO: Maybe disallow variable names beginning with hyphens, and/or # otherwise make this safer. @@ -326,8 +325,7 @@ ob_substvars() # Perform the substitution. name_tr="$(printf '%s' "${name}" | tr 'A-Z-' 'a-z_')" - package="$(printf '%s' "${package}" | tr 'A-Z' 'a-z' | \ - tr -C 'a-z0-9' '_')" + package="$(ob_clean_name "${package}")" if eval "[ x\"\${_ob_substvar_src_${name_tr}:+set}\" = x'set' ]" then name_tr="_ob_substvar_src_${name_tr}" diff --git a/lib/deps.sh b/lib/deps.sh index 32b05e8..2dd7c10 100644 --- a/lib/deps.sh +++ b/lib/deps.sh @@ -42,7 +42,7 @@ ## the given platform. ## @operand dep req The dependency to parse. ## @return Returns 0. -## @stdout If \fB-a\fP and \fB\p\fP aren't given, the entire dependency string +## @stdout If \fB-a\fP and \fB-p\fP aren't given, the entire dependency string ## is printed, with normalized formatting. If \fB-a\fP and/or \fB-p\fP ## are given and the dependency applies to their arguments, the ## dependency string is printed, except for the architecture (if diff --git a/lib/metadata.sh b/lib/metadata.sh index da3ff60..bc7e717 100644 --- a/lib/metadata.sh +++ b/lib/metadata.sh @@ -1,6 +1,6 @@ # Functions for parsing and validating package metadata # -# Copyright (C) 2012, 2014, 2018, 2019 Patrick McDermott +# Copyright (C) 2012, 2014, 2018-2020 Patrick McDermott # # This file is part of opkbuild. # @@ -61,6 +61,25 @@ ob_validate_binary_name() return 0 } +## @brief Convert a source or binary package name to a "clean" identifier name +## @details \fBob_clean_name\fP() encodes characters in a source or binary +## package name that would be invalid in a shell variable or function +## name. This conversion is performed by the metadata plugin selected +## at libopkbuild's build time. +## @operand name req The source or binary package name to convert. +## @return Returns 0 on success. +## @stdout Prints the converted name. +## @pure yes This function has no side effects. +ob_clean_name() +{ + local name="${1}" + shift 1 || _ob_abort + + _ob_metadata_do 'clean_name' "${name}" || return ${?} + + return 0 +} + ## @brief Parse a source package version ## @details \fBob_parse_version\fP() validates and parses a source package ## version identifier using the metadata plugin selected at @@ -334,3 +353,46 @@ ob_get_system_path() return 0 } + +## @brief Validate a section name +## @details \fBob_validate_section\fP() validates a package archive section name +## against the list in the metadata plugin selected at libopkbuild's +## build time. +## @operand section req The section name to validate. +## @return Returns 0 if valid or 1 if invalid. +## @pure yes This function has no side effects. +ob_validate_section() +{ + local section="${1}" + shift 1 || _ob_abort + + _ob_metadata_do 'validate_section' "${section}" || return ${?} + + return 0 +} + +## @brief Get a possibly architecture-qualified package name +## @details \fBob_qualify_package_name\fP() qualifies the name of a binary +## package with the host architecture if the package is in a section +## whose packages are coinstallable. +## @operand name req The name of the binary package. +## @operand host_arch req The host architecture. +## @return Returns 0. +## @stdout Prints \fIname\fP, possibly followed by a colon and \fIhost_arch\fP. +## @pure yes This function has no side effects. +ob_qualify_package_name() +{ + local name="${1}" + local host_arch="${2}" + shift 2 || _ob_abort + local sect= + + sect="$(ob_get_binary_parameter "${name}" 'Section')" + if _ob_metadata_do 'section_is_coinstallable' "${sect}"; then + printf '%s:%s' "${name}" "${host_arch}" + else + printf '%s' "${name}" + fi + + return 0 +} diff --git a/lib/metadata/proteanos.sh b/lib/metadata/proteanos.sh index 2713423..6d68ccb 100644 --- a/lib/metadata/proteanos.sh +++ b/lib/metadata/proteanos.sh @@ -1,6 +1,6 @@ # Functions for parsing, validating, and retrieving metadata for ProteanOS # -# Copyright (C) 2012, 2019 Patrick McDermott +# Copyright (C) 2012, 2019-2020 Patrick McDermott # # This file is part of opkbuild. # @@ -19,6 +19,7 @@ _OB_NAME_RE_PROTEANOS='^[a-z0-9][a-z0-9+.-]+$' _OB_VERSION_RE_PROTEANOS='^' +_OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'([1-9][0-9]*:)?' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'[0-9a-z.~+]+' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'(\+sip[1-9][0-9]*)?' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'(-[0-9]+)?' @@ -69,6 +70,16 @@ _ob_validate_binary_name() return 0 } +_ob_clean_name() +{ + local name="${1}" + shift 1 || _ob_abort + + printf '%s' "${name}" | sed 's/-/_h_/g; s/+/_p_/g; s/[.]/_d_/g;' + + return 0 +} + _ob_validate_version() { local version="${1}" @@ -164,3 +175,33 @@ _ob_get_system_path() return 0 } + +_ob_validate_section() +{ + local section="${1}" + shift 1 || _ob_abort + + case "${section}" in + boot | dbg | dev | doc | lib | libdev | locale | share | util) + return 0 + ;; + *) + return 1 + ;; + esac +} + +_ob_section_is_coinstallable() +{ + local sect="${1}" + shift 1 || _ob_abort + + case "${sect}" in + 'lib') + return 0 + ;; + *) + return 1 + ;; + esac +} diff --git a/lib/output.sh b/lib/output.sh index 056c929..defadee 100644 --- a/lib/output.sh +++ b/lib/output.sh @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with opkbuild. If not, see <http://www.gnu.org/licenses/>. -## @brief Print an error message and exit +## @brief Print an error message ## @details \fBob_error\fP() prints \fIarguments\fP according to \fIformat\fP. ## @operand format req The format string. See \fBprintf\fP(1) for the syntax ## of \fIformat\fP. @@ -25,7 +25,7 @@ ## \fIformat\fP. ## @return Returns 0. ## @stderr Prints the formatted message, preceded by the program name and -## "Error:". +## "Error:" (or a translation thereof). ## @pure yes This function has no side effects. ob_error() { @@ -46,7 +46,7 @@ ob_error() ## \fIformat\fP. ## @return Returns 0. ## @stderr Prints the formatted message, preceded by the program name and -## "Warning:". +## "Warning:" (or a translation thereof). ## @pure yes This function has no side effects. ob_warn() { diff --git a/lib/package.sh b/lib/package.sh index 27ea8cb..dbf6b67 100644 --- a/lib/package.sh +++ b/lib/package.sh @@ -18,9 +18,9 @@ # along with opkbuild. If not, see <http://www.gnu.org/licenses/>. _ob_package_dir= +_ob_package_format_full= _ob_package_format= _ob_binary_packages= -_ob_got_binary_packages=false _ob_source_parameters= _ob_binary_parameters= @@ -34,6 +34,25 @@ _ob_package_do() return 0 } +_ob_find_binary_packages() +{ + local pkg= + + _ob_binary_packages='' + + for pkg in $(_ob_package_do 'get_binary_packages'); do + # Validate the name. + if ! ob_validate_binary_name "${pkg}"; then + _ob_warn_msg 'bad_binary_name' "${pkg}" + continue + fi + + _ob_binary_packages="${_ob_binary_packages} ${pkg}" + done + + return 0 +} + ## @brief Initialize libopkbuild for a source package ## @details \fBob_init_package\fP() detects the version of and parses all ## metadata of a source package. This function must be called before @@ -48,10 +67,11 @@ ob_init_package() local dir="${1}" shift 1 || _ob_abort - _ob_package_dir="$(cd -- "${dir}" && pwd)" + _ob_package_dir="$(unset CDPATH; cd -- "${dir}" && pwd)" + _ob_package_format_full="$(cat -- "${_ob_package_dir}/format")" if [ -r "${_ob_package_dir}/format" ]; then - case "$(cat -- "${_ob_package_dir}/format")" in + case "${_ob_package_format_full}" in 2.0) _ob_package_format='2' ;; @@ -63,7 +83,7 @@ ob_init_package() return 1 fi - _ob_binary_packages= + _ob_find_binary_packages _ob_package_do 'parse_package_metadata' || return ${?} @@ -78,21 +98,15 @@ ob_init_package() ## @option -a host_plat The platform by which to filter binary packages. ## @return Returns 0 on success. ## @stdout Prints the resulting list of binary packages. -## @stderr Prints warning messages on invalid binary package names and duplicate -## "clean" binary package names. -## @pure maybe This function caches a list of all binary packages to an internal -## global variable to save time and avoid repeating warning messages -## on subsequent invocations. It should therefore first be called -## outside a subshell, though this is not required. +## @stderr Prints warning messages on invalid binary package names. +## @pure yes This function has no side effects. ob_get_binary_packages() { local opt= local host_arch= local host_plat= - local pkg= - local pkgs_clean= - local pkg_clean= local pkgs= + local pkg= OPTIND=1 while getopts 'a:p:' opt; do @@ -110,38 +124,6 @@ ob_get_binary_packages() done shift $((${OPTIND} - 1)) - if ! ${_ob_got_binary_packages}; then - - _ob_package_do 'get_binary_packages' - - pkgs_clean=' ' - - for pkg in ${_ob_binary_packages}; do - - # Validate the name. - if ! ob_validate_binary_name "${pkg}"; then - _ob_warn_msg 'bad_binary_name' "${pkg}" - continue - fi - - # Make sure the "clean" name is unique. - pkg_clean="$(printf '%s' "${pkg}" | tr 'a-z' 'A-Z' | \ - tr -C 'A-Z0-9' '_')" - case "${pkgs_clean}" in *" ${pkg_clean} "*) - _ob_warn_msg 'duplicate_clean_binary_name' \ - "${pkg_clean}" - continue - esac - pkgs_clean="${pkgs_clean}${pkg_clean} " - - _ob_binary_packages="${_ob_binary_packages} ${pkgs}" - - done - - _ob_got_binary_packages=true - - fi - pkgs='' for pkg in ${_ob_binary_packages}; do @@ -184,6 +166,10 @@ ob_get_source_parameter() EOF )" + case "${name}" in 'FORMAT') + printf '%s' "${_ob_package_format_full}" + esac + # TODO: Return error on no such field? eval "printf '%s' \"\${_OB_SRCFIELD_${name}-}\"" @@ -208,9 +194,8 @@ ob_get_binary_parameter() return 1 fi - # Convert package name to its uppercase "clean" form. - package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | \ - tr -C 'A-Z0-9' '_')" + # Convert package name to clean form. + package="$(ob_clean_name "${package}")" # Convert field name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') @@ -275,16 +260,6 @@ ob_set_package_substvars() return 0 } -_ob_set_binary_packages() -{ - local packages="${1}" - shift 1 || _ob_abort - - _ob_binary_packages="${packages}" - - return 0 -} - _ob_set_source_parameter() { local name="${1}" @@ -318,9 +293,8 @@ _ob_set_binary_parameter() return 1 fi - # Convert package name to its uppercase "clean" form. - package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | \ - tr -C 'A-Z0-9' '_')" + # Convert package name to clean form. + package="$(ob_clean_name "${package}")" # Convert field name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') diff --git a/lib/package/2.sh b/lib/package/2.sh index ce96e5f..6a2b2f9 100644 --- a/lib/package/2.sh +++ b/lib/package/2.sh @@ -20,7 +20,7 @@ _OB_SOURCE_FIELDS_REQUIRED_2='Maintainer' _OB_SOURCE_FIELDS_OPTIONAL_2='Build-Depends Homepage' _OB_BINARY_FIELDS_REQUIRED_2='Architecture Platform Description' -_OB_BINARY_FIELDS_OPTIONAL_2='Essential Depends Recommends Suggests '\ +_OB_BINARY_FIELDS_OPTIONAL_2='Section Essential Depends Recommends Suggests '\ 'Pre-Depends Conflicts Provides Replaces' _ob_source_substvars_set_2=false @@ -28,6 +28,7 @@ _ob_source_substvars_set_2=false _ob_parse_package_metadata_2() { local pkg= + local sect= ob_parse_control "${_ob_package_dir}/control" _ob_srcfield_2 '' \ "${_OB_SOURCE_FIELDS_REQUIRED_2}" \ @@ -39,6 +40,11 @@ _ob_parse_package_metadata_2() _ob_binfield_2 "${pkg}" \ "${_OB_BINARY_FIELDS_REQUIRED_2}" \ "${_OB_BINARY_FIELDS_OPTIONAL_2}" + sect="$(ob_get_binary_parameter "${pkg}" 'Section')" + if [ -n "${sect}" ] && ! ob_validate_section "${sect}"; then + _ob_warn_msg 'bad_section' "${pkg}" "${sect}" + continue + fi done return 0 @@ -46,7 +52,6 @@ _ob_parse_package_metadata_2() _ob_get_binary_packages_2() { - local pkgs= local pkg_control= for pkg_control in "${_ob_package_dir}/"*'.pkg/control'; do @@ -58,14 +63,10 @@ _ob_get_binary_packages_2() pkg_control="${pkg_control%.pkg/control}" pkg_control="${pkg_control##*/}" - ob_validate_binary_name "${pkg_control}" - - pkgs="${pkgs} ${pkg_control}" + printf '%s ' "${pkg_control}" done - _ob_set_binary_packages "${pkgs}" - return 0 } diff --git a/lib/time.sh b/lib/time.sh index aa4990b..910d825 100644 --- a/lib/time.sh +++ b/lib/time.sh @@ -52,6 +52,7 @@ _ob_month_to_days() 1) d=0;; 2) d=31;; 3) d=59;; 4) d=90;; 5) d=120;; 6) d=151;; 7) d=181;; 8) d=212;; 9) d=243;; 10) d=273;; 11) d=304;; 12) d=334;; + 13)d=365;; esac [ ${month} -ge 2 ] && _ob_is_leap_year ${year} && : $((++d)) printf '%d' ${d} @@ -157,7 +158,7 @@ _ob_gmtime() while :; do _ob_is_leap_year ${year} && days_in_year=366 || days_in_year=365 - [ ${timep} -le ${days_in_year} ] && break + [ ${timep} -lt ${days_in_year} ] && break : $((timep -= ${days_in_year})) : $((year += 1)) done diff --git a/locale/en_US/libopkbuild_2.sh b/locale/C/libopkbuild_2.sh index 275177e..0dd836c 100644 --- a/locale/en_US/libopkbuild_2.sh +++ b/locale/C/libopkbuild_2.sh @@ -1,4 +1,4 @@ -# English message strings for the "libopkbuild_2" text domain +# C/POSIX/English message strings for the "libopkbuild_2" text domain # # Copyright (C) 2012, 2019 Patrick McDermott # @@ -25,7 +25,9 @@ msg_libopkbuild_2_output_info_format='%s: %s' # lib/package.sh msg_libopkbuild_2_unable_to_detect_package_format='Unable to detect package format' msg_libopkbuild_2_bad_binary_name='Bad binary package name: "%s"' -msg_libopkbuild_2_duplicate_clean_binary_name='Duplicate clean binary package name: "%s"' + +# lib/package/*.sh +msg_libopkbuild_2_bad_section='Binary package "%s" has invalid section name "%s"' # lib/control.sh msg_libopkbuild_2_control_empty_line='%s: empty line' diff --git a/locale/en_US/opkbuild.sh b/locale/C/opkbuild.sh index c0e6817..8dfc0cb 100644 --- a/locale/en_US/opkbuild.sh +++ b/locale/C/opkbuild.sh @@ -1,4 +1,4 @@ -# English message strings for the "opkbuild" text domain +# C/POSIX/English message strings for the "opkbuild" text domain # # Copyright (C) 2012, 2019 Patrick McDermott # @@ -43,7 +43,7 @@ Options: -V display the version and exit ' msg_opkbuild_version='%s (%s) %s -Copyright (C) 2012-2014, 2018-2019 Patrick McDermott +Copyright (C) 2012-2014, 2018-2020 Patrick McDermott License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff --git a/locale/POSIX b/locale/POSIX new file mode 120000 index 0000000..96d80cd --- /dev/null +++ b/locale/POSIX @@ -0,0 +1 @@ +C
\ No newline at end of file diff --git a/locale/en_US b/locale/en_US new file mode 120000 index 0000000..96d80cd --- /dev/null +++ b/locale/en_US @@ -0,0 +1 @@ +C
\ No newline at end of file diff --git a/locale/local.mk b/locale/local.mk index a18bf5e..cd14569 100644 --- a/locale/local.mk +++ b/locale/local.mk @@ -16,6 +16,10 @@ # along with opkbuild. If not, see <http://www.gnu.org/licenses/>. locale_sources = \ + locale/C/libopkbuild_2.sh \ + locale/C/opkbuild.sh \ + locale/POSIX/libopkbuild_2.sh \ + locale/POSIX/opkbuild.sh \ locale/en_US/libopkbuild_2.sh \ locale/en_US/opkbuild.sh locale_MESSAGES = $(locale_sources:.sh=.ms) diff --git a/man/local.mk b/man/local.mk index 6e6d3a2..28ee816 100644 --- a/man/local.mk +++ b/man/local.mk @@ -51,6 +51,8 @@ man3_MANS = \ %reldir%/ob_arch_is_concerned.3 \ %reldir%/ob_plat_is_concerned.3 \ %reldir%/ob_get_system_path.3 \ + %reldir%/ob_validate_section.3 \ + %reldir%/ob_qualify_package_name.3 \ %reldir%/ob_parse_control.3 \ %reldir%/ob_set_binary_substvar.3 \ %reldir%/ob_set_source_substvar.3 \ diff --git a/notes/libopkbuild.1.txt b/notes/libopkbuild.1.txt deleted file mode 100644 index 0636fe3..0000000 --- a/notes/libopkbuild.1.txt +++ /dev/null @@ -1,38 +0,0 @@ -load.sm - ob_use module -locale.sm - ob_get_text_domain - ob_set_text_domain domain - ob_set_locale_path format - ob_get_msg msgid -output.sm - ob_error format [arg]... - ob_warn format [arg]... - ob_info format [arg]... -package.sm - ob_init_package dir - ob_parse_package_metadata [-c cache_file] - ob_get_binary_packages [-a host_arch] - ob_get_source_parameter name - ob_get_binary_parameter package name - ob_summarize_package_arch - ob_summarize_package_plat - ob_get_doc_package - ob_get_doc_files -metadata.sm - ob_validate_source_name name - ob_validate_binary_name name - ob_parse_version [-u upstreamver_var] [-d distrev_var] version - ob_get_system_arch - ob_match_arch arch arch_field - ob_get_system_plat - ob_match_plat plat plat_field - ob_get_system_path path_id [arg]... -control.sm - ob_parse_control file field_cb req_fields opt_fields -changelog.sm - ob_parse_changelog file entry_cb -deps.sm - ob_parse_dep [-p pkg_var] [-q archqual_var] - [-r rel_var] [-v ver_var] [-A arches_var | -a host_arch] dep - ob_reduce_deps [-a host_arch] [-u] deps diff --git a/notes/opkbuild.txt b/notes/opkbuild.txt deleted file mode 100644 index 4240ef6..0000000 --- a/notes/opkbuild.txt +++ /dev/null @@ -1,41 +0,0 @@ -init locale -get options -test UID0 command - -detect build system arch/plat -set host system arch/plat - -init source package - -make work area - -parse package metadata - -build source package - -reduce build dependencies -check build dependencies - -build list of packages to be built for host arch - -set up package build helper -set up toolchain -set up build flags - -unpack sources -apply patches -install platconf - -../build build -uid0_cmd ../build install - -install docs -gen control -install scripts -gen conffiles -gen md5sums -build opk - -clean work area - -gen changes diff --git a/scripts/announce-release.sh b/scripts/announce-release.sh index f27e0cb..5070f50 100755 --- a/scripts/announce-release.sh +++ b/scripts/announce-release.sh @@ -6,7 +6,7 @@ SIG="$(cat <<-EOF Patrick McDermott, CEO Libiquity Putting customers in control of high-quality technologies - http://www.libiquity.com/ + https://www.libiquity.com/ EOF )" KEY='2250 31F0 47FF E516 63ED 516F 1A45 9ECD E4D6 04BE' diff --git a/src/ob-buildenv.sh b/src/ob-buildenv.sh index 6d42851..0657d09 100644 --- a/src/ob-buildenv.sh +++ b/src/ob-buildenv.sh @@ -84,6 +84,12 @@ setup_build_flags() if [ -r "${build_flags}" ]; then . "${build_flags}" fi + printf "CFLAGS='%s %s'\\n" "${CFLAGS:-}" \ + "-ffile-prefix-map=${PWD}=." + printf "CXXFLAGS='%s %s'\\n" "${CXXFLAGS:-}" \ + "-ffile-prefix-map=${PWD}=." + printf "TZ='UTC0'\\n" + printf "LC_ALL='C'\\n" return 0 } diff --git a/src/ob-buildopk.sh b/src/ob-buildopk.sh index 598419f..dc88758 100644 --- a/src/ob-buildopk.sh +++ b/src/ob-buildopk.sh @@ -27,12 +27,20 @@ build_opk() local plat="${4}" local date="${5}" shift 5 + local binary_qual= local find_not_link= local touch_noderef= local sort_r= + if [ "x${arch}" = 'xsrc' ]; then + binary_qual="${binary}" + else + binary_qual="$(ob_qualify_package_name "${binary}" \ + "${OPK_HOST_ARCH}")" + fi + ob_info "$(ob_get_msg 'build_opk')" \ - "${binary}_${version}_${arch}_${plat}.opk" + "${binary_qual}_${version}_${arch}_${plat}.opk" mkdir -p '.opkbuild' @@ -57,7 +65,7 @@ build_opk() # order. touch '.opkbuild/a' '.opkbuild/b' if [ x"$(printf '.opkbuild/a\n.opkbuild/b\n' | ${TAR} -c -T - | \ - ${TAR} -t | head -n 1)" = x'b' ]; then + ${TAR} -t | head -n 1)" = x'.opkbuild/b' ]; then sort_r='-r' else sort_r='' @@ -69,22 +77,27 @@ build_opk() # This utility runs with (fake) privileges, so we can chown what we're # about to tar. - find "${binary}.control" "${binary}.data" | xargs chown -h 0:0 + if [ "x${arch}" = 'xsrc' ]; then + find "${binary}.control" "${binary}.data" | xargs chown -h 0:0 + else + find "${binary}.control" | xargs chown -h 0:0 + fi (cd -- "${binary}.control" && find '.' | LC_ALL=C sort ${sort_r} | \ ${TAR} -cf '../control.tar' --no-recursion -T -) (cd -- "${binary}.data" && find '.' | LC_ALL=C sort ${sort_r} | \ ${TAR} -cf '../data.tar' --no-recursion -T -) - ${TOUCH} -t "${date}" 'control.tar' 'data.tar' ${GZIP} 'control.tar' 'data.tar' + ${TOUCH} -t "${date}" 'control.tar.gz' 'data.tar.gz' - ${TAR} -cf "../../${binary}_${version}_${arch}_${plat}.tar" \ + ${TAR} -cf "../../${binary_qual}_${version}_${arch}_${plat}.tar" \ 'debian-binary' 'control.tar.gz' 'data.tar.gz' rm -Rf 'control.tar.gz' 'data.tar.gz' - ${TOUCH} -t "${date}" "../../${binary}_${version}_${arch}_${plat}.tar" - ${GZIP} "../../${binary}_${version}_${arch}_${plat}.tar" - mv "../../${binary}_${version}_${arch}_${plat}.tar.gz" \ - "../../${binary}_${version}_${arch}_${plat}.opk" + ${TOUCH} -t "${date}" \ + "../../${binary_qual}_${version}_${arch}_${plat}.tar" + ${GZIP} "../../${binary_qual}_${version}_${arch}_${plat}.tar" + mv "../../${binary_qual}_${version}_${arch}_${plat}.tar.gz" \ + "../../${binary_qual}_${version}_${arch}_${plat}.opk" return 0 } @@ -108,7 +121,7 @@ main() printf '2.0\n' >'debian-binary' ${TOUCH} -t "${date}" 'debian-binary' if [ x"${OB_DO_SOURCE:+set}" = x'set' ]; then - build_opk "src-${OPK_SOURCE}" "${OPK_SOURCE_VERSION}" \ + build_opk "src:${OPK_SOURCE}" "${OPK_SOURCE_VERSION}" \ 'src' 'all' "${date}" else for pkg in ${OPK_PACKAGES_REDUCED}; do diff --git a/src/ob-genchanges.sh b/src/ob-genchanges.sh index 9e8c75a..323f417 100644 --- a/src/ob-genchanges.sh +++ b/src/ob-genchanges.sh @@ -31,7 +31,10 @@ write_changes() printf 'Format: 1.0\n' >&3 printf 'Source: %s\n' "${OPK_SOURCE}" >&3 - printf 'Binary: %s\n' "$(ob_get_binary_packages)" >&3 + printf 'Binary:' >&3 + printf '%s\n' $(ob_get_binary_packages) | LC_ALL='C' sort | \ + xargs printf ' %s' >&3 + printf '\n' >&3 printf 'Version: %s\n' "${version}" >&3 printf 'Architecture: %s\n' "${arch}" >&3 printf 'Platform: %s\n' "${plat}" >&3 @@ -63,10 +66,10 @@ write_files_src() local file= printf 'Files:\n' >&3 - file="src-${OPK_SOURCE}_${OPK_SOURCE_VERSION}_src_all.opk" + file="src:${OPK_SOURCE}_${OPK_SOURCE_VERSION}_src_all.opk" printf ' %s %s %s\n' \ "$(wc -c "../../${file}" | cut -d ' ' -f 1)" \ - 'base' "${file}" >&3 + 'src' "${file}" >&3 return 0 } @@ -76,6 +79,7 @@ write_files_bin() local pkg= local arch= local plat= + local sect= local file= printf 'Files:\n' >&3 @@ -84,10 +88,13 @@ write_files_bin() [ x"${arch}" != x'all' ] && arch="${OPK_HOST_ARCH}" plat="$(ob_get_binary_parameter "${pkg}" 'Platform')" [ x"${plat}" != x'all' ] && plat="${OPK_HOST_PLAT}" - file="${pkg}_${OPK_BINARY_VERSION}_${arch}_${plat}.opk" + sect="$(ob_get_binary_parameter "${pkg}" 'Section')" + [ x"${sect}" = x'' ] && sect='base' + file="$(ob_qualify_package_name "${pkg}" "${OPK_HOST_ARCH}")" + file="${file}_${OPK_BINARY_VERSION}_${arch}_${plat}.opk" printf ' %s %s %s\n' \ "$(wc -c "../../${file}" | cut -d ' ' -f 1)" \ - 'base' "${file}" >&3 + "${sect}" "${file}" >&3 done return 0 diff --git a/src/ob-gencontrol.sh b/src/ob-gencontrol.sh index 172f50f..f88508c 100644 --- a/src/ob-gencontrol.sh +++ b/src/ob-gencontrol.sh @@ -1,6 +1,6 @@ # Generate a control directory with a control file and scripts # -# Copyright (C) 2012, 2019 Patrick McDermott +# Copyright (C) 2012, 2019, 2023-2024 Patrick McDermott # # This file is part of opkbuild. # @@ -67,14 +67,17 @@ gen_control_src() local binary= local name= local value= + local deps= + local dep= local homepage= - binary="src-${OPK_SOURCE}" + binary="src:${OPK_SOURCE}" mkdir -p -- "${binary}.control" + exec 3>"${binary}.control/control" - cat >"${binary}.control/control" <<-EOF - Package: src-${OPK_SOURCE} + cat >&3 <<-EOF + Package: src:${OPK_SOURCE} Source: ${OPK_SOURCE} Binary:$(printf '%s\n' $(ob_get_binary_packages) | \ LC_ALL='C' sort | xargs printf ' %s') @@ -90,23 +93,30 @@ gen_control_src() if [ -z "${value}" ]; then continue fi - value="$(ob_substvars "${value}")" - printf '%s: %s\n' "${name}" "${value}" | \ - sed 's/[, ]*$//' \ - >>"${binary}.control/control" + deps='' + IFS=',' + for dep in ${value}; do + unset IFS + deps="${deps}$(ob_parse_dep "${dep}"), " + done + unset IFS + value="$(ob_substvars "${deps}")" + printf '%s: %s\n' "${name}" "${deps}" | sed 's/[, ]*$//' >&3 done - cat >>"${binary}.control/control" <<-EOF - Installed-Size: $(calc_inst_size "src-${OPK_SOURCE}") + cat >&3 <<-EOF + Installed-Size: $(calc_inst_size "src:${OPK_SOURCE}") + Format: $(ob_get_source_parameter 'Format') Description: ${OPK_SOURCE} source package EOF homepage="$(ob_get_source_parameter 'Homepage')" if [ -n "${homepage}" ]; then - printf '%s: %s\n' 'Homepage' "${homepage}" \ - >>"${binary}.control/control" + printf '%s: %s\n' 'Homepage' "${homepage}" >&3 fi + exec 3>&- + return 0 } @@ -118,67 +128,96 @@ gen_control_bin() local plat="${4}" local desc="${5}" shift 5 - local name= + local binary_qual= local value= + local doc_pkg= + local doc_pkg_q= + local doc_dep= + local name= local homepage= mkdir -p -- "${binary}.control" + exec 3>"${binary}.control/control" - cat >"${binary}.control/control" <<-EOF - Package: ${binary} + binary_qual="$(ob_qualify_package_name "${binary}" "${OPK_HOST_ARCH}")" + + cat >&3 <<-EOF + Package: ${binary_qual} Source: ${OPK_SOURCE} Version: ${version} Architecture: ${arch} Platform: ${plat} + EOF + value="$(ob_get_binary_parameter "${binary}" 'Section')" + if [ -n "${value}" ]; then + cat >&3 <<-EOF + Section: ${value} + EOF + fi + cat >&3 <<-EOF Maintainer: $(ob_get_source_parameter 'Maintainer' | \ tr '\n' ' ') EOF - if :; then - for name in Essential Depends Recommends Suggests Pre-Depends \ - Conflicts Provides Replaces; do - value="$(ob_get_binary_parameter "${binary}" "${name}")" - if [ -z "${value}" ]; then - continue - fi - case "${name}" in - 'Essential') - ;; - 'Depends' | 'Recommends' | \ - 'Suggests' | 'Pre-Depends') - value="$(ob_reduce_deps \ - -a "${OPK_HOST_ARCH}" \ - -p "${OPK_HOST_PLAT}" \ - -- "${value}")" - value="$(ob_substvars "${value}" \ - "${binary}")" - ;; - 'Conflicts' | 'Provides' | 'Replaces') - value="$(ob_reduce_deps \ - -a "${OPK_HOST_ARCH}" \ - -p "${OPK_HOST_PLAT}" \ - -u -- "${value}")" - value="$(ob_substvars "${value}" \ - "${binary}")" - ;; - esac - printf '%s: %s\n' "${name}" "${value}" | \ - sed 's/[, ]*$//' \ - >>"${binary}.control/control" - done + if ! doc_pkg="$(ob_get_doc_package)"; then + ob_error "$(ob_get_msg 'cant_get_doc_pkg')" + return 1 fi + doc_pkg_q="$(ob_qualify_package_name "${doc_pkg}" "${OPK_HOST_ARCH}")" + if [ x"$(ob_get_binary_parameter "${doc_pkg}" 'Architecture')" \ + = x'all' ]; then + doc_dep="${doc_pkg_q} (= ${OPK_SOURCE_VERSION})" + elif [ x"$(ob_get_binary_parameter "${binary}" 'Architecture')" \ + = x'all' ]; then + doc_dep="${doc_pkg_q} (>= ${OPK_SOURCE_VERSION}), $(: \ + )${doc_pkg_q} (<< ${OPK_SOURCE_VERSION}.~)" + else + doc_dep="${doc_pkg_q} (= ${OPK_BINARY_VERSION})" + fi + + for name in Essential Depends Recommends Suggests Pre-Depends \ + Conflicts Provides Replaces; do + value="$(ob_get_binary_parameter "${binary}" "${name}")" + if [ x"${name}" = x'Depends' ] && + [ x"${binary_qual}" != x"${doc_pkg_q}" ]; then + value="${doc_dep}, ${value}" + fi + if [ -z "${value}" ]; then + continue + fi + case "${name}" in + 'Essential') + ;; + 'Depends' | 'Recommends' | 'Suggests' | 'Pre-Depends') + value="$(ob_substvars "${value}" "${binary}")" + value="$(ob_reduce_deps \ + -a "${OPK_HOST_ARCH}" \ + -p "${OPK_HOST_PLAT}" \ + -- "${value}")" + ;; + 'Conflicts' | 'Provides' | 'Replaces') + value="$(ob_substvars "${value}" "${binary}")" + value="$(ob_reduce_deps \ + -a "${OPK_HOST_ARCH}" \ + -p "${OPK_HOST_PLAT}" \ + -u -- "${value}")" + ;; + esac + printf '%s: %s\n' "${name}" "${value}" | sed 's/[, ]*$//' >&3 + done - cat >>"${binary}.control/control" <<-EOF + cat >&3 <<-EOF Installed-Size: $(calc_inst_size "${binary}") Description:$(printf '%s' "${desc}" | sed 's/^/ /') EOF homepage="$(ob_get_source_parameter 'Homepage')" if [ -n "${homepage}" ]; then - printf '%s: %s\n' 'Homepage' "${homepage}" \ - >>"${binary}.control/control" + printf '%s: %s\n' 'Homepage' "${homepage}" >&3 fi + exec 3>&- + return 0 } @@ -268,9 +307,9 @@ main() ob_init_package '..' || return 1 if [ x"${OB_DO_SOURCE:+set}" = x'set' ]; then - ob_info "$(ob_get_msg 'gen_control')" "src-${OPK_SOURCE}" + ob_info "$(ob_get_msg 'gen_control')" "src:${OPK_SOURCE}" gen_control_src - gen_md5sums "src-${OPK_SOURCE}" + gen_md5sums "src:${OPK_SOURCE}" else for pkg in ${OPK_PACKAGES_REDUCED}; do ob_info "$(ob_get_msg 'gen_control')" "${pkg}" diff --git a/src/ob-installdocs.sh b/src/ob-installdocs.sh index f07bfb8..a662a94 100644 --- a/src/ob-installdocs.sh +++ b/src/ob-installdocs.sh @@ -79,11 +79,14 @@ main() return 1 fi doc_pkg_doc_dir="$(ob_get_system_path 'package-docs' \ - "${doc_pkg}" "${OPK_BINARY_VERSION}")" + "$(ob_qualify_package_name "${doc_pkg}" "${OPK_HOST_ARCH}")" \ + "${OPK_BINARY_VERSION}")" for pkg in ${OPK_PACKAGES_REDUCED}; do doc_dir="$(ob_get_system_path 'package-docs' \ - "${pkg}" "${OPK_BINARY_VERSION}")" + "$(ob_qualify_package_name "${pkg}" \ + "${OPK_HOST_ARCH}")" \ + "${OPK_BINARY_VERSION}")" data_doc_dir="${pkg}.data/${doc_dir%/}" if [ x"${pkg}" = x"${doc_pkg}" ]; then if [ -d "${data_doc_dir}" ]; then diff --git a/src/opkbuild.sh b/src/opkbuild.sh index e6dc730..5b368fc 100644 --- a/src/opkbuild.sh +++ b/src/opkbuild.sh @@ -253,7 +253,7 @@ build_source() src="$(ob_get_source_parameter 'Source')" ver="$(ob_get_source_parameter 'Version')" - src_pkg_data_base="src-${src}.data$(ob_get_system_path \ + src_pkg_data_base="src:${src}.data$(ob_get_system_path \ 'package-source' "${src}" "${ver}")" if ! mkdir -p -- "${src_pkg_data_base}"; then @@ -287,7 +287,7 @@ build_source() return 1 fi - if ! rm -Rf "src-${src}.data"; then + if ! rm -Rf "src:${src}.data"; then ob_error "$(ob_get_msg 'cant_rm_src_pkg_data')" return 1 fi @@ -351,13 +351,16 @@ build() { case "${opt_target}" in '') - ../build build && - ${opt_uid0_cmd} -- ../build install && - ${opt_uid0_cmd} -- "${bindir}/ob-installdocs" && - ${opt_uid0_cmd} -- "${bindir}/ob-gencontrol" && - ${opt_uid0_cmd} -- "${bindir}/ob-buildopk" && - ${opt_uid0_cmd} -- "${bindir}/ob-genchanges" || + if ! ../build build || ! ${opt_uid0_cmd} -- ${SH} <<-EOF + ../build install && + "${bindir}/ob-installdocs" && + "${bindir}/ob-gencontrol" && + "${bindir}/ob-buildopk" && + "${bindir}/ob-genchanges" + EOF + then return 1 + fi ;; 'install'|'install-'*) if ! ${opt_uid0_cmd} -- ../build -- "${opt_target}" @@ -421,8 +424,8 @@ main() if [ x"${opt_build}" != x'source' ]; then print_arch_stats - if "${opt_check_build_deps}"; then - if ! "${bindir}/ob-checkbuilddeps"; then + if ! "${bindir}/ob-checkbuilddeps"; then + if "${opt_check_build_deps}"; then return 1 fi fi diff --git a/tests/aux/common.sh b/tests/aux/common.sh index 3ea3740..effc208 100644 --- a/tests/aux/common.sh +++ b/tests/aux/common.sh @@ -86,8 +86,8 @@ export OPK_SOURCE='foo' export OPK_SOURCE_VERSION='1.0-1' export OPK_SOURCE_VERSION_UPSTREAM='1.0' export OPK_BINARY_VERSION='1.0-1' -export OPK_PACKAGES='foo baz-qux bar' -export OPK_PACKAGES_REDUCED='foo baz-qux bar' +export OPK_PACKAGES='foo baz+qux baz-qux bar' +export OPK_PACKAGES_REDUCED='foo baz+qux baz-qux bar' # Section 7.3.2 Build and Host System Variables # OPK_BUILD_ARCH_GNU and OPK_HOST_ARCH_GNU aren't set or used by opkbuild # utilities. These should be removed from the SPF. diff --git a/tests/data/pkg/bar.pkg/control b/tests/data/pkg/bar.pkg/control index b0c05fa..93c1198 100644 --- a/tests/data/pkg/bar.pkg/control +++ b/tests/data/pkg/bar.pkg/control @@ -1,5 +1,6 @@ -Architecture: all +Architecture: any Platform: all +Section: util Description: Bit-bang All Registers ${Common-Description} . diff --git a/tests/data/pkg/baz+qux.pkg/control b/tests/data/pkg/baz+qux.pkg/control new file mode 100644 index 0000000..1ecae47 --- /dev/null +++ b/tests/data/pkg/baz+qux.pkg/control @@ -0,0 +1,8 @@ +Architecture: all +Platform: all +Depends: ${Generated-Depends} +Description: Add all the things + ${Common-Description} + . + This package's name contains a plus sign, not to be confused with the one that + instead contains a hyphen. diff --git a/tests/data/pkg/build b/tests/data/pkg/build index dbc550a..abbfe8f 100755 --- a/tests/data/pkg/build +++ b/tests/data/pkg/build @@ -5,4 +5,5 @@ build: install: build install -p -m 755 -D src/src/foo.sh foo.data/usr/bin/foo.sh printf 'Generated-Depends: bar\n' >foo.substvars + printf 'Generated-Depends: bar\n' >baz+qux.substvars printf 'Generated-Depends: bar\n' >baz-qux.substvars diff --git a/tests/data/pkg/control b/tests/data/pkg/control index 3165de1..f8717ef 100644 --- a/tests/data/pkg/control +++ b/tests/data/pkg/control @@ -1,2 +1,3 @@ Maintainer: "J. Random Hacker" <jrandom@example.com> -Build-Depends: build-all-runes +Build-Depends: build-all-runes, quiet-untuned-xylophone, + something-completely-different, diff --git a/tests/data/pkg/foo.pkg/control b/tests/data/pkg/foo.pkg/control index b383ff9..a0320b7 100644 --- a/tests/data/pkg/foo.pkg/control +++ b/tests/data/pkg/foo.pkg/control @@ -1,5 +1,6 @@ Architecture: any-linux-any Platform: all +Section: lib Depends: ${Generated-Depends} Description: Frobnicator of Objects ${Common-Description} diff --git a/tests/exe/ob-buildenv.sh b/tests/exe/ob-buildenv.sh index 3720207..29235c0 100755 --- a/tests/exe/ob-buildenv.sh +++ b/tests/exe/ob-buildenv.sh @@ -41,4 +41,8 @@ cmd_is 'ob-buildenv' ob-buildenv <<-EOF STRINGS='i686-linux-glibc-strings' STRIP='i686-linux-glibc-strip' OPK_TOOL_PREFIX='i686-linux-glibc-' + CFLAGS=' -ffile-prefix-map=${PWD}=.' + CXXFLAGS=' -ffile-prefix-map=${PWD}=.' + TZ='UTC0' + LC_ALL='C' EOF diff --git a/tests/exe/ob-buildopk.sh b/tests/exe/ob-buildopk.sh index 020824a..ca0c7ee 100755 --- a/tests/exe/ob-buildopk.sh +++ b/tests/exe/ob-buildopk.sh @@ -43,14 +43,14 @@ plan_ 9 rm -Rf *'.data/' *'.control/' mkdir -p 'foo.data/usr/bin/' 'bar.data/' 'foo.control/' 'bar.control/' \ - 'baz-qux.data/' 'baz-qux.control/' + 'baz+qux.data/' 'baz+qux.control/' 'baz-qux.data/' 'baz-qux.control/' cp -p '../../src/src/foo.sh' 'foo.data/usr/bin/' touch 'foo.control/control' 'foo.control/md5sums' \ 'bar.control/control' 'bar.control/md5sums' command_ok_ 'ob-buildopk exit status' -- "${FAKEROOT}" ob-buildopk -for opk in '../../foo_1.0-1_i686-linux-glibc_all.opk' \ - '../../bar_1.0-1_all_all.opk'; do +for opk in '../../foo:i686-linux-glibc_1.0-1_i686-linux-glibc_all.opk' \ + '../../bar_1.0-1_i686-linux-glibc_all.opk'; do command_ok_ 'opk exists' -- [ -f "${opk}" ] cmd_is 'outer archive contents' ls_outer "${opk}" <<-EOF debian-binary @@ -64,13 +64,14 @@ for opk in '../../foo_1.0-1_i686-linux-glibc_all.opk' \ EOF done cmd_is 'data.tar.gz contents' \ - ls_inner '../../foo_1.0-1_i686-linux-glibc_all.opk' data.tar.gz <<-EOF + ls_inner '../../foo:i686-linux-glibc_1.0-1_i686-linux-glibc_all.opk' \ + data.tar.gz <<-EOF ./ ./usr/ ./usr/bin/ ./usr/bin/foo.sh EOF cmd_is 'data.tar.gz contents' \ - ls_inner '../../bar_1.0-1_all_all.opk' data.tar.gz <<-EOF + ls_inner '../../bar_1.0-1_i686-linux-glibc_all.opk' data.tar.gz <<-EOF ./ EOF diff --git a/tests/exe/ob-genchanges.sh b/tests/exe/ob-genchanges.sh index c0e38fc..7fc8ec8 100755 --- a/tests/exe/ob-genchanges.sh +++ b/tests/exe/ob-genchanges.sh @@ -24,15 +24,16 @@ set -eu plan_ 2 ->'../../foo_1.0-1_i686-linux-glibc_all.opk' ->'../../bar_1.0-1_all_all.opk' +>'../../foo:i686-linux-glibc_1.0-1_i686-linux-glibc_all.opk' +>'../../bar_1.0-1_i686-linux-glibc_all.opk' +>'../../baz+qux_1.0-1_all_all.opk' >'../../baz-qux_1.0-1_all_all.opk' command_ok_ 'ob-genchanges exit status' -- ob-genchanges cmd_is 'changes file' cat '../../foo_1.0-1_i686-linux-glibc_x60.changes' <<-EOF Format: 1.0 Source: foo - Binary: bar baz-qux foo + Binary: bar baz+qux baz-qux foo Version: 1.0-1 Architecture: i686-linux-glibc Platform: x60 @@ -42,13 +43,15 @@ cmd_is 'changes file' cat '../../foo_1.0-1_i686-linux-glibc_x60.changes' <<-EOF Date: Thu, 01 Jan 1970 01:00:00 +0000 Description: bar - Bit-bang All Registers + baz+qux - Add all the things baz-qux - Hyphenate all the things foo - Frobnicator of Objects Changes: foo (1.0-1) trunk * Initial release. Files: - 0 base foo_1.0-1_i686-linux-glibc_all.opk + 0 lib foo:i686-linux-glibc_1.0-1_i686-linux-glibc_all.opk + 0 base baz+qux_1.0-1_all_all.opk 0 base baz-qux_1.0-1_all_all.opk - 0 base bar_1.0-1_all_all.opk + 0 util bar_1.0-1_i686-linux-glibc_all.opk EOF diff --git a/tests/exe/ob-gencontrol.sh b/tests/exe/ob-gencontrol.sh index a619856..309e28a 100755 --- a/tests/exe/ob-gencontrol.sh +++ b/tests/exe/ob-gencontrol.sh @@ -22,20 +22,22 @@ set -eu . "${TOP_SRCDIR}/tests/aux/tap-functions.sh" . "${TOP_SRCDIR}/tests/aux/common.sh" -plan_ 12 +plan_ 14 OB_DO_SOURCE='true' command_ok_ 'ob-gencontrol source package exit status' -- \ ob-gencontrol -cmd_is 'source package control file' cat 'src-foo.control/control' <<-EOF - Package: src-foo +cmd_is 'source package control file' cat 'src:foo.control/control' <<-EOF + Package: src:foo Source: foo - Binary: bar baz-qux foo + Binary: bar baz+qux baz-qux foo Version: 1.0-1 Architecture: src Platform: all Maintainer: "J. Random Hacker" <jrandom@example.com> - Build-Depends: build-all-runes + Build-Depends: build-all-runes, quiet-untuned-xylophone, $(: \ + )something-completely-different Installed-Size: 0 + Format: 2.0 Description: foo source package EOF @@ -45,12 +47,13 @@ cp -Rp '../../src/' 'src/' for run in 'first' 'second'; do command_ok_ "ob-gencontrol ${run} run exit status" -- ob-gencontrol - cmd_is 'control file' cat 'foo.control/control' <<-EOF - Package: foo + cmd_is "${run} run foo control file" cat 'foo.control/control' <<-EOF + Package: foo:i686-linux-glibc Source: foo Version: 1.0-1 Architecture: i686-linux-glibc Platform: all + Section: lib Maintainer: "J. Random Hacker" <jrandom@example.com> Depends: bar Installed-Size: 1 @@ -61,16 +64,18 @@ for run in 'first' 'second'; do . This package provides a frobnicator of objects. EOF - cmd_is 'md5sums file' cat 'foo.control/md5sums' <<-EOF + cmd_is "${run} run foo md5sums file" cat 'foo.control/md5sums' <<-EOF 582b7bd410b9e196dfb0a706ac95bf23 /usr/bin/foo.sh EOF - cmd_is 'control file' cat 'bar.control/control' <<-EOF + cmd_is "${run} run bar control file" cat 'bar.control/control' <<-EOF Package: bar Source: foo Version: 1.0-1 - Architecture: all + Architecture: i686-linux-glibc Platform: all + Section: util Maintainer: "J. Random Hacker" <jrandom@example.com> + Depends: foo:i686-linux-glibc (= 1.0-1) Installed-Size: 0 Description: Bit-bang All Registers This is a frobnicator of objects. Conveniently, it also $(: \ @@ -79,14 +84,36 @@ for run in 'first' 'second'; do . This package assists in bit-banging all yer registers. EOF - cmd_is 'control file' cat 'baz-qux.control/control' <<-EOF + cmd_is "${run} run baz+qux control file" cat 'baz+qux.control/control' \ + <<-EOF + Package: baz+qux + Source: foo + Version: 1.0-1 + Architecture: all + Platform: all + Maintainer: "J. Random Hacker" <jrandom@example.com> + Depends: foo:i686-linux-glibc (>= 1.0-1), $(: \ + )foo:i686-linux-glibc (<< 1.0-1.~), bar + Installed-Size: 0 + Description: Add all the things + This is a frobnicator of objects. Conveniently, it also $(: \ + )bit-bangs all + registers. + . + This package's name contains a plus sign, not to be $(: \ + )confused with the one that + instead contains a hyphen. + EOF + cmd_is "${run} baz-qux foo control file" cat 'baz-qux.control/control' \ + <<-EOF Package: baz-qux Source: foo Version: 1.0-1 Architecture: all Platform: all Maintainer: "J. Random Hacker" <jrandom@example.com> - Depends: bar + Depends: foo:i686-linux-glibc (>= 1.0-1), $(: \ + )foo:i686-linux-glibc (<< 1.0-1.~), bar Installed-Size: 0 Description: Hyphenate all the things This is a frobnicator of objects. Conveniently, it also $(: \ diff --git a/tests/exe/ob-installdocs.sh b/tests/exe/ob-installdocs.sh index 96c3244..d55f116 100755 --- a/tests/exe/ob-installdocs.sh +++ b/tests/exe/ob-installdocs.sh @@ -22,20 +22,24 @@ set -eu . "${TOP_SRCDIR}/tests/aux/tap-functions.sh" . "${TOP_SRCDIR}/tests/aux/common.sh" -plan_ 10 +plan_ 11 rm -Rf *'.data/' command_ok_ 'ob-installdocs first run exit status' -- ob-installdocs for f in 'copyright' 'changelog.dist' 'README.upstream'; do command_ok_ "${f} file installed" -- \ - [ -f "foo.data/usr/share/doc/foo/${f}" ] + [ -f "foo.data/usr/share/doc/foo:i686-linux-glibc/${f}" ] done command_ok_ 'link created' -- [ -L 'bar.data/usr/share/doc/bar' ] command_ok_ 'ob-installdocs second run exit status' -- ob-installdocs for f in 'copyright' 'changelog.dist' 'README.upstream'; do command_ok_ "${f} file installed" -- \ - [ -f "foo.data/usr/share/doc/foo/${f}" ] + [ -f "foo.data/usr/share/doc/foo:i686-linux-glibc/${f}" ] done command_ok_ 'link created' -- [ -L 'bar.data/usr/share/doc/bar' ] + +command_ok_ 'link destination' -- \ + [ "x$(ls -l 'bar.data/usr/share/doc/bar' | sed 's/^.* -> //')" = \ + "x/usr/share/doc/foo:i686-linux-glibc" ] diff --git a/tests/exe/opkbuild.sh b/tests/exe/opkbuild.sh index b569986..d113e5b 100755 --- a/tests/exe/opkbuild.sh +++ b/tests/exe/opkbuild.sh @@ -49,9 +49,9 @@ rm -Rf 'src/' 'tmp/' cp -Rp '../src/' 'src/' command_ok_ 'opkbuild exit status' -- opkbuild -a i686-linux-glibc -p x60 -dc -for opk in '../src-foo_1.0-1_src_all.opk' \ - '../foo_1.0-1_i686-linux-glibc_all.opk' \ - '../bar_1.0-1_all_all.opk'; do +for opk in '../src:foo_1.0-1_src_all.opk' \ + '../foo:i686-linux-glibc_1.0-1_i686-linux-glibc_all.opk' \ + '../bar_1.0-1_i686-linux-glibc_all.opk'; do command_ok_ 'opk exists' -- [ -f "${opk}" ] cmd_is 'outer archive contents' ls_outer "${opk}" <<-EOF debian-binary @@ -60,38 +60,40 @@ for opk in '../src-foo_1.0-1_src_all.opk' \ EOF done cmd_is 'control.tar.gz contents' \ - ls_inner '../src-foo_1.0-1_src_all.opk' control.tar.gz <<-EOF + ls_inner '../src:foo_1.0-1_src_all.opk' control.tar.gz <<-EOF ./ ./control ./md5sums EOF cmd_is 'control.tar.gz contents' \ - ls_inner '../foo_1.0-1_i686-linux-glibc_all.opk' control.tar.gz <<-EOF + ls_inner '../foo:i686-linux-glibc_1.0-1_i686-linux-glibc_all.opk' \ + control.tar.gz <<-EOF ./ ./control ./md5sums EOF cmd_is 'control.tar.gz contents' \ - ls_inner '../bar_1.0-1_all_all.opk' control.tar.gz <<-EOF + ls_inner '../bar_1.0-1_i686-linux-glibc_all.opk' control.tar.gz <<-EOF ./ ./control EOF cmd_is 'data.tar.gz contents' \ - ls_inner '../foo_1.0-1_i686-linux-glibc_all.opk' data.tar.gz <<-EOF + ls_inner '../foo:i686-linux-glibc_1.0-1_i686-linux-glibc_all.opk' \ + data.tar.gz <<-EOF ./ ./usr/ ./usr/bin/ ./usr/bin/foo.sh ./usr/share/ ./usr/share/doc/ - ./usr/share/doc/foo/ - ./usr/share/doc/foo/README.dist - ./usr/share/doc/foo/README.upstream - ./usr/share/doc/foo/changelog.dist - ./usr/share/doc/foo/copyright + ./usr/share/doc/foo:i686-linux-glibc/ + ./usr/share/doc/foo:i686-linux-glibc/README.dist + ./usr/share/doc/foo:i686-linux-glibc/README.upstream + ./usr/share/doc/foo:i686-linux-glibc/changelog.dist + ./usr/share/doc/foo:i686-linux-glibc/copyright EOF cmd_is 'data.tar.gz contents' \ - ls_inner '../bar_1.0-1_all_all.opk' data.tar.gz <<-EOF + ls_inner '../bar_1.0-1_i686-linux-glibc_all.opk' data.tar.gz <<-EOF ./ ./usr/ ./usr/share/ diff --git a/tests/lib/ob_get_binary_parameter.sh b/tests/lib/ob_get_binary_parameter.sh index 1ad8a32..c85c3ec 100755 --- a/tests/lib/ob_get_binary_parameter.sh +++ b/tests/lib/ob_get_binary_parameter.sh @@ -23,7 +23,7 @@ set -eu . "${TOP_SRCDIR}/tests/aux/common.sh" . "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}" -plan_ 5 +plan_ 7 command_ok_ 'ob_init_package()' -- ob_init_package '..' @@ -32,6 +32,10 @@ is 'foo Architecture' \ is 'foo Platform' \ "$(ob_get_binary_parameter 'foo' 'Platform')" 'all' is 'bar Architecture' \ - "$(ob_get_binary_parameter 'bar' 'Architecture')" 'all' + "$(ob_get_binary_parameter 'bar' 'Architecture')" 'any' is 'bar Platform' \ "$(ob_get_binary_parameter 'bar' 'Platform')" 'all' +is 'baz-qux Architecture' \ + "$(ob_get_binary_parameter 'baz-qux' 'Architecture')" 'all' +is 'baz-qux Platform' \ + "$(ob_get_binary_parameter 'baz-qux' 'Platform')" 'all' diff --git a/tests/lib/ob_iso8601_gmtime.sh b/tests/lib/ob_iso8601_gmtime.sh index 840b378..f9d0deb 100755 --- a/tests/lib/ob_iso8601_gmtime.sh +++ b/tests/lib/ob_iso8601_gmtime.sh @@ -1,4 +1,4 @@ -# Tests for ob_arch_is_concerned() +# Tests for ob_iso8601_gmtime() # # Copyright (C) 2019 Patrick McDermott # @@ -23,7 +23,7 @@ set -eu . "${TOP_SRCDIR}/tests/aux/common.sh" . "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}" -plan_ 7 +plan_ 10 tst() { @@ -40,4 +40,7 @@ tst 108123 '1970-01-02T06:02:03Z' tst 41877296 '1971-04-30T16:34:56Z' tst 762480000 '1994-03-01T00:00:00Z' tst 962443230 '2000-07-01T09:20:30Z' +tst 1607419408 '2020-12-08T09:23:28Z' +tst 1609459199 '2020-12-31T23:59:59Z' +tst 1609510819 '2021-01-01T14:20:19Z' tst 2147483648 '2038-01-19T03:14:08Z' diff --git a/tests/lib/ob_reduce_deps.sh b/tests/lib/ob_reduce_deps.sh index b1e8609..72f32dd 100755 --- a/tests/lib/ob_reduce_deps.sh +++ b/tests/lib/ob_reduce_deps.sh @@ -22,7 +22,7 @@ set -eu . "${TOP_SRCDIR}/tests/aux/tap-functions.sh" . "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}" -plan_ 11 +plan_ 13 # Normal and union AND-lists. @@ -83,6 +83,15 @@ command_ok_ \ x'foo, bar' \ ] +command_ok_ \ + 'NORMAL LIST "foo, bar,"' -- \ + [ x"$(ob_reduce_deps \ + -a 'amd64-linux-glibc' \ + 'foo, bar,' \ + )" = \ + x'foo, bar' \ + ] + # Normal OR-lists. command_ok_ \ @@ -112,6 +121,15 @@ command_ok_ \ x'foo | bar' \ ] +command_ok_ \ + 'NORMAL LIST "foo | bar |"' -- \ + [ x"$(ob_reduce_deps \ + -a 'amd64-linux-glibc' \ + 'foo | bar |' \ + )" = \ + x'foo | bar' \ + ] + # Normal and union AND-lists with arch specs. command_ok_ \ diff --git a/tests/lib/ob_rfc822_mktime.sh b/tests/lib/ob_rfc822_mktime.sh index f0ddcbc..e62e5a6 100755 --- a/tests/lib/ob_rfc822_mktime.sh +++ b/tests/lib/ob_rfc822_mktime.sh @@ -1,4 +1,4 @@ -# Tests for ob_arch_is_concerned() +# Tests for ob_rfc822_mktime() # # Copyright (C) 2019 Patrick McDermott # @@ -23,7 +23,7 @@ set -eu . "${TOP_SRCDIR}/tests/aux/common.sh" . "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}" -plan_ 7 +plan_ 10 tst() { @@ -40,4 +40,7 @@ tst 'Fri, 02 Jan 1970 01:02:03 -0500' 108123 tst 'Fri, 30 Apr 1971 12:34:56 -0400' 41877296 tst 'Mon, 28 Feb 1994 19:00:00 -0500' 762480000 tst 'Sat, 01 Jul 2000 10:20:30 +0100' 962443230 +tst 'Tue, 08 Dec 2020 04:23:28 -0500' 1607419408 +tst 'Thu, 31 Dec 2020 23:59:59 +0000' 1609459199 +tst 'Fri, 01 Jan 2021 09:20:19 -0500' 1609510819 tst 'Tue, 19 Jan 2038 03:14:08 +0000' 2147483648 diff --git a/tests/lib/ob_touch_t_gmtime.sh b/tests/lib/ob_touch_t_gmtime.sh new file mode 100755 index 0000000..f7c481c --- /dev/null +++ b/tests/lib/ob_touch_t_gmtime.sh @@ -0,0 +1,46 @@ +# Tests for ob_touch_t_gmtime() +# +# Copyright (C) 2019, 2021 Patrick McDermott +# +# This file is part of opkbuild. +# +# opkbuild 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. +# +# opkbuild 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 opkbuild. If not, see <http://www.gnu.org/licenses/>. + +set -eu + +. "${TOP_SRCDIR}/tests/aux/tap-functions.sh" +. "${TOP_SRCDIR}/tests/aux/common.sh" +. "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}" + +plan_ 10 + +tst() +{ + local in="${1}" + local out="${2}" + shift 2 + + is "${in} = ${out}" "$(ob_touch_t_gmtime "${in}")" "${out}" +} + +tst 0 '197001010000.00' +tst 1 '197001010000.01' +tst 108123 '197001020602.03' +tst 41877296 '197104301634.56' +tst 762480000 '199403010000.00' +tst 962443230 '200007010920.30' +tst 1607419408 '202012080923.28' +tst 1609459199 '202012312359.59' +tst 1609510819 '202101011420.19' +tst 2147483648 '203801190314.08' diff --git a/tests/local.mk b/tests/local.mk index 7eca563..b986d2d 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -9,6 +9,7 @@ TESTS = \ %reldir%/lib/ob_get_binary_parameter.sh \ %reldir%/lib/ob_rfc822_mktime.sh \ %reldir%/lib/ob_iso8601_gmtime.sh \ + %reldir%/lib/ob_touch_t_gmtime.sh \ %reldir%/exe/opkbuild_version.sh \ %reldir%/exe/ob-buildenv.sh \ %reldir%/exe/ob-unpacksource.sh \ @@ -41,6 +42,7 @@ EXTRA_DIST += \ tests/aux/common.sh \ tests/data/pkg/README \ tests/data/pkg/bar.pkg/control \ + tests/data/pkg/baz+qux.pkg/control \ tests/data/pkg/baz-qux.pkg/control \ tests/data/pkg/build \ tests/data/pkg/changelog \ diff --git a/tools/mtime.sh b/tools/mtime.sh index 7207f9e..b88b833 100755 --- a/tools/mtime.sh +++ b/tools/mtime.sh @@ -31,10 +31,11 @@ get_mtime() local m= local d= local y= + local name= local now_m= local now_y= - read -r mode links owner group size m d y <<-EOF + read -r mode links owner group size m d y name <<-EOF $(LC_ALL=POSIX ls -l "${file}") EOF case "${m}" in |