#!/bin/sh # # Usage: sh build-package.sh source-1.2.3.tar.gz # # Given a tar.gz, build a package for the current OS. # # Supports these packaging types: # # .deb (Debian, Ubuntu, etc) - requires dpkg-dev, debhelper # .rpm (AlmaLinux, Rocky Linux, OpenSUSE etc) - requires rpmbuild # # If the MAINTAINER environment variable is set, this is used as a GPG key # ID for package signing. # # The packages built with this script are not "official", in that they are # not part of any Linux distribution and may not follow the distribution's # policies. Use at your own risk. # # Copyright 2024-2025 Andrew Wood # License GPLv3+: GNU GPL version 3 or later; see `docs/COPYING'. sourceArchive="$1" test -n "${sourceArchive}" && test -f "${sourceArchive}" \ || { printf "%s: %s: %s\n" "${0##*/}" "${sourceArchive}" "source archive not found" 1>&2; exit 1; } packageName="pv" packageSummary="Shell pipeline element to meter data passing through" packageDescription="\ pv (Pipe Viewer) can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion." packageUrl="https://www.ivarch.com/programs/pv.shtml" sourceUrl="https://www.ivarch.com/programs/sources/${packageName}-%{version}.tar.gz" packageEmail="Andrew Wood " workDir="$(mktemp -d)" || exit 1 trap 'rm -rf "${workDir}"' EXIT # Infer the version from the most recent NEWS entry. version="$(tar xzf "${sourceArchive}" --wildcards -O '*/docs/NEWS.md' 2>/dev/null | awk '/^### [0-9]/{print $2}' | sed -n 1p)" if command -v rpmbuild >/dev/null 2>&1; then # Build an RPM. cat > "${workDir}"/spec </dev/null 2>&1; then # Build a Debian package. mkdir "${workDir}/build" "${workDir}/build/debian" "${workDir}/build/debian/source" tar xzf "${sourceArchive}" -C "${workDir}/build" --strip-components=1 printf "%s\n" "10" > "${workDir}/build/debian/compat" touch "${workDir}/build/debian/copyright" printf "%s\n" "3.0 (quilt)" > "${workDir}/build/debian/source/format" cat > "${workDir}/build/debian/rules" < "${workDir}/build/debian/control" <= 9) Package: ${packageName} Architecture: any Depends: \${misc:Depends} Description: ${packageSummary} $(printf "%s\n.\n" "${packageDescription}" | sed 's,^, ,') EOF cat > "${workDir}/build/debian/changelog" <