Skip to content

Commit

Permalink
Merge pull request #150 from grische/feature/manifest-signature-eof
Browse files Browse the repository at this point in the history
firmware-downloader: add "---" to manifests
  • Loading branch information
GoliathLabs authored Jan 26, 2024
2 parents f25a14e + 40f126d commit d8bb870
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 9 additions & 6 deletions github-downloader/firmware-downloader
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,42 @@

set -eEu
shopt -s nullglob # required for downloads that have no "debug" artifacts
set -o pipefail # to capture errors of jq when there is a grep after

SITE=${2:-ffm}
if [ "${SITE}" = "ffm" ]; then
if [[ "${SITE}" == "ffm" ]]; then
base_url=https://api.github.com/repos/freifunkMUC/site-ffm
elif [ "${SITE}" = "ffdon" ]; then
elif [[ "${SITE}" == "ffdon" ]]; then
base_url=https://api.github.com/repos/freifunkMUC/sites-ffdon
else
echo "Unknown site ${SITE}. Aborting."
exit 1
fi

TAG=${1:-latest}
if [ "${TAG}" = "latest" ]; then
if [[ "${TAG}" == "latest" ]]; then
TAG=$(curl -s "${base_url}/releases/latest" | jq .tag_name | tr -d \")
echo "Latest tag is $TAG"
fi

TAG_ID=$(curl -s "${base_url}/releases" | jq '.[] | "\(.tag_name) \(.id)"' | grep \""${TAG}"\ | cut -d" " -f2 | sed 's/"//g')
URLS=$(curl -s "${base_url}/releases/${TAG_ID}" | jq '.assets[].browser_download_url' | tr -d \")

if [ "${SITE}" = "ffm" ]; then
if [[ "${SITE}" == "ffm" ]]; then
FIRMWARE_DIR=/srv/www/firmware.ffmuc.net/$TAG
TEMP_DIR=/tmp/firmware/$TAG
else
FIRMWARE_DIR="/srv/www/firmware.ffmuc.net/${SITE}/${TAG}"
TEMP_DIR="/tmp/firmware/${SITE}/${TAG}"
fi

if [ -d "$TEMP_DIR" ]
if [[ -d "$TEMP_DIR" ]]
then # cleanup old tempdirs
echo "Cleaning old temporary directory"
rm -r "$TEMP_DIR"
fi

if [ ! -d "$FIRMWARE_DIR" ];
if [[ ! -d "$FIRMWARE_DIR" ]]
then
echo "Downloading firmware with tag $TAG"
mkdir -p "$TEMP_DIR/extracted"
Expand All @@ -58,6 +59,8 @@ then
do
tail -n +5 "$manifest" >> "extracted/$branch"
done
# Add --- to easily add signatures below
echo '---' >> "extracted/$branch"
done
mkdir -p "$FIRMWARE_DIR"
cp -r extracted/*/debug extracted/*/images/* extracted/*/packages "$FIRMWARE_DIR"/
Expand Down
3 changes: 3 additions & 0 deletions github-downloader/firmware-legacy-merger
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ function merge_manifests() {
# merge both files, ignoring all but the first entry ("-u") for a specific model ("-k1,1")
sort -u -k1,1 "${tempdir}/$branch.models" >> "${tempdir}/$branch"

# Add --- to easily add signatures below
echo '---' >> "${tempdir}/$branch"

echo "Merged $branch".
done
}
Expand Down

0 comments on commit d8bb870

Please sign in to comment.