Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Meta PyPCC
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Operate
Environments
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
Meta PyPCC
Commits
7084e0d5
Commit
7084e0d5
authored
1 month ago
by
Reinder Kraaij
Browse files
Options
Downloads
Patches
Plain Diff
Software module, distset
parent
cee0239f
No related branches found
No related tags found
2 merge requests
!15
Resolve L2SS-2305 "Add hawkbit support"
,
!4
L2SS-2305: Add Hawkbit support
Pipeline
#124530
skipped
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
publish/create_software_module_with_distset.sh
+118
-0
118 additions, 0 deletions
publish/create_software_module_with_distset.sh
with
119 additions
and
1 deletion
.gitlab-ci.yml
+
1
−
1
View file @
7084e0d5
...
...
@@ -37,7 +37,7 @@ publish_to_hawkbit:
script
:
-
cd publish
-
chmod +x *.sh
-
./create_software_module.sh
-
./create_software_module
_with_distset
.sh
-
./publish_to_hawkbit.sh
...
...
This diff is collapsed.
Click to expand it.
publish/create_software_module.sh
→
publish/create_software_module
_with_distset
.sh
+
118
−
0
View file @
7084e0d5
...
...
@@ -5,14 +5,15 @@ DEFAULT_SERVER="https://ota.lofar.net"
SERVER
=
"
${
1
:-
$DEFAULT_SERVER
}
"
# Software module metadata
MODULE_NAME
=
"
CCD/
APSCT Yocto Image"
MODULE_NAME
=
"
Lofar CCD and
APSCT Yocto Image"
MODULE_TYPE
=
"os"
MODULE_VENDOR
=
"LOFAR"
MODULE_DESC
=
"Yocto image for Raspberry Pi"
# Distribution metadata
DIST_NAME
=
"Lofar CCD/APSCT Yocto Image Distribution"
DIST_DESC
=
"Distribution for CCD/APSCT Raspberry Pi Yocto images"
# 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
...
...
@@ -25,12 +26,19 @@ fi
echo
"Using version:
$MODULE_VERSION
"
# 1. Check if software module exists and get its ID
# 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?
page=0&size=100
"
)
"
$SERVER
/rest/v1/softwaremodules?
q=
$query_sm_enc
&limit=1
"
)
module_id
=
$(
echo
"
$modules
"
| jq
-r
--arg
name
"
$MODULE_NAME
"
--arg
version
"
$MODULE_VERSION
"
\
'.content[] | select(.name == $name and .version == $version) | .id // empty'
)
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
."
...
...
@@ -60,24 +68,51 @@ else
echo
"➤ Created software module with ID:
$module_id
"
fi
# 2. Check if distribution exists
distributions
=
$(
curl
-s
-u
"
$HAWKBITUSER
:
$HAWKBITPW
"
\
"
$SERVER
/rest/v1/distributions?page=0&size=100"
)
# 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
echo
"
$distributions
"
| jq
-e
--arg
name
"
$DIST_NAME
"
\
'.content[] | select(.name == $name)'
>
/dev/null
;
then
echo
"➤ Distribution
\"
$DIST_NAME
\"
already exists."
if
[
-n
"
$distset_id
"
]
;
then
echo
"➤ Distribution set
\"
$DISTSET_NAME
\"
already exists with ID
$distset_id
."
else
echo
"➤ Creating distribution
\"
$DIST_NAME
\"
..."
echo
"➤ Creating distribution
set
\"
$DIST
SET
_NAME
\"
..."
dist_payload
=
$(
jq
-n
\
--arg
name
"
$DIST_NAME
"
\
--arg
desc
"
$DIST_DESC
"
\
--argjson
modules
"[{
\"
id
\"
:
\"
$module_id
\"
}]"
\
'{ name: $name, description: $desc, softwareModules: $modules, enabled: true }'
)
# 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 .
curl
-s
-w
"
\n
→ HTTP %{http_code}
\n
"
-u
"
$HAWKBITUSER
:
$HAWKBITPW
"
\
response
=
$(
curl
-s
-u
"
$HAWKBITUSER
:
$HAWKBITPW
"
\
-H
"Content-Type: application/json"
\
-X
POST
"
$SERVER
/rest/v1/distributions"
\
-d
"
$dist_payload
"
-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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment