From 8609f79a1f92eb9b553d0928d6c39ec5fbad3c34 Mon Sep 17 00:00:00 2001 From: Zach van Rijn Date: Sat, 4 Feb 2023 01:03:24 -0600 Subject: scripts/*: add Makefile generator. This commit adds a few scripts to the packages repository: * configure Typical 'configure' script; run to see usage. * scripts/genmake Generates a top-level 'Makefile' that will either build packages in the correct order, or sleep to simulate package builds. The main purpose of this tool is to enable concurrent package builds, and to provide a framework to analyze build strategies. When a dependency is updated, it is the responsibility of the maintainer to relbump all dependent packages. This tool is intended to facilitate concurrent package builds, not be a comprehensive maintenance tool. --- .gitignore | 2 ++ configure | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/genmake | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100755 configure create mode 100755 scripts/genmake diff --git a/.gitignore b/.gitignore index 5c5ff1687..4d70126d3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ pkg scripts/sgrep scripts/tsort scripts/.index +Makefile +built diff --git a/configure b/configure new file mode 100755 index 000000000..72abed07d --- /dev/null +++ b/configure @@ -0,0 +1,103 @@ +#!/bin/sh -e + +HERE="$(dirname $(readlink -f ${0}))"; + +## +# Full list of all possible repositories. +# +repos=$(grep -v ^# < "${TEMP}" -E `# use extended regex, write to temp file ` \ + -e 's/ /: /' `# append colon to first column` \ + -e '/: /s@( |$)@/built @2g' `# append '/built' to all dependencies` \ + -e 's/ $//g' `# trim trailing spaces` \ + ; + +## +# Internal; convenience only. +# +list=$(grep : "${TEMP}" \ + | cut -d: -f1 \ + | xargs \ +); + +## +# Create (or truncate) the output Makefile. +# +# Default target builds everything. +# +printf "all: %s\n" "${list}" > "${DEST}"; + +## +# Append generic target build recipe. +# +rule=; +case ${1} in + 0) rule="${rule_real}"; ;; + 1) rule="${rule_fake}"; ;; + *) printf "E: Invalid mode '%s'\n" "${1}"; exit 1; ;; +esac +cat >> "${DEST}" <> "${DEST}" "${TEMP}"; + +## +# Clean up. +# +rm "${TEMP}"; -- cgit v1.2.3-70-g09d2