commit cb930415f2798c4fe43d23e83be64d227e3c46cd
parent dd7ef3e7e976a438bb742c93fe63c614c9c3c7d6
Author: finwo <finwo@pm.me>
Date: Sun, 19 Feb 2023 21:17:58 +0100
cgraham functional release
Diffstat:
13 files changed, 251 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/update-v1.0.yml b/.github/workflows/update-v1.0.yml
@@ -0,0 +1 @@
+
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1 @@
+/build/
diff --git a/config/package-cgraham.ini b/config/package-cgraham.ini
@@ -0,0 +1,9 @@
+[mirror]
+source=pt.h=http://dunkels.com/adam/download/graham-pt.h
+tag=cgraham
+
+[package]
+name=cgraham/protothreads
+
+[export]
+include/cgraham/protothreads.h=pt.h
diff --git a/config/package-v1.0.ini b/config/package-v1.0.ini
@@ -0,0 +1,9 @@
+[mirror]
+tarball=http://dunkels.com/adam/download/pt-1.0.tar.gz
+tag=v1.0
+
+[package]
+name=adamdunkels/protothreads
+
+[export]
+include/adamdunkels/protothreads.h=pt.h
diff --git a/config/package-v1.1.ini b/config/package-v1.1.ini
@@ -0,0 +1,9 @@
+[mirror]
+tarball=http://dunkels.com/adam/download/pt-1.1.tar.gz
+tag=v1.1
+
+[package]
+name=adamdunkels/protothreads
+
+[export]
+include/adamdunkels/protothreads.h=pt.h
diff --git a/config/package-v1.2.1.ini b/config/package-v1.2.1.ini
@@ -0,0 +1,9 @@
+[mirror]
+tarball=http://dunkels.com/adam/download/pt-1.2.1.tar.gz
+tag=v1.2.1
+
+[package]
+name=adamdunkels/protothreads
+
+[export]
+include/adamdunkels/protothreads.h=pt.h
diff --git a/config/package-v1.2.ini b/config/package-v1.2.ini
@@ -0,0 +1,9 @@
+[mirror]
+tarball=http://dunkels.com/adam/download/pt-1.2.tar.gz
+tag=v1.2
+
+[package]
+name=adamdunkels/protothreads
+
+[export]
+include/adamdunkels/protothreads.h=pt.h
diff --git a/config/package-v1.3.ini b/config/package-v1.3.ini
@@ -0,0 +1,9 @@
+[mirror]
+tarball=http://dunkels.com/adam/download/pt-1.3.tar.gz
+tag=v1.3
+
+[package]
+name=adamdunkels/protothreads
+
+[export]
+include/adamdunkels/protothreads.h=pt.h
diff --git a/config/package-v1.4.ini b/config/package-v1.4.ini
@@ -0,0 +1,11 @@
+[mirror]
+tarball=http://dunkels.com/adam/download/pt-1.4.tar.gz
+tag=v1.4
+tag=edge
+tag=stable
+
+[package]
+name=adamdunkels/protothreads
+
+[export]
+include/adamdunkels/protothreads.h=pt.h
diff --git a/scripts/build-tag.sh b/scripts/build-tag.sh
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+
+DIR=$(realpath $(dirname $0))
+TAG="${TAG:-v1.4}"
+
+# Load ini lib
+source "${DIR}/ini.sh"
+
+function usage {
+ echo ""
+ echo "Usage: $(basename $0) [options] <tag>"
+ echo ""
+ echo "Options:"
+ echo " -h --help Show this usage"
+ echo ""
+ echo "Tag:"
+ echo ""
+ echo " The default tag configured is '${TAG}', but specifying one will allow"
+ echo " you to load a different configuration to build the tag for."
+ echo ""
+}
+
+# Parse arguments
+while [[ "$#" -gt 0 ]]; do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ TAG="$1"
+ ;;
+ esac
+ shift
+done
+
+# Ensure tag is given
+if [ -z "${TAG}" ]; then
+ usage
+ exit 1
+fi
+
+# Ensure the config for the given tag exists
+CFGFILE="${DIR}/../config/package-${TAG}.ini"
+if [ ! -f "${CFGFILE}" ]; then
+ echo "Configuration for tag '${TAG}' does not exist"
+ exit 1
+fi
+
+# Make an artifact directory, as a stand-alone git repository
+rm -rf "${DIR}/../build"
+git init "${DIR}/../build"
+git -C "${DIR}/../build" remote add origin "$(git -C "${DIR}/../" remote get-url origin)"
+git -C "${DIR}/../build" fetch --all
+git -C "${DIR}/../build" checkout -b "release-${TAG}"
+rm -rf "${DIR}/../build/*"
+
+# Load tarball into directory
+TARBALL=$(ini_foreach ini_output_value "${CFGFILE}" "mirror.tarball")
+if [ ! -z "${TARBALL}" ]; then
+ TARBALLTMP=$(mktemp)
+ curl -sSL "${TARBALL}" > "${TARBALLTMP}"
+ tar -x -C "${DIR}/../build" -f "${TARBALLTMP}" --strip-components=1
+ rm -f "${TARBALLTMP}"
+fi
+
+# Handle specific sources
+while read srcfg; do
+ DST=${srcfg%%=*}
+ DST=${DST%%*( )}
+ SRC=${srcfg#*=}
+ SRC=${SRC##*( )}
+ curl -sSL "${SRC}" > "${DIR}/../build/${DST}"
+done < <(ini_foreach ini_output_value "${CFGFILE}" "mirror.source")
+
+# Install package.ini into the build directory without mirror config
+ini_foreach ini_output_full "${CFGFILE}" \
+ | grep -vE '^mirror\.' \
+ | ini_write "${DIR}/../build/package.ini"
+
+# Create a commit+tag of this version and push to origin
+git -C "${DIR}/../build" add .
+git -C "${DIR}/../build" commit -m "Release (update) $(TZ=UTC date '+%Y-%m-%dT%H:%MZ')"
+git -C "${DIR}/../build" tag -f "${TAG}"
+git -C "${DIR}/../build" push -f origin HEAD
+git -C "${DIR}/../build" push -f --tags
+
+# Done
diff --git a/scripts/ini.sh b/scripts/ini.sh
@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+
+# Copied from https://github.com/finwo/dep/blob/main/src/util/ini.sh
+
+# Required for the whitespace trimming
+shopt -s extglob
+
+# Arguments:
+# $0 <fn_keyHandler> <str_filename> [section[.key]]
+function ini_foreach {
+
+ # No file = no data
+ inifile="${2}"
+ if [[ ! -f "$inifile" ]]; then
+ exit 1
+ fi
+
+ # Process the file line-by-line
+ SECTION=
+ while read line; do
+
+ # Remove surrounding whitespace
+ line=${line##*( )} # From the beginning
+ line=${line%%*( )} # From the end
+
+ # Remove comments and empty lines
+ if [[ "${line:0:1}" == '#' ]] || [[ "${line:0:1}" == ';' ]] || [[ "${#line}" == 0 ]]; then
+ continue
+ fi
+
+ # Handle section markers
+ if [[ "${line:0:1}" == "[" ]]; then
+ SECTION=$(echo $line | sed -e 's/\[\(.*\)\]/\1/')
+ SECTION=${SECTION##*( )}
+ SECTION=${SECTION%%*( )}
+ SECTION="${SECTION}."
+ continue
+ fi
+
+ # Output found variable
+ NAME=${line%%=*}
+ NAME=${NAME%%*( )}
+ VALUE=${line#*=}
+ VALUE=${VALUE##*( )}
+
+ # Output searched or all
+ if [[ -z "${3}" ]]; then
+ $1 "$SECTION" "$NAME" "${VALUE}"
+ elif [[ "${SECTION}" == "${3}" ]] || [[ "${SECTION}${NAME}" == "${3}" ]]; then
+ $1 "$SECTION" "$NAME" "${VALUE}"
+ fi
+
+ done < "${inifile}"
+}
+
+function ini_write {
+ PREVIOUSSECTION=
+ echo -en "" > "$1"
+ while read line; do
+ KEYFULL=${line%%=*}
+ VALUE=${line#*=}
+ SECTION=${KEYFULL%%.*}
+ KEY=${KEYFULL#*.}
+ if [[ "${SECTION}" != "${PREVIOUSSECTION}" ]]; then
+ echo "[${SECTION}]" >> "$1"
+ PREVIOUSSECTION="${SECTION}"
+ fi
+ echo "${KEY}=${VALUE}" >> "$1"
+ done < <(sort --unique)
+}
+
+function ini_output_full {
+ echo "$1$2=$3"
+}
+function ini_output_section {
+ echo "$2=$3"
+}
+function ini_output_value {
+ echo "$3"
+}
+
+# Allow this file to be called stand-alone
+# ini.sh <filename> [section[.key]] [sectionmode]
+if [ $(basename $0) == "ini.sh" ]; then
+ fullMode=full
+ sectionMode=value
+ if [[ ! -z "${3}" ]]; then
+ fullMode=${3}
+ sectionMode=${3}
+ fi
+ if [[ -z "${2}" ]]; then
+ ini_foreach ini_output_${fullMode} "$@"
+ else
+ ini_foreach ini_output_${sectionMode} "$@"
+ fi
+fi
diff --git a/scripts/package.ini b/scripts/package.ini
diff --git a/scripts/packagify.sh b/scripts/packagify.sh
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-DIR=$(realpath $(dirname $0))
-
-cp "${DIR}/package.ini" "${DIR}/../package.ini"