Skip to content
Snippets Groups Projects
Commit b8381ee6 authored by Reinder Kraaij's avatar Reinder Kraaij :eye:
Browse files

revert changes, move to own branch

parent 7084e0d5
No related branches found
No related tags found
2 merge requests!15Resolve L2SS-2305 "Add hawkbit support",!4L2SS-2305: Add Hawkbit support
Pipeline #124532 skipped
......@@ -10,7 +10,6 @@ variables:
stages:
- build
- publish
run_build:
stage: build
......@@ -24,23 +23,3 @@ run_build:
artifacts:
paths:
- artifacts/*
\ No newline at end of file
publish_to_hawkbit:
image:
name: alpine/curl
stage: build
when: manual
environment:
name: production
script:
- cd publish
- chmod +x *.sh
- ./create_software_module_with_distset.sh
- ./publish_to_hawkbit.sh
#!/bin/sh
# Default server URL
DEFAULT_SERVER="https://ota.lofar.net"
SERVER="${1:-$DEFAULT_SERVER}"
# Software module metadata
MODULE_NAME="Lofar CCD and APSCT Yocto Image"
MODULE_TYPE="os"
MODULE_VENDOR="LOFAR"
MODULE_DESC="Yocto image for Raspberry Pi"
# Distribution set metadata
DISTSET_NAME="Lofar CCD and APSCT Yocto Image Distribution"
DISTSET_DESC="Distribution set for CCD APSCT Raspberry Pi Yocto images"
DISTSET_TYPE="os_app" # its a full os with apps :)
# Determine version from GitLab CI or local commit
if [ -n "$CI_COMMIT_TAG" ]; then
MODULE_VERSION="$CI_COMMIT_TAG"
elif [ -n "$CI_COMMIT_SHORT_SHA" ]; then
MODULE_VERSION="dev-${CI_COMMIT_SHORT_SHA}"
else
MODULE_VERSION="dev-$(git rev-parse --short HEAD)"
fi
echo "Using version: $MODULE_VERSION"
# urlencode function using jq
urlencode() {
printf '%s' "$1" | jq -sRr @uri
}
# 1. Check if software module exists and get its ID, using q filter
query_sm="name==\"$MODULE_NAME\";version==\"$MODULE_VERSION\""
query_sm_enc=$(urlencode "$query_sm")
modules=$(curl -s -u "$HAWKBITUSER:$HAWKBITPW" \
"$SERVER/rest/v1/softwaremodules?q=$query_sm_enc&limit=1")
module_id=$(echo "$modules" | jq -r '.content[0].id // empty')
if [ -n "$module_id" ]; then
echo "➤ Software module \"$MODULE_NAME\" version \"$MODULE_VERSION\" already exists with ID $module_id."
else
echo "➤ Creating software module \"$MODULE_NAME\" version \"$MODULE_VERSION\"..."
payload=$(jq -n \
--arg name "$MODULE_NAME" \
--arg version "$MODULE_VERSION" \
--arg type "$MODULE_TYPE" \
--arg vendor "$MODULE_VENDOR" \
--arg desc "$MODULE_DESC" \
'{ name: $name, version: $version, type: $type, vendor: $vendor, description: $desc, encrypted: false }')
response=$(curl -s -u "$HAWKBITUSER:$HAWKBITPW" \
-H "Content-Type: application/json" \
-X POST "$SERVER/rest/v1/softwaremodules" \
-d "[$payload]")
module_id=$(echo "$response" | jq -r '.[0].id')
if [ -z "$module_id" ] || [ "$module_id" = "null" ]; then
echo "❌ ERROR: Failed to create software module or parse module ID"
exit 1
fi
echo "➤ Created software module with ID: $module_id"
fi
# 2. Check if distribution set exists and get its ID, using q filter
query_ds="name==\"$DISTSET_NAME\""
query_ds_enc=$(urlencode "$query_ds")
distsets=$(curl -s -u "$HAWKBITUSER:$HAWKBITPW" \
"$SERVER/rest/v1/distributionsets?q=$query_ds_enc&limit=1")
#echo "$distsets"
distset_id=$(echo "$distsets" | jq -r '.content[0]?.id // empty')
if [ -n "$distset_id" ]; then
echo "➤ Distribution set \"$DISTSET_NAME\" already exists with ID $distset_id."
else
echo "➤ Creating distribution set \"$DISTSET_NAME\"..."
# Prepare modules array with module_id converted to number inside jq
modules_array=$(jq -n --arg id "$module_id" '[{id: ($id|tonumber)}]')
distset_payload=$(jq -n \
--arg name "$DISTSET_NAME" \
--arg desc "$DISTSET_DESC" \
--arg version "$MODULE_VERSION" \
--arg type "$DISTSET_TYPE" \
--argjson modules "$modules_array" \
'{
name: $name,
description: $desc,
version: $version,
locked: true,
requiredMigrationStep: false,
modules: $modules,
type: $type
}')
#echo "$distset_payload" | jq .
response=$(curl -s -u "$HAWKBITUSER:$HAWKBITPW" \
-H "Content-Type: application/json" \
-X POST "$SERVER/rest/v1/distributionsets" \
-d "[$distset_payload]")
echo "$response"
distset_id=$(echo "$response" | jq -r '.[0].id')
if [ -z "$distset_id" ] || [ "$distset_id" = "null" ]; then
echo "❌ ERROR: Failed to create distribution set or parse ID"
exit 1
fi
echo "➤ Created distribution set with ID: $distset_id"
fi
#!/bin/sh
echo "work in progress"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment