diff options
author | P. J. McDermott <pj@pehjota.net> | 2017-07-22 18:06:12 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2017-07-22 18:06:12 (EDT) |
commit | 9217f3869f76d6936e77cec0a1a4d5efd1e97727 (patch) | |
tree | 97255d75e43cebc41e7b779b109496e35b9c192e | |
parent | e0cc4b1883c98145d05a141e06a0392a3181e6e5 (diff) | |
parent | 98725484ac7bb96cd2ac6481c8460ceaa06dc4be (diff) |
Merge branch 'feature/use-autoconf-automake-shpp-and-shld'
-rw-r--r-- | .gitignore | 32 | ||||
-rw-r--r-- | INSTALL | 51 | ||||
-rw-r--r-- | Makefile.am | 142 | ||||
-rw-r--r-- | Makefile.in | 255 | ||||
-rwxr-xr-x | autogen.sh | 27 | ||||
-rw-r--r-- | config.sh.in | 2 | ||||
-rwxr-xr-x | configure | 320 | ||||
-rw-r--r-- | configure.ac | 59 | ||||
-rw-r--r-- | lib/cmd/local.mk | 11 | ||||
-rw-r--r-- | lib/local.mk | 15 | ||||
-rw-r--r-- | locale/en_US.sh (renamed from locale/en_US/pro_archman.sh) | 28 | ||||
-rw-r--r-- | locale/local.mk | 7 | ||||
-rw-r--r-- | man/local.mk | 7 | ||||
-rw-r--r-- | man/pro-archman.1in | 2 | ||||
-rwxr-xr-x | scripts/announce-release.sh | 90 | ||||
-rw-r--r-- | src/cmd.sh (renamed from lib/cmd.sh) | 28 | ||||
-rw-r--r-- | src/cmd/copy-suite.sh (renamed from lib/cmd/copy-suite.sh) | 8 | ||||
-rw-r--r-- | src/cmd/help.sh (renamed from lib/cmd/help.sh) | 6 | ||||
-rw-r--r-- | src/cmd/include.sh (renamed from lib/cmd/include.sh) | 8 | ||||
-rw-r--r-- | src/cmd/local.mk | 8 | ||||
-rw-r--r-- | src/cmd/process-incoming.sh (renamed from lib/cmd/process-incoming.sh) | 10 | ||||
-rw-r--r-- | src/cmd/remove-suite.sh (renamed from lib/cmd/remove-suite.sh) | 8 | ||||
-rw-r--r-- | src/cmd/remove.sh (renamed from lib/cmd/remove.sh) | 8 | ||||
-rw-r--r-- | src/cmd/version.sh (renamed from lib/cmd/version.sh) | 8 | ||||
-rw-r--r-- | src/control.sh (renamed from lib/control.sh) | 6 | ||||
-rw-r--r-- | src/db.sh (renamed from lib/db.sh) | 5 | ||||
-rw-r--r-- | src/dir.sh (renamed from lib/dir.sh) | 3 | ||||
-rw-r--r-- | src/garbage.sh (renamed from lib/garbage.sh) | 7 | ||||
-rw-r--r-- | src/include.sh (renamed from lib/include.sh) | 8 | ||||
-rw-r--r-- | src/index.sh (renamed from lib/index.sh) | 7 | ||||
-rw-r--r-- | src/local.mk | 18 | ||||
-rw-r--r-- | src/locale.sh (renamed from lib/locale.sh) | 37 | ||||
-rw-r--r-- | src/main.sh (renamed from src/pro-archman.sh) | 53 | ||||
-rw-r--r-- | src/output.sh (renamed from lib/output.sh) | 3 | ||||
-rw-r--r-- | src/remove.sh (renamed from lib/remove.sh) | 7 | ||||
-rw-r--r-- | src/suite.sh (renamed from lib/suite.sh) | 9 | ||||
-rw-r--r-- | tests/local.mk | 3 | ||||
-rwxr-xr-x | tools/shld.sh | 157 | ||||
-rwxr-xr-x | tools/shpp.sh | 173 |
39 files changed, 781 insertions, 855 deletions
@@ -4,11 +4,29 @@ *~ Session.vim -# Generated files +# Files generated by aclocal, autoconf, and automake +aclocal.m4 +autom4te.cache/ +configure +build-aux/ +ChangeLog +INSTALL +Makefile.in + +# Files generated by configure +config.log +config.status Makefile -src/*[^.]?? -lib/*.sm -lib/*/*.sm -man/*.? -locale/*/*.ms -pro-archman-*.tar.* +config.sh + +# Files generated by Makefile +*.sho +pro-archman +locale/*.ms +man/*.1 +*-*/ +*-*.tar* +tests/*[^.]?? +tests/*.log +tests/*.trs +test-suite.log diff --git a/INSTALL b/INSTALL deleted file mode 100644 index a648c82..0000000 --- a/INSTALL +++ /dev/null @@ -1,51 +0,0 @@ -Basic Installation ------------------- - -This software package uses a build system similar to one generated by GNU -Autoconf and Automake. - -The `configure` shell script attempts to find certain system dependencies (e.g. -a shell interpreter) and configure the package to be built and installed on the -system. Upon successful dependency resolution and configuration, the script -generates a `Makefile` in your current working directory. - -The simplest way to configure, build, and install this package is: - - 1. Run the `configure` script from the source directory or any other directory. - For example, from the source directory you can run `./configure`. - 2. Run `make` to build the package. - 3. Run `make install` to install the package. You will probably need superuser - privileges to install files into your system. - -To uninstall the package, you can run `make uninstall`. - -Configuration Options ---------------------- - -The `configure` script accepts certain command-line options to control package -building and installation. Run the script with the `--help` option for more -information. - -Macros ------- - -The macro `DESTDIR` affects the root directory into which the `Makefile` -installs the package. For example, you can install the package into a -filesystem hierarchy under a directory named `dest` in the current directory by -running `make DESTDIR=dest install`. - -Separate Build Directory ------------------------- - -Building this package from outside the source directory is currently -unsupported. - -Copyright Information ---------------------- - -Copyright (C) 2012-2013 Patrick "P. J." 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 new file mode 100644 index 0000000..c49df54 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,142 @@ +# Process this file with automake to produce an input makefile. +# +# Copyright (C) 2013-2016 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 2 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/>. + +if IN_GIT +PACKAGE_VERSION_GIT = $$(git describe --tags --dirty | sed 's|^.*/||') +else +PACKAGE_VERSION_GIT = $(PACKAGE_VERSION) +endif + +MANUAL = ProteanOS Archive Manager Manual +TEXTDOMAIN = $$(printf '%s\n' '$(PACKAGE)' | sed -e 's|-|_|g') + +SUFFIXES = .sh .sho .ms .1in .1 +OBJEXT = sho + +# This PACKAGE_VERSION stuff is a rather gross hack, but it's the only reliable +# way to put Git commit information in the prokit executable. Setting +# PACKAGE_VERSION in configure causes it to become outdated until the next +# configure run. Adding it to the preprocessor command line can cause multiple +# values of it to exist in the linked executable. +LINK = printf "PACKAGE_VERSION='%s'\n" "$(PACKAGE_VERSION_GIT)" | \ + '$(srcdir)/tools/shld.sh' -I '$(SH)' -o $@ config.sh - + +bin_PROGRAMS = pro-archman + +pro_archman_SOURCES = +pro_archman_SHPPFLAGS = \ + -DLOCALEDIR="$(localedir)" \ + -DTEXTDOMAIN="$(TEXTDOMAIN)" +pro_archman_LDADD = $(pro_archman_SOURCES:.sh=.sho) +EXTRA_pro_archman_DEPENDENCIES = config.sh + +locale_MESSAGES = $(locale_sources:.sh=.ms) +noinst_DATA = $(locale_MESSAGES) + +man1_MANS = $(man1_sources:.1in=.1) +do_subst = sed \ + -e 's|[@]PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ + -e "s|[@]PACKAGE_VERSION[@]|$(PACKAGE_VERSION_GIT)|g" \ + -e 's|[@]MANUAL[@]|$(MANUAL)|g' + +CLEANFILES = \ + $(pro_archman_LDADD) \ + $(locale_MESSAGES) \ + $(man1_MANS) +EXTRA_DIST = \ + COPYING.2 \ + COPYING.3 \ + autogen.sh \ + $(locale_sources) \ + $(man1_sources) \ + $(tests) \ + tools/shpp.sh \ + tools/shld.sh + +install-data-local: $(locale_MESSAGES) + @$(NORMAL_INSTALL) + for f in $(locale_MESSAGES); do \ + ff="$${f#*/}"; \ + dir="$(DESTDIR)$(localedir)/$${ff%.ms}/LC_MESSAGES"; \ + $(MKDIR_P) "$${dir}" || exit 1; \ + $(INSTALL_DATA) "$${f}" "$${dir}/$(TEXTDOMAIN).ms" || \ + exit $${?}; \ + done + +uninstall-local: + @$(NORMAL_UNINSTALL) + for f in $(locale_MESSAGES); do \ + ff="$${f#*/}"; \ + dir="$(DESTDIR)$(localedir)/$${ff%.ms}/LC_MESSAGES"; \ + rm -f "$${dir}/$(TEXTDOMAIN).ms"; \ + done + +really-clean: distclean + rm -Rf $(srcdir)/aclocal.m4 $(srcdir)/autom4te.cache/ \ + $(srcdir)/configure \ + $(srcdir)/build-aux/ $(srcdir)/INSTALL $(srcdir)/Makefile.in \ + $(srcdir)/ChangeLog + +dist-hook: + if [ -d '$(srcdir)/.git' ]; then \ + printf 'Generated file. Do not edit.\n\n' \ + >'$(distdir)/ChangeLog~'; \ + GIT_DIR='$(srcdir)/.git' git log --stat --color=never \ + >>'$(distdir)/ChangeLog~'; \ + mv '$(distdir)/ChangeLog~' '$(distdir)/ChangeLog'; \ + fi + +release: + sed "s/^Released: ????-??-??\$$/Released: $$(date '+%Y-%m-%d')/" \ + '$(srcdir)/NEWS' >'$(srcdir)/NEWS~' + mv '$(srcdir)/NEWS~' '$(srcdir)/NEWS' + $(MAKE) distcheck + set -e; \ + export GIT_DIR='$(srcdir)/.git'; \ + export GIT_WORK_TREE='$(srcdir)'; \ + git commit -m 'NEWS: Release $(PACKAGE) $(VERSION)' -- NEWS; \ + git tag '$(PACKAGE)/$(VERSION)' HEAD; \ + git push --tags origin master:master + md5sum $(DIST_ARCHIVES) >MD5SUMS + sha256sum $(DIST_ARCHIVES) >SHA256SUMS + set -e; \ + for f in $(DIST_ARCHIVES); do \ + gpg --armor --sign $${f}; \ + done + ssh files@files.proteanos.com mkdir -p files/pub/$(PACKAGE) + rsync -az --progress --stats $(DIST_ARCHIVES) MD5SUMS SHA256SUMS \ + files@files.proteanos.com:files/pub/$(PACKAGE)/$(VERSION)/ + '$(srcdir)/scripts/announce-release.sh' \ + $(PACKAGE) $(VERSION) '$(PACKAGE_NAME)' + +.sh.sho: + $(AM_V_GEN)$(MKDIR_P) "$$(dirname $@)" + $(AM_V_at)$(SH) -n $< + $(AM_V_at)'$(srcdir)/tools/shpp.sh' $(pro_archman_SHPPFLAGS) $< $@ + +.sh.ms: + $(AM_V_GEN)$(MKDIR_P) "$$(dirname $@)" + $(AM_V_at)cp $< $@ + +.1in.1: + $(AM_V_GEN)$(MKDIR_P) "$$(dirname $@)" + $(AM_V_at)$(do_subst) $< >$@ + +include $(top_srcdir)/src/local.mk +include $(top_srcdir)/locale/local.mk +include $(top_srcdir)/man/local.mk +include $(top_srcdir)/tests/local.mk diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index fad6921..0000000 --- a/Makefile.in +++ /dev/null @@ -1,255 +0,0 @@ -# pro-archman -# Makefile.in -# Input Makefile for configure. -# -# Copyright (C) 2012-2013 Patrick "P. J." McDermott -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 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@ -package_description = @package_description@ -package_library = @package_library@ - -srcdir = @srcdir@ -prefix = @prefix@ -bindir = @bindir@ -libdir = @libdir@ -pkglibdir = @pkglibdir@ -datadir = @datadir@ -mandir = @mandir@ -man1dir = @man1dir@ -localedir = @localedir@ - -DESTDIR = / - -sh = @sh@ - -pkglibcmddir = $(pkglibdir)/cmd - -include $(srcdir)/src/local.mk -include $(srcdir)/lib/local.mk -include $(srcdir)/lib/cmd/local.mk -include $(srcdir)/man/local.mk -include $(srcdir)/locale/local.mk -include $(srcdir)/tests/local.mk - -bin = $(bin_srcs:.sh=) -pkglib = $(pkglib_srcs:.sh=.sm) -pkglibcmd = $(pkglibcmd_srcs:.sh=.sm) -man1 = $(man1_srcs:.1in=.1) -locale = $(locale_srcs:.sh=.ms) - -distdir = $(package_name)-$(package_version) -distfiles = \ - configure \ - Makefile.in \ - COPYING.2 \ - COPYING.3 \ - README \ - INSTALL \ - HACKING \ - NEWS \ - examples/conf.default \ - src/local.mk \ - lib/local.mk \ - lib/cmd/local.mk \ - man/local.mk \ - locale/local.mk \ - tests/local.mk \ - $(bin_srcs) \ - $(pkglib_srcs) \ - $(pkglibcmd_srcs) \ - $(man1_srcs) \ - $(locale_srcs) \ - $(tests) - -script = \ - s&@@PACKAGE_NAME@@&$(package_name)&;\ - s&@@PACKAGE_VERSION@@&$(package_version)&;\ - s&@@PACKAGE_DESCRIPTION@@&$(package_description)&;\ - s&@@BINDIR@@&$(bindir)&;\ - s&@@PKGLIBDIR@@&$(pkglibdir)&;\ - s&@@PKGLIBCMDDIR@@&$(pkglibcmddir)&;\ - s&@@DATADIR@@&$(datadir)&;\ - s&@@LOCALEDIR@@&$(localedir)&;\ - s&@@SH@@&$(sh)&;\ - s&@@PKGLIBCMD@@&$(pkglibcmd)&; - -.SUFFIXES: -.SUFFIXES: .sh .sm .1in .1 .ms - -# XXX: Support for lists of multiple targets in inference rules doesn't appear -# to be required by POSIX.1-2008 [1], but it exists in GNU Make and NetBSD -# pmake. Expand this into separate rules if it is a problem with certain make -# implementations. -# [1]: Compare the inference and target rule definitions after fragments -# <#tag_20_76_13_06> and <#tag_20_76_13_04> in -# <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html>. -.sh: - @printf ' SED %s\n' '$@' - @sed '$(script)' '$(srcdir)/$?' >'$@' - @chmod 755 '$@' -.sh.sm .1in.1: - @printf ' SED %s\n' '$@' - @sed '$(script)' '$(srcdir)/$?' >'$@' - @chmod 644 '$@' -.sh.ms: - @printf ' CP %s\n' '$@' - @obj='$@'; mkdir -p "$${obj%/*}" - @cp '$(srcdir)/$?' '$@' - @chmod 644 '$@' - -all: all-exec all-data -all-exec: all-bin all-pkglib all-pkglibcmd -all-bin: $(bin) -all-pkglib: $(pkglib) -all-pkglibcmd: $(pkglibcmd) -all-data: all-man1 all-locale -all-man1: $(man1) -all-locale: $(locale) - -clean_cmds = \ - set -e; \ - for f in $${files}; do \ - printf ' RM %s\n' "$${f}"; \ - rm -f "$${f}"; \ - done -clean: clean-exec clean-data -clean-exec: clean-bin clean-pkglib clean-pkglibcmd -clean-bin: - @files='$(bin)'; $(clean_cmds) -clean-pkglib: - @files='$(pkglib)'; $(clean_cmds) -clean-pkglibcmd: - @files='$(pkglibcmd)'; $(clean_cmds) -clean-data: clean-man1 clean-locale -clean-man1: - @files='$(man1)'; $(clean_cmds) -clean-locale: - @files='$(locale)'; $(clean_cmds) - -distclean: clean - @printf ' RM Makefile\n'; \ - rm -f Makefile - -install_cmds = \ - set -e; \ - mkdir -p "$(DESTDIR)/$${dir}"; \ - for f in $${files}; do \ - printf ' INSTALL %s\n' "$${f}"; \ - ff="$$(basename "$${f}")"; \ - cp "$${f}" "$(DESTDIR)/$${dir}/$${ff}"; \ - chmod "$${mode}" "$(DESTDIR)/$${dir}/$${ff}"; \ - done -install: all install-exec install-data -install-exec: all-exec install-bin install-pkglib install-pkglibcmd -install-bin: - @files='$(bin)'; dir='$(bindir)'; mode='755'; $(install_cmds) -install-pkglib: - @files='$(pkglib)'; dir='$(pkglibdir)'; mode='644'; $(install_cmds) -install-pkglibcmd: - @files='$(pkglibcmd)'; dir='$(pkglibcmddir)'; \ - mode='644'; $(install_cmds) -install-data: all-data install-man1 install-locale -install-man1: - @files='$(man1)'; dir='$(man1dir)'; mode='644'; $(install_cmds) -install-locale: - @mkdir -p '$(DESTDIR)/$(localedir)' - @set -e; for f in $(locale); do \ - printf ' INSTALL %s\n' "$${f}"; \ - ff="$${f#*/}"; \ - dd="$(DESTDIR)/$(localedir)/$${ff%/?*}/LC_MESSAGES"; \ - mkdir -p "$${dd}"; \ - df="$${dd}/$${ff##*/}"; \ - cp "$${f}" "$${df}"; \ - chmod 644 "$${df}"; \ - done - -uninstall_cmds = \ - set -e; \ - for f in $${files}; do \ - printf ' RM %s\n' "$${f}"; \ - ff="$$(basename "$${f}")"; \ - rm -f "$(DESTDIR)/$${dir}/$${ff}"; \ - done -uninstall: uninstall-exec uninstall-data -uninstall-exec: uninstall-bin uninstall-pkglibcmd uninstall-pkglib -uninstall-bin: - @files='$(bin)'; dir='$(bindir)'; $(uninstall_cmds) -uninstall-pkglib: - @files='$(pkglib)'; dir='$(pkglibdir)'; $(uninstall_cmds) - @rmdir '$(DESTDIR)/$(pkglibdir)' -uninstall-pkglibcmd: - @files='$(pkglibcmd)'; dir='$(pkglibcmddir)'; \ - $(uninstall_cmds) - @rmdir '$(DESTDIR)/$(pkglibcmddir)' -uninstall-data: uninstall-man1 uninstall-locale -uninstall-man1: - @files='$(man1)'; dir='$(man1dir)'; $(uninstall_cmds) -uninstall-locale: - @set -e; for f in $(locale); do \ - printf ' RM %s\n' "$${f}"; \ - ff="$${f#*/}"; \ - dd="$(DESTDIR)/$(localedir)/$${ff%/?*}/LC_MESSAGES"; \ - df="$${dd}/$${ff##*/}"; \ - rm -f "$${df}"; \ - done - -test: all - @cd '$(srcdir)/tests'; \ - all=0; failed=0; \ - for test in $(tests); do \ - out="$$($(sh) "$(srcdir)/$${test}" 2>&1)"; \ - if [ $${?} -eq 0 ]; then \ - printf 'PASS: %s\n' "$${test}"; \ - else \ - printf 'FAIL: %s\n' "$${test}"; \ - echo "$${out}" | sed 's/^/ /'; \ - failed=$$(($$failed + 1)); \ - fi; \ - all=$$(($$all + 1)); \ - done; \ - banner="$$(printf '%d out of %d tests failed' $${failed} $${all})"; \ - l=$$(echo "$${banner}" | wc -c); \ - i=1; while [ "$${i}" -lt "$${l}" ]; do \ - printf '='; \ - i=$$(($$i + 1)); \ - done; \ - printf '\n%s\n' "$${banner}"; \ - i=1; while [ $${i} -lt $${l} ]; do \ - printf '='; \ - i=$$(($$i + 1)); \ - done; \ - printf '\n'; \ - exit $${failed} - -$(distdir): - @mkdir -p '$(distdir)' - @set -e; for f in $(distfiles); do \ - mkdir -p "$(distdir)/$$(dirname $${f})"; \ - cp -p "$${f}" "$(distdir)/$${f}"; \ - done - -dist dist-gzip: $(distdir) - @tar -cf - '$(distdir)' | gzip -9c > '$(distdir).tar.gz' - @rm -Rf '$(distdir)' - -dist-bzip2: $(distdir) - @tar -cf - '$(distdir)' | bzip2 -9c > '$(distdir).tar.bz2' - @rm -Rf '$(distdir)' - -dist-xz: $(distdir) - @tar -cf - '$(distdir)' | xz -c > '$(distdir).tar.xz' - @rm -Rf '$(distdir)' diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..969dc3a --- /dev/null +++ b/autogen.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# Script to generate the build system. +# +# Copyright (C) 2013 Patrick "P. J." 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. + +set -e + +srcdir="${0%/*}" + +{( + cd "${srcdir}" + [ -d build-aux ] || mkdir build-aux + cat >ChangeLog <<-EOF +This file is generated upon release. Run \`git log\` for a list of changes. +EOF + aclocal + autoconf + automake --add-missing --copy +)} + +"${srcdir}/configure" "${@}" diff --git a/config.sh.in b/config.sh.in new file mode 100644 index 0000000..e882179 --- /dev/null +++ b/config.sh.in @@ -0,0 +1,2 @@ +PACKAGE='@PACKAGE@' +PACKAGE_NAME='@PACKAGE_NAME@' diff --git a/configure b/configure deleted file mode 100755 index 2e18e91..0000000 --- a/configure +++ /dev/null @@ -1,320 +0,0 @@ -#! /bin/sh -# -# pro-archman -# configure -# Configuration script to generate Makefile. -# -# Copyright (C) 2011-2013 Patrick "P. J." McDermott -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 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='pro-archman' -package_version='1.4.0' -package_description='ProteanOS Archive Manager' -package_library='pro-archman' - -srcdir="$(cd "${0%/*}" && pwd)" -prefix='/usr/local' -bindir='${prefix}/bin' -libdir='${prefix}/share' -pkglibdir='${libdir}/${package_library}' -datadir='${prefix}/share' -mandir='${datadir}/man' -man1dir='${mandir}/man1' -localedir='${datadir}/locale' - -quiet='false' -missing_deps='false' -dep_cmds=' -sh -make -' - -long_opts_with_args=' -srcdir -prefix -bindir -libdir -pkglibdir -datadir -mandir -man1dir -localedir -' - -features=" -${dep_cmds} -${dep_libs} -${opt_dep_cmds} -${opt_dep_libs} -" - -subst_vars=" -package_name -package_version -package_description -package_library -${long_opts_with_args} -${features} -" - -main() -{ - parse_options "${@}" - shift ${optind} - if [ ${#} -ne 0 ]; then - print_usage - exit - fi - - for dep in ${dep_cmds}; do - dep_name="$(printf '%s' "${dep}" | tr -c '[a-z0-9]' '_')" - dep_val="$(eval printf \'%s\' \"\$\{"${dep_name}"\}\")" - if [ -z "${dep_val}" ]; then - find_dep_cmd "${dep}" || missing_deps='true' - fi - done - for dep in ${dep_libs}; do - dep_name="$(printf '%s' "${dep}" | tr -c '[a-z0-9]' '_')" - dep_val="$(eval printf \'%s\' \"\$\{"${dep_name}"\}\")" - if [ -z "${dep_val}" ]; then - find_dep_lib "${dep}" || missing_deps='true' - fi - done - for dep in ${opt_dep_cmds}; do - dep_name="$(printf '%s' "${dep}" | tr -c '[a-z0-9]' '_')" - dep_val="$(eval printf \'%s\' \"\$\{"${dep_name}"\}\")" - if [ -z "${dep_val}" ]; then - find_dep_cmd "${dep}" - fi - done - for dep in ${opt_dep_libs}; do - dep_name="$(printf '%s' "${dep}" | tr -c '[a-z0-9]' '_')" - dep_val="$(eval printf \'%s\' \"\$\{"${dep_name}"\}\")" - if [ -z "${dep_val}" ]; then - find_dep_lib "${dep}" - fi - done - - if ${missing_deps}; then - cat <<EOF - -Some dependencies could not be found. -Please make sure all dependencies are installed and try again. - -EOF - exit 1 - fi - - write_makefiles - - printf '\nConfiguration complete!\n\n' -} - -print_usage() -{ - printf 'Usage: %s [OPTION]...\n' "${0}" -} - -print_help() -{ - cat <<EOF -\`configure' configures ${package_name} ${package_version} to adapt to many \ -kinds of systems. - -$(print_usage) - -Configuration: - -h, --help display this help and exit - -V, --version display version information and exit - -q, --quiet do not print \`checking ...' messages - --srcdir=SRCDIR find the sources in SRCDIR - default: configure dir - -Installation directories: - --prefix=PREFIX install files under PREFIX - default: /usr/local - --bindir=BINDIR install scripts in BINDIR - default: PREFIX/bin - --libdir=LIBDIR install library scripts in LIBDIR - default: PREFIX/share - --pkglibdir=PKGLIBDIR install package library scripts in PKGLIBDIR - default: LIBDIR/${package_library} - --datadir=DATADIR expect to find data in DATADIR - default: PREFIX/share - --mandir=MANDIR install manual pages in MANDIR - default: DATADIR/man - --man1dir=MAN1DIR install section 1 manual pages in MAN1DIR - default: MANDIR/man1 - --localedir=LOCALEDIR install locales in LOCALEDIR - default: DATADIR/locale - -Dependencies: - --with-sh=PATH use sh at PATH -EOF -} - -print_version() -{ - cat <<EOF -${package_name} ${package_version} configure -Not generated by GNU Autoconf - -Copyright (C) 2011-2013 Patrick "P. J." McDermott -License: GNU GPL version 2 or later <http://www.gnu.org/licenses/gpl.html>. -This configure script is free software: you can redistribute and/or modify it. -There is NO WARRANTY, to the extent permitted by law. -EOF -} - -parse_options() -{ - optind=0 - - for _opt; do - - # Handle arguments of "--opt arg" options. - if [ -n "${_prev}" ]; then - eval "${_prev}"=\"\$\{_opt\}\" - _prev='' - continue - fi - - # Detect "--opt=arg" and "--opt arg" options. - case "${_opt}" in - *=*) - _optarg="${_opt#*=}" - _opt="${_opt%=*}" - _optarg_set='true' - ;; - *) - _optarg_set='false' - ;; - esac - - # Handle short and long options. - case "${_opt}" in - --) - break - ;; - -h|--help) - print_help - exit 0 - ;; - -V|--version) - print_version - exit 0 - ;; - -q|--quiet) - quiet='true' - continue - ;; - esac - - # Anything beyond this point should be a long option. - case "${_opt}" in - --with-*) - _opt="${_opt#--with-}" - _opts="${features}" - _type='package' - ;; - --*) - _opt="${_opt#--}" - _opts="${long_opts_with_args}" - _type='option' - ;; - *) - break - ;; - esac - - grep "^${_opt}\$" >/dev/null 2>&1 <<EOF -"${_opts}" -EOF - if [ ${?} -ne 0 ]; then - printf 'warning: unrecognized %s name: %s\n' \ - "${_type}" "${_opt}" >&2 - elif ${_optarg_set}; then - _opt="$(printf '%s' "${_opt}" | tr -c '[a-z0-9]' '_')" - eval "${_opt}"=\"\$\{_optarg\}\" - else - _prev="${_opt}" - fi - - optind=$(($optind + 1)) - - done -} - -find_dep_cmd() -{ - _dep="${1}" - - ${quiet} || printf 'checking for %s... ' "${_dep}" - - IFS=':' - - for _element in ${PATH}; do - unset IFS - : ${_element=-.} - if [ -f "${_element}/${_dep}" -a -x "${_element}/${_dep}" ]; then - ${quiet} || printf '%s/%s\n' "${_element}" "${_dep}" - _var="$(printf '%s' "${_dep}" | tr -c '[a-z0-9]' '_')" - eval "${_var}"=\"${_element}/${_dep}\" - return 0 - fi - done - - unset IFS - - ${quiet} || printf 'not found\n' - return 1 -} - -find_dep_lib() -{ - _dep="${1}" - - ${quiet} || printf 'checking for %s... ' "${_dep}" - - for _element in $(eval printf \'%s\' \""${libdir}"\") ${PATH}; do - : ${_element=-.} - if [ -d "${_element}/${_dep}" ]; then - ${quiet} || printf '%s/%s\n' "${_element}" "${_dep}" - _var="$(printf '%s' "${_dep}" | tr -c '[a-z0-9]' '_')" - eval "${_var}"=\"${_element}/${_dep}\" - return 0 - fi - done - - ${quiet} || printf 'not found\n' - return 1 -} - -write_makefiles() -{ - mkdir -p src lib lib/cmd locale man tests - - # Make a script to edit input makefiles. - _sed_script='' - for _var in ${subst_vars}; do - _var="$(printf '%s' "${_var}" | tr -c '[a-z0-9]' '_')" - _val="$(eval printf \'%s\' \"\$\{"${_var}"\}\")" - _sed_script="${_sed_script}s&@${_var}@&${_val}&g;" - done - - sed "${_sed_script}" "${srcdir}/Makefile.in" >'Makefile' -} - -main "${@}" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..6d6b874 --- /dev/null +++ b/configure.ac @@ -0,0 +1,59 @@ +# Process this file with autoconf to produce a configure script. +# +# Copyright (C) 2013 Patrick "P. J." McDermott +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 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/>. + +AC_INIT([ProteanOS Archive Manager], [1.4.0], + [mailto:proteanos-dev@lists.proteanos.com], [pro-archman], + [http://www.proteanos.com/dev/pro-archman/]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_SRCDIR([src/main.sh]) + +AM_INIT_AUTOMAKE([gnu check-news dist-bzip2 dist-xz subdir-objects]) +AM_SILENT_RULES([yes]) + +AM_CONDITIONAL([IN_GIT], + [test -d "${srcdir}/.git" && command -v git >/dev/null 2>&1]) + +AC_ARG_WITH( + [sh], + [AS_HELP_STRING([--with-sh=PATH], + [POSIX-conformant shell with `local'])], + dnl This `dnl' is needed to workaround Vim syntax highlighting. + [ + case "${withval}" in + 'yes'|'') + AC_MSG_ERROR([--with-sh requires an argument]) + ;; + 'no') + AC_MSG_ERROR([sh is required]) + ;; + *) + SH="${withval}" + ;; + esac + ], + [ + AC_PATH_PROG([SH], [sh]) + if test -z "${SH}"; then + AC_MSG_ERROR([sh not found]) + fi + ] +) + +AC_SUBST([SH]) +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([config.sh]) +AC_OUTPUT() diff --git a/lib/cmd/local.mk b/lib/cmd/local.mk deleted file mode 100644 index 5687a3e..0000000 --- a/lib/cmd/local.mk +++ /dev/null @@ -1,11 +0,0 @@ -# pro-archman -# lib/cmd/local.mk - -pkglibcmd_srcs = \ - lib/cmd/help.sh \ - lib/cmd/version.sh \ - lib/cmd/include.sh \ - lib/cmd/process-incoming.sh \ - lib/cmd/remove.sh \ - lib/cmd/copy-suite.sh \ - lib/cmd/remove-suite.sh diff --git a/lib/local.mk b/lib/local.mk deleted file mode 100644 index 0ad1925..0000000 --- a/lib/local.mk +++ /dev/null @@ -1,15 +0,0 @@ -# pro-archman -# lib/local.mk - -pkglib_srcs = \ - lib/output.sh \ - lib/locale.sh \ - lib/control.sh \ - lib/dir.sh \ - lib/db.sh \ - lib/index.sh \ - lib/garbage.sh \ - lib/include.sh \ - lib/remove.sh \ - lib/suite.sh \ - lib/cmd.sh diff --git a/locale/en_US/pro_archman.sh b/locale/en_US.sh index 76c5e58..920df73 100644 --- a/locale/en_US/pro_archman.sh +++ b/locale/en_US.sh @@ -27,18 +27,18 @@ msg_pro_archman_opt_v_summary='print verbose informational messages' msg_pro_archman_opt_b_summary='set archive base directory to <base-dir>' msg_pro_archman_opt_b_arg='<base-dir>' -# lib/cmd.sh +# src/cmd.sh msg_pro_archman_cmd_not_found='Command "%s" not found' msg_pro_archman_cmd_usage='Usage: %s [<option> ...] %s %s' -# lib/cmd/help.sh +# src/cmd/help.sh msg_pro_archman_cmd_help_head='Usage: %s [<option> ...] <command> [<arg> ...]' msg_pro_archman_cmd_help_opts_head='Options:' msg_pro_archman_cmd_help_summary_head='Commands:' msg_pro_archman_cmd_help_summary='print this help message' msg_pro_archman_cmd_help_usage='[<command>]' -# lib/cmd/version.sh +# src/cmd/version.sh msg_pro_archman_cmd_version_summary='print version information' msg_pro_archman_cmd_version_usage='' msg_pro_archman_cmd_version_copyright='Copyright (C) %s %s @@ -46,42 +46,42 @@ 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.' -# lib/cmd/include.sh +# src/cmd/include.sh msg_pro_archman_cmd_include_summary='include packages described in changes files' msg_pro_archman_cmd_include_usage='<changes> ...' -# lib/include.sh +# src/include.sh msg_pro_archman_include_unknown_changes_format='%s: Unknown format "%s"' msg_pro_archman_include_including='Including %s (%s) into %s/%s...' msg_pro_archman_include_no_files='No package files to include' msg_pro_archman_include_bvap_exists='Packages already exist for binary version %s, architecture %s, and platform %s' -# lib/cmd/process-incoming.sh +# src/cmd/process-incoming.sh msg_pro_archman_cmd_process_incoming_summary='include packages in incoming' msg_pro_archman_cmd_process_incoming_usage='' msg_pro_archman_cmd_process_incoming_processing='Processing changes in incoming...' -# lib/cmd/remove.sh +# src/cmd/remove.sh msg_pro_archman_cmd_remove_summary='remove packages from a suite' msg_pro_archman_cmd_remove_usage='<suite> <source>' -# lib/remove.sh +# src/remove.sh msg_pro_archman_removing_from_suite='Removing package %s from suite %s/%s...' msg_pro_archman_removing_from_suite_archplat='Removing package %s from suite %s/%s, architecture %s, and platform %s...' -# lib/cmd/copy-suite.sh +# src/cmd/copy-suite.sh msg_pro_archman_cmd_copy_suite_summary='copy packages from one suite to another' msg_pro_archman_cmd_copy_suite_usage='<source-suite> <destination-suite>' -# lib/cmd/remove-suite.sh +# src/cmd/remove-suite.sh msg_pro_archman_cmd_remove_suite_summary='remove a suite' msg_pro_archman_cmd_remove_suite_usage='<suite>' -# lib/suite.sh +# src/suite.sh msg_pro_archman_suite_copying='Copying suite %s/%s to suite %s/%s...' msg_pro_archman_suite_removing='Removing suite %s/%s...' -# lib/control.sh +# src/control.sh msg_pro_archman_control_empty_line='empty line' msg_pro_archman_control_bad_nv='badly formatted control field' msg_pro_archman_control_unknown_field='unrecognized field "%s"' @@ -90,13 +90,13 @@ msg_pro_archman_control_found_contination='found continuation line where expecte msg_pro_archman_list_item_separator=', ' msg_pro_archman_control_missing_fields='missing fields: %s' -# lib/index.sh +# src/index.sh msg_pro_archman_feed_adding='Adding package %s to feed %s/%s/%s/%s/%s...' msg_pro_archman_feed_removing='Removing package %s from feed %s/%s/%s/%s/%s...' msg_pro_archman_updating_feeds='Updating feeds...' msg_pro_archman_updating_feed='Updating feed %s/%s/%s/%s/%s...' -# lib/garbage.sh +# src/garbage.sh msg_pro_archman_collecting_garbage='Collecting garbage...' msg_pro_archman_collecting_garbage_file='Deleting file %s...' msg_pro_archman_marking_garbage_file='Marking file %s for future deletion...' diff --git a/locale/local.mk b/locale/local.mk index 73a831e..483c6af 100644 --- a/locale/local.mk +++ b/locale/local.mk @@ -1,5 +1,2 @@ -# pro-archman -# locale/local.mk - -locale_srcs = \ - locale/en_US/pro_archman.sh +locale_sources = \ + %reldir%/en_US.sh diff --git a/man/local.mk b/man/local.mk index 9cc9528..3b6a0a1 100644 --- a/man/local.mk +++ b/man/local.mk @@ -1,5 +1,2 @@ -# pro-archman -# man/local.mk - -man1_srcs = \ - man/pro-archman.1in +man1_sources = \ + %reldir%/pro-archman.1in diff --git a/man/pro-archman.1in b/man/pro-archman.1in index a987f1f..6724c10 100644 --- a/man/pro-archman.1in +++ b/man/pro-archman.1in @@ -1,5 +1,5 @@ .TH PRO-ARCHMAN "1" \ -"2014-05-01" "@@PACKAGE_NAME@@ @@PACKAGE_VERSION@@" "@@PACKAGE_DESCRIPTION@@" +"2017-07-22" "@PACKAGE_NAME@ @PACKAGE_VERSION@" "@MANUAL@" .SH NAME pro-archman \- ProteanOS Archive Manager diff --git a/scripts/announce-release.sh b/scripts/announce-release.sh new file mode 100755 index 0000000..74e915b --- /dev/null +++ b/scripts/announce-release.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +package="${1}" +version="${2}" +package_name="${3}" +srcdir="${0%/scripts/announce-release.sh}" + +about="$(sed -n ' + H; + ${ + g; + s/^\n*[^\n][^\n]*\n[=-][=-]*\n\n*//; + s/\n*[^\n][^\n]*\n[=-][=-]*\n.*$//; + p; + }; + ' "${srcdir}/README")" +news="$(sed -n ' + H; + ${ + g; + s/^\n*[^\n][^\n]*\n[=-][=-]*\n\n*//; + s/^Released: [^\n]*\n\n*//; + s/\n*[^\n][^\n]*\n[=-][=-]*\n.*$//; + p; + }; + ' "${srcdir}/NEWS")" +old_version="$(sed -n "/^${package_name} version /p;" "${srcdir}/NEWS" | \ + sed -n "2{ s/^${package_name} version //p; };")" + +export GIT_DIR="${srcdir}/.git" + +/usr/sbin/sendmail \ + -f pj+proteanos-ml@pehjota.net proteanos-dev@lists.proteanos.com <<-EOF + Date: $(LC_ALL='POSIX' date '+%a, %d %b %Y %H:%M:%S %z') + From: "Patrick 'P. J.' McDermott" <pj+proteanos-ml@pehjota.net> + To: proteanos-dev@lists.proteanos.com + Subject: ${package_name} ${version} released + + About + ===== + + ${about} + + Downloading + =========== + + Source archives are available from the files site by HTTP or FTP: + + http://files.proteanos.com/pub/${package}/${version}/ + ftp://files.proteanos.com/pub/${package}/${version}/ + + Here are the MD5 checksums: + + $(sed 's/^/ /' MD5SUMS) + + Here are the SHA-256 checksums: + + $(sed 's/^/ /' SHA256SUMS) + + The sources are maintained in a Git repository: + + http://git.proteanos.com/${package}/${package}.git/ + git://git.proteanos.com/${package}/${package}.git/ + + This release is marked by the "${package}/${version}" tag. + + NEWS for Version ${version} + =================$(printf '%s\n' "${version}" | sed 's/./=/g') + + ${news} + + Shortlog of Changes Since Version ${old_version} + ==================================$(printf '%s\n' "${old_version}" | \ + sed 's/./=/g') + + $(git shortlog "${package}/${old_version}..HEAD" | sed '/^..*$/s/^/ /') + + Diffstat of Changes Since Version ${old_version} + ==================================$(printf '%s\n' "${old_version}" | \ + sed 's/./=/g') + + $(git diff --stat=69 --color=never "${package}/${old_version}..HEAD" | \ + sed 's/^/ /') + + -- $(: Just something to follow the trailing space) + Patrick "P. J." McDermott + http://www.pehjota.net/ + Lead Developer, ProteanOS + http://www.proteanos.com/ + EOF @@ -17,24 +17,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_CMD_SM+set}" = 'xset' ] && return 0 -_CMD_SM=1 +cmds=' ' -use output -use locale - -cmds= - -load_cmds() +register_cmd() { - local cmd= + local cmd="${1}" + shift 1 - for cmd in ${PKGLIBCMD}; do - cmd="${cmd##*/}" - cmd="${cmd%.sm}" - cmds="${cmds}${cmd}${LF}" - use "cmd/${cmd}" - done + cmds="${cmds}${cmd} " + return 0 } print_opt_summaries() @@ -74,9 +65,7 @@ print_cmd_summaries() local summary= padding="$(printf '%24s' '')" - for cmd in ${PKGLIBCMD}; do - cmd="${cmd##*/}" - cmd="${cmd%.sm}" + for cmd in ${cmds}; do if [ ${#cmd} -gt 20 ]; then printf ' %s\n%24s' "${cmd}" '' else @@ -107,7 +96,8 @@ is_cmd() { local cmd="${1}" - [ "x$(printf '%s' "${cmds}" | grep "^${cmd}$")" = "x${cmd}" ] + case "${cmds}" in *" ${cmd} "*) return 0;; esac + return 1 } run_cmd() diff --git a/lib/cmd/copy-suite.sh b/src/cmd/copy-suite.sh index 987fb45..51fd969 100644 --- a/lib/cmd/copy-suite.sh +++ b/src/cmd/copy-suite.sh @@ -17,8 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -use suite - cmd_copy_suite_main() { local src_suite="${1}" @@ -47,3 +45,9 @@ cmd_copy_suite_main() return 0 } + +cmd_copy_suite_register() +{ + register_cmd 'copy-suite' +} +__init cmd_copy_suite_register diff --git a/lib/cmd/help.sh b/src/cmd/help.sh index 8b4cd58..628b0dc 100644 --- a/lib/cmd/help.sh +++ b/src/cmd/help.sh @@ -38,3 +38,9 @@ cmd_help_main() printf "$(get_msg 'cmd_help_summary_head')\n" print_cmd_summaries } + +cmd_help_register() +{ + register_cmd 'help' +} +__init cmd_help_register diff --git a/lib/cmd/include.sh b/src/cmd/include.sh index 4d279af..7f8fbac 100644 --- a/lib/cmd/include.sh +++ b/src/cmd/include.sh @@ -17,8 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -use include - cmd_include_main() { local changes= @@ -33,3 +31,9 @@ cmd_include_main() return 0 } + +cmd_include_register() +{ + register_cmd 'include' +} +__init cmd_include_register diff --git a/src/cmd/local.mk b/src/cmd/local.mk new file mode 100644 index 0000000..9dd7023 --- /dev/null +++ b/src/cmd/local.mk @@ -0,0 +1,8 @@ +pro_archman_SOURCES += \ + %reldir%/help.sh \ + %reldir%/version.sh \ + %reldir%/include.sh \ + %reldir%/process-incoming.sh \ + %reldir%/remove.sh \ + %reldir%/copy-suite.sh \ + %reldir%/remove-suite.sh diff --git a/lib/cmd/process-incoming.sh b/src/cmd/process-incoming.sh index 1eb52ae..0634f34 100644 --- a/lib/cmd/process-incoming.sh +++ b/src/cmd/process-incoming.sh @@ -17,10 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -use locale -use output -use include - cmd_process_incoming_main() { local changes= @@ -47,3 +43,9 @@ cmd_process_incoming_main() return 0 } + +cmd_process_incoming_register() +{ + register_cmd 'process-incoming' +} +__init cmd_process_incoming_register diff --git a/lib/cmd/remove-suite.sh b/src/cmd/remove-suite.sh index 5fc24ae..6703d24 100644 --- a/lib/cmd/remove-suite.sh +++ b/src/cmd/remove-suite.sh @@ -17,8 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -use suite - cmd_remove_suite_main() { local suite="${1}" @@ -39,3 +37,9 @@ cmd_remove_suite_main() return 0 } + +cmd_remove_suite_register() +{ + register_cmd 'remove-suite' +} +__init cmd_remove_suite_register diff --git a/lib/cmd/remove.sh b/src/cmd/remove.sh index 30dffa6..388a4d3 100644 --- a/lib/cmd/remove.sh +++ b/src/cmd/remove.sh @@ -17,8 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -use remove - cmd_remove_main() { local suite="${1}" @@ -40,3 +38,9 @@ cmd_remove_main() return 0 } + +cmd_remove_register() +{ + register_cmd 'remove' +} +__init cmd_remove_register diff --git a/lib/cmd/version.sh b/src/cmd/version.sh index 6608107..b22205f 100644 --- a/lib/cmd/version.sh +++ b/src/cmd/version.sh @@ -19,8 +19,14 @@ cmd_version_main() { - printf '%s %s\n' "${PACKAGE_NAME}" "${PACKAGE_VERSION}" + printf '%s %s\n' "${PACKAGE}" "${PACKAGE_VERSION}" printf "$(get_msg 'cmd_version_copyright')\n" \ '2013' 'Patrick "P. J." McDermott' } + +cmd_version_register() +{ + register_cmd 'version' +} +__init cmd_version_register diff --git a/lib/control.sh b/src/control.sh index 6907b3d..3fe00d4 100644 --- a/lib/control.sh +++ b/src/control.sh @@ -17,12 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_CONTROL_SM+set}" = 'xset' ] && return 0 -_CONTROL_SM=1 - -use output -use locale - control_file= control_line_nr= @@ -17,11 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_DB_SM+set}" = 'xset' ] && return 0 -_DB_SM=1 - -use dir - # # Functions for the suites indices # @@ -17,9 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_DIR_SM+set}" = 'xset' ] && return 0 -_DIR_SM=1 - hash_name() { local name="${1}" diff --git a/lib/garbage.sh b/src/garbage.sh index a6f1a3d..0cf8afe 100644 --- a/lib/garbage.sh +++ b/src/garbage.sh @@ -17,13 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_GARBAGE_SM+set}" = 'xset' ] && return 0 -_GARBAGE_SM=1 - -use locale -use output -use dir - collect_garbage() { local cur_time= diff --git a/lib/include.sh b/src/include.sh index 42ccf24..e83b41d 100644 --- a/lib/include.sh +++ b/src/include.sh @@ -17,14 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_INCLUDE_SM+set}" = 'xset' ] && return 0 -_INCLUDE_SM=1 - -use control -use db -use locale -use output - _INCLUDE_CHANGES_FIELDS='Format Source Binary Version Architecture Platform Distribution Maintainer Changed-By Date Description Changes Files' diff --git a/lib/index.sh b/src/index.sh index 8749897..a975e7c 100644 --- a/lib/index.sh +++ b/src/index.sh @@ -17,13 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_INDEX_SM+set}" = 'xset' ] && return 0 -_INDEX_SM=1 - -use locale -use output -use dir - feed_add_package() { local chan="${1}" diff --git a/src/local.mk b/src/local.mk index c42c66e..c906578 100644 --- a/src/local.mk +++ b/src/local.mk @@ -1,5 +1,15 @@ -# pro-archman -# src/local.mk +pro_archman_SOURCES += \ + %reldir%/main.sh \ + %reldir%/output.sh \ + %reldir%/locale.sh \ + %reldir%/control.sh \ + %reldir%/dir.sh \ + %reldir%/db.sh \ + %reldir%/index.sh \ + %reldir%/garbage.sh \ + %reldir%/include.sh \ + %reldir%/remove.sh \ + %reldir%/suite.sh \ + %reldir%/cmd.sh -bin_srcs = \ - src/pro-archman.sh +include %reldir%/cmd/local.mk diff --git a/lib/locale.sh b/src/locale.sh index b3f54f4..f7cc0a5 100644 --- a/lib/locale.sh +++ b/src/locale.sh @@ -17,18 +17,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_LOCALE_SM+set}" = 'xset' ] && return 0 -_LOCALE_SM=1 - -LOCALEDIR='@@LOCALEDIR@@' -LOCALE_PATH='%s/%s/LC_MESSAGES/%s.ms' DEFAULT_LOCALE='en_US' -TEXT_DOMAIN='pro_archman' load_locale() { local localedir= - local localepath= # Make sure LC_MESSAGES is set. if [ "x${LC_MESSAGES+set}" != 'xset' ]; then @@ -43,18 +36,16 @@ load_locale() if [ "${ARCHMAN_LOCALEDIR+set}" = 'set' ]; then localedir="${ARCHMAN_LOCALEDIR:-.}" - localepath='%s/%s/%s.ms' else localedir="${LOCALEDIR}" - localepath="${LOCALE_PATH}" fi # Try to load the locale. - if ! _try_load_locale "${localedir}" "${localepath}" \ + if ! _try_load_locale "${localedir}" \ "${LC_MESSAGES%.*}"; then - if ! _try_load_locale "${localedir}" "${localepath}" \ + if ! _try_load_locale "${localedir}" \ "${LC_MESSAGES%_*}"; then - if ! _try_load_locale "${localedir}" "${localepath}" \ + if ! _try_load_locale "${localedir}" \ "${DEFAULT_LOCALE}"; then warn 'Cannot load locale' return 1 @@ -69,7 +60,7 @@ get_msg() { local msgid="${1}" - eval "printf '%s' \"\${msg_${TEXT_DOMAIN}_${msgid}}\"" + eval "printf '%s' \"\${msg_${TEXTDOMAIN}_${msgid}}\"" return 0 } @@ -77,18 +68,16 @@ get_msg() _try_load_locale() { local localedir="${1}" - local localepath="${2}" - local locale="${3}" + local locale="${2}" local ms= - ms="$(printf "${localepath}" \ - "${localedir}" "${locale}" "${TEXT_DOMAIN}")" - - if [ -f "${ms}" ]; then - . "${ms}" - else - return 1 - fi + for ms in "${localedir}/${locale}/LC_MESSAGES/${TEXTDOMAIN}.ms" \ + "${localedir}/${locale}.ms"; do + if [ -f "${ms}" ]; then + . "${ms}" + return 0 + fi + done - return 0 + return 1 } diff --git a/src/pro-archman.sh b/src/main.sh index 0cd34e9..b31e9ea 100644 --- a/src/pro-archman.sh +++ b/src/main.sh @@ -1,5 +1,3 @@ -#!@@SH@@ -# # pro-archman # src/pro-archman.sh # Main program file @@ -22,11 +20,6 @@ set -u # Constant global variables -PACKAGE_NAME='@@PACKAGE_NAME@@' -PACKAGE_VERSION='@@PACKAGE_VERSION@@' -PKGLIBDIR='@@PKGLIBDIR@@' -PKGLIBCMDDIR='@@PKGLIBCMDDIR@@' -PKGLIBCMD='@@PKGLIBCMD@@' LF=' ' OPTSTRING='hVvb:' @@ -42,49 +35,6 @@ conf_gzip= lock= exit_status= -# use() must be defined inline so it can be used to load other modules. -use() -{ - local module="${1}" - local default_dir= - local lib_subdir= - local dir= - - if [ "x${module%/*}" = "x${module}" ]; then - default_dir="${PKGLIBDIR}" - lib_subdir='' - else - case "${module%/*}" in - 'cmd') - loading_cmd="$(printf '%s' "${module##*/}" | \ - tr '[A-Z]' '[a-z]' | \ - tr -C '[a-z0-9_]' '_')" - default_dir="${PKGLIBCMDDIR}" - lib_subdir='cmd' - ;; - esac - fi - - if [ "${ARCHMAN_LIBDIR+set}" = 'set' ]; then - dir="${ARCHMAN_LIBDIR:-.}/${lib_subdir}" - else - dir="${default_dir}" - fi - - if [ -f "${dir}/${module##*/}.sm" ]; then - . "${dir}/${module##*/}.sm" - else - printf '%s: Error: Failed to load module "%s": %s\n' \ - "${0##*/}" "${module}" 'no such file or directory' >&2 - exit 2 - fi -} - -use locale -use cmd -use index -use garbage - main() { local cmd= @@ -92,7 +42,6 @@ main() init_sigs load_locale - load_cmds get_options "${@}" shift $(($OPTIND - 1)) @@ -221,5 +170,3 @@ handle_sig() exit $((128 + $sig)) fi } - -main "${@}" diff --git a/lib/output.sh b/src/output.sh index d3d150f..da3a7d5 100644 --- a/lib/output.sh +++ b/src/output.sh @@ -17,9 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_OUTPUT_SM+set}" = 'xset' ] && return 0 -_OUTPUT_SM=1 - error() { local status=${1} diff --git a/lib/remove.sh b/src/remove.sh index a3a06dd..b580b1b 100644 --- a/lib/remove.sh +++ b/src/remove.sh @@ -17,13 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_REMOVE_SM+set}" = 'xset' ] && return 0 -_REMOVE_SM=1 - -use locale -use output -use db - remove_source_from_suite() { local chan="${1}" diff --git a/lib/suite.sh b/src/suite.sh index 4de39ef..da4a02d 100644 --- a/lib/suite.sh +++ b/src/suite.sh @@ -17,15 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -[ "x${_SUITE_SM+set}" = 'xset' ] && return 0 -_SUITE_SM=1 - -use db -use dir -use remove -use locale -use output - copy_suite() { local src_chan="${1}" diff --git a/tests/local.mk b/tests/local.mk index cefe649..8f59854 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -1,4 +1 @@ -# pro-archman -# tests/local.mk - tests = diff --git a/tools/shld.sh b/tools/shld.sh new file mode 100755 index 0000000..e1dff5f --- /dev/null +++ b/tools/shld.sh @@ -0,0 +1,157 @@ +#!/bin/sh +# +# Shell command language linker +# +# Copyright (C) 2015 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/>. + +set -u + +VERSION='0.1.0' + +output='out.sh' +make_executable=true +interpreter='/bin/sh' +entry_point='main' + +die() +{ + local fmt="${1}" + shift 1 + + printf "shld: ${fmt}\n" "${@}" >&2 + exit 2 +} + +link() +{ + local input= + + # Open output file. + if ! exec 3>"${output}~"; then + die 'Cannot open file "%s"' "${output}~" + fi + + # Write magic number and interpreter path. + if ${make_executable}; then + printf '#!%s\n' "${interpreter}" >&3 + fi + + # Write __init() function. + cat >&3 <<-'EOF' + __init_funcs='' + __init() + { + __init_funcs="${__init_funcs} ${1}" + } + EOF + + # Read input files. + for input in "${@}"; do + if ! cat "${input}" >&3; then + die 'Cannot read file "%s"' "${input}" + fi + done + + # Add call to init functions. + cat >&3 <<-'EOF' + for __func in ${__init_funcs}; do + ${__func} + done + EOF + + # Add call to entry point. + if ${make_executable}; then + printf '%s "${@}"\n' "${entry_point}" >&3 + fi + + # Close output file, make it executable, and set its name. + exec 3>&- + if ${make_executable}; then + if ! chmod a+x "${output}~"; then + die 'Cannot set mode of file "%s"' "${output}~" + fi + fi + if ! mv "${output}~" "${output}"; then + die 'Cannot rename file to "%s"' "${output}" + fi +} + +usage() +{ + printf 'Usage: %s [option ...] <file>...\n' "${0}" +} + +help() +{ + usage + cat <<EOF +Options: + -h Display this information + -V Display linker version information + -I <interp> Use <interp> as the interpreter for your program, instead of the + default of "/bin/sh" + -e <entry> Use <entry> as the function for beginning execution of your + program, instead of the default of "main" + -o <output> Use <output> as the name of the program produced by shld, instead + of the default of "out.sh" +EOF +} + +version() +{ + cat <<EOF +shld ${VERSION} +Copyright (C) 2015 Patrick "P. J." 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. +EOF +} + +main() +{ + while getopts 'hVI:e:o:' opt; do + case "${opt}" in + 'h') + help + exit + ;; + 'V') + version + exit + ;; + 'I') + interpreter="${OPTARG}" + ;; + 'e') + entry_point="${OPTARG}" + ;; + 'o') + output="${OPTARG}" + ;; + esac + done + shift $(($OPTIND - 1)) + + if [ ${#} -lt 1 ]; then + usage >&2 + exit 1 + fi + + link "${@}" +} + +main "${@}" diff --git a/tools/shpp.sh b/tools/shpp.sh new file mode 100755 index 0000000..fc23a52 --- /dev/null +++ b/tools/shpp.sh @@ -0,0 +1,173 @@ +#!/bin/sh +# +# Shell command language preprocessor +# +# Copyright (C) 2015 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/>. + +set -u + +VERSION='0.1.0' +FS="$(printf '\034')" + +die() +{ + local fmt="${1}" + shift 1 + + printf "shpp: ${fmt}\n" "${@}" >&2 + exit 2 +} + +error() +{ + local fmt="${1}" + shift 1 + + printf "shpp: ${fmt}\n" "${@}" >&2 +} + +preprocess() +{ + local vars="${1}" + local input="${2}" + local output="${3}" + local def= + local var= + local val= + + # Open output file. + if [ "x${output}" = 'x-' ]; then + if ! exec 3>&1; then + die 'Cannot duplicate output file descriptor' + fi + else + if ! exec 3>"${outfile}~"; then + die 'Cannot open file "%s"' "${output}~" + fi + fi + + IFS="${FS}" + for def in ${vars}; do + case "${def}" in + *=*) + var="${def%%=*}" + val="${def#*=}" + ;; + *) + var="${def%%=*}" + val='true' + ;; + esac + case "${var}" in + *[!A-Za-z0-9_]*) + error 'Invalid variable name "%s"' "${var}" + continue + ;; + [0-9]*) + error 'Invalid variable name "%s"' "${var}" + continue + ;; + esac + printf "%s='" "${var}" >&3 + printf '%s' "${val}" | sed "s/'/'\\\\''/g" >&3 + printf "'\n" >&3 + done + unset IFS + + # Read input file. + if ! cat "${input}" >&3; then + die 'Cannot read file "%s"' "${input}" + fi + + # Close output file, make it executable, and set its name. + if ! [ "x${output}" = 'x-' ]; then + exec 3>&- + if ! mv "${output}~" "${output}"; then + die 'Cannot rename file to "%s"' "${output}" + fi + fi +} + +usage() +{ + printf 'Usage: %s [option ...] <infile> [<outfile>]\n' "${0}" +} + +help() +{ + usage + cat <<EOF +Options: + -h Display this information + -V Display preprocessor version information + -D <var>[=<val>] Predefine <var> as a variable with value <val> (default + "true") +EOF +} + +version() +{ + cat <<EOF +shpp ${VERSION} +Copyright (C) 2015 Patrick "P. J." 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. +EOF +} + +main() +{ + local opt= + local vars= + local infile= + local outfile= + + while getopts 'hVD:' opt; do + case "${opt}" in + 'h') + help + exit + ;; + 'V') + version + exit + ;; + 'D') + vars="${vars}${OPTARG}${FS}" + ;; + esac + done + shift $(($OPTIND - 1)) + + case ${#} in + 1) + infile="${1}" + outfile='-' + ;; + 2) + infile="${1}" + outfile="${2}" + ;; + *) + usage >&2 + exit 1 + esac + + preprocess "${vars}" "${infile}" "${outfile}" +} + +main "${@}" |