#!/bin/sh set -eu PLAT= MAKE_SUBSTVARS=false info() { local fmt="${1}" shift 1 printf "ppt-mkpkgs: ${fmt}\n" "${@}" } make_common_pkg() { # Make "-common" package to provide source package documentation files. mkdir -p "config-${PLAT}-common.pkg" cat >"config-${PLAT}-common.pkg/control" <<-EOF # Generated by ppt-mkpkgs. Do not edit. Architecture: all Platform: all Section: share Description: "${PLAT}" platform configuration - common files EOF >"config-${PLAT}-common.pkg/docs" info 'Metadata for package "%s" generated.' "config-${PLAT}-common" } make_base_pkg() { # Make a "config-base" package to depend on packages to be automatically # installed. mkdir -p "config-base.pkg" cat >"config-base.pkg/control" <<-EOF # Generated by ppt-mkpkgs. Do not edit. Architecture: all Platform: ${PLAT} Section: share Essential: yes Depends: config-${PLAT}-common (= \${Binary-Version}), \${Config-Base-Depends} Description: "${PLAT}" platform configuration - base package EOF if ${MAKE_SUBSTVARS}; then printf 'Config-Base-Depends:\n' >>'substvars' fi info 'Metadata for package "%s" generated.' "config-base" } make_build_time_pkgs() { local pkg= # Make each config-*-* package. for pkg in src/build/*; do [ -d "${pkg}" ] || continue pkg="${pkg#src/build/}" mkdir -p "config-${pkg}-${PLAT}.pkg" cat >"config-${pkg}-${PLAT}.pkg/control" <<-EOF # Generated by ppt-mkpkgs. Do not edit. Architecture: all Platform: all Section: dev Depends: config-${PLAT}-common (= \${Binary-Version}), \${Config-${pkg}-Depends} Description: "${PLAT}" platform configuration for ${pkg} EOF if ${MAKE_SUBSTVARS}; then printf 'Config-%s-Depends:\n' "${pkg}" >>'substvars' fi info 'Metadata for package "%s" generated.' \ "config-${pkg}-${PLAT}" done } make_run_time_pkgs() { local pkg= # Make each config-* package. for pkg in src/run/*; do [ -d "${pkg}" ] || continue pkg="${pkg#src/run/}" mkdir -p "config-${pkg}.pkg" cat >"config-${pkg}.pkg/control" <<-EOF # Generated by ppt-mkpkgs. Do not edit. Architecture: all Platform: ${PLAT} Section: share Depends: config-${PLAT}-common (= \${Binary-Version}), \${Config-${pkg}-Depends} Description: "${PLAT}" platform configuration for ${pkg} EOF if ${MAKE_SUBSTVARS}; then printf 'Config-%s-Depends:\n' "${pkg}" >>'substvars' fi info 'Metadata for package "%s" generated.' \ "config-${pkg}" done } main() { PLAT="$(sed '1{s/^config-\([^ ][^ ]*\) (.*$/\1/;};1!q;' changelog)" if ! [ -e 'substvars' ]; MAKE_SUBSTVARS=true printf '# Generated by ppt-mkpkgs. DO EDIT.\n' >'substvars' fi make_common_pkg make_base_pkg make_build_time_pkgs make_run_time_pkgs info 'Consider adding "opkbuild (>= 4.2.0)" to Build-Depends' if ${MAKE_SUBSTVARS}; then info 'Stub "substvars" file generated. Set variables as '$(: \ )'needed.' else info 'Ensure "substvars" contains Config-*-Depends '$(: \ )'variables as needed.' fi } main "${@}"