Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firmware-downloader: add "---" to manifests #150

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading