@@ -271,24 +271,16 @@ update_main() {
271271 # Add packages from main folder
272272 adding_packages " common" " " " main" " $input_folder "
273273
274- # Drop old snapshot if it exists and is not published
274+ # Always drop and recreate the common snapshot to ensure it's up-to-date
275+ # This is safe because the snapshot is only used as a reference for publishing
275276 if [[ -n $( aptly snapshot list -config=" ${CONFIG} " -raw | awk ' {print $(NF)}' | grep " common" ) ]]; then
276- # Check if snapshot is published
277- if ! aptly publish list -config=" ${CONFIG} " 2> /dev/null | grep -q " common" ; then
278- run_aptly -config=" ${CONFIG} " snapshot drop common | logger -t repo-management > /dev/null
279- else
280- log " WARNING: common snapshot is published, cannot drop. Packages added to repo but snapshot not updated."
281- log " Run 'update' command to update all releases with new packages."
282- return 0
283- fi
277+ log " Dropping existing common snapshot to create fresh one"
278+ run_aptly -config=" ${CONFIG} " snapshot drop common | logger -t repo-management > /dev/null
284279 fi
285280
286- # Create new snapshot if it doesn't exist or was dropped
287- if [[ -z $( aptly snapshot list -config=" ${CONFIG} " -raw | awk ' {print $(NF)}' | grep " common" ) ]]; then
288- run_aptly -config=" ${CONFIG} " snapshot create common from repo common | logger -t repo-management > /dev/null
289- else
290- log " common snapshot already exists, skipping creation"
291- fi
281+ # Always create a fresh snapshot from the current repo state
282+ log " Creating fresh common snapshot"
283+ run_aptly -config=" ${CONFIG} " snapshot create common from repo common | logger -t repo-management > /dev/null
292284
293285 log " Common component built successfully"
294286}
@@ -354,23 +346,18 @@ process_release() {
354346 log " Force publish enabled: will publish even with no packages"
355347 fi
356348
357- # Drop old snapshots if we have new packages to add OR if FORCE_PUBLISH is enabled
358- # This ensures fresh snapshots are created for force-publish scenarios
359- if [[ " $utils_count " -gt 0 || " $FORCE_PUBLISH " == true ]]; then
360- if [[ -n $( aptly snapshot list -config=" ${CONFIG} " -raw | awk ' {print $(NF)}' | grep " ${release} -utils" ) ]]; then
361- log " Dropping existing ${release} -utils snapshot"
362- run_aptly -config=" ${CONFIG} " snapshot drop ${release} -utils | logger -t repo-management 2> /dev/null
363- fi
349+ # Always drop and recreate snapshots for fresh publish
350+ # This ensures that even empty repos are properly published
351+ if [[ -n $( aptly snapshot list -config=" ${CONFIG} " -raw | awk ' {print $(NF)}' | grep " ${release} -utils" ) ]]; then
352+ log " Dropping existing ${release} -utils snapshot"
353+ run_aptly -config=" ${CONFIG} " snapshot drop ${release} -utils | logger -t repo-management 2> /dev/null
364354 fi
365- if [[ " $desktop_count " -gt 0 || " $FORCE_PUBLISH " == true ]]; then
366- if [[ -n $( aptly snapshot list -config=" ${CONFIG} " -raw | awk ' {print $(NF)}' | grep " ${release} -desktop" ) ]]; then
367- log " Dropping existing ${release} -desktop snapshot"
368- run_aptly -config=" ${CONFIG} " snapshot drop ${release} -desktop | logger -t repo-management 2> /dev/null
369- fi
355+ if [[ -n $( aptly snapshot list -config=" ${CONFIG} " -raw | awk ' {print $(NF)}' | grep " ${release} -desktop" ) ]]; then
356+ log " Dropping existing ${release} -desktop snapshot"
357+ run_aptly -config=" ${CONFIG} " snapshot drop ${release} -desktop | logger -t repo-management 2> /dev/null
370358 fi
371359
372- # Create snapshots only for repos that have packages
373- # OR when FORCE_PUBLISH is enabled (then we publish whatever exists in the DB)
360+ # Create snapshots for all repos (even empty ones) to ensure they're included in publish
374361 # In isolated mode, do NOT include common snapshot - it will be merged later
375362 local components_to_publish=()
376363 local snapshots_to_publish=()
@@ -381,51 +368,17 @@ process_release() {
381368 snapshots_to_publish=(" common" )
382369 fi
383370
384- if [[ " $utils_count " -gt 0 || " $FORCE_PUBLISH " == true ]]; then
385- # Only create snapshot if repo has packages, or if force-publishing
386- if [[ " $utils_count " -gt 0 ]]; then
387- run_aptly -config=" ${CONFIG} " snapshot create ${release} -utils from repo ${release} -utils | logger -t repo-management > /dev/null
388- components_to_publish+=(" ${release} -utils" )
389- snapshots_to_publish+=(" ${release} -utils" )
390- elif [[ " $FORCE_PUBLISH " == true ]]; then
391- log " Force publish: checking for existing ${release} -utils snapshot in DB"
392- # Try to use existing snapshot if it exists
393- if [[ -n $( aptly snapshot list -config=" ${CONFIG} " -raw | awk ' {print $(NF)}' | grep " ${release} -utils" ) ]]; then
394- components_to_publish+=(" ${release} -utils" )
395- snapshots_to_publish+=(" ${release} -utils" )
396- log " Using existing ${release} -utils snapshot"
397- else
398- # Create empty snapshot from empty repo
399- run_aptly -config=" ${CONFIG} " snapshot create ${release} -utils from repo ${release} -utils | logger -t repo-management > /dev/null
400- components_to_publish+=(" ${release} -utils" )
401- snapshots_to_publish+=(" ${release} -utils" )
402- log " Created empty ${release} -utils snapshot for force publish"
403- fi
404- fi
405- fi
371+ # Always create utils snapshot and include in publish (even if empty)
372+ log " Creating ${release} -utils snapshot (packages: $utils_count )"
373+ run_aptly -config=" ${CONFIG} " snapshot create ${release} -utils from repo ${release} -utils | logger -t repo-management > /dev/null
374+ components_to_publish+=(" ${release} -utils" )
375+ snapshots_to_publish+=(" ${release} -utils" )
406376
407- if [[ " $desktop_count " -gt 0 || " $FORCE_PUBLISH " == true ]]; then
408- # Only create snapshot if repo has packages, or if force-publishing
409- if [[ " $desktop_count " -gt 0 ]]; then
410- run_aptly -config=" ${CONFIG} " snapshot create ${release} -desktop from repo ${release} -desktop | logger -t repo-management > /dev/null
411- components_to_publish+=(" ${release} -desktop" )
412- snapshots_to_publish+=(" ${release} -desktop" )
413- elif [[ " $FORCE_PUBLISH " == true ]]; then
414- log " Force publish: checking for existing ${release} -desktop snapshot in DB"
415- # Try to use existing snapshot if it exists
416- if [[ -n $( aptly snapshot list -config=" ${CONFIG} " -raw | awk ' {print $(NF)}' | grep " ${release} -desktop" ) ]]; then
417- components_to_publish+=(" ${release} -desktop" )
418- snapshots_to_publish+=(" ${release} -desktop" )
419- log " Using existing ${release} -desktop snapshot"
420- else
421- # Create empty snapshot from empty repo
422- run_aptly -config=" ${CONFIG} " snapshot create ${release} -desktop from repo ${release} -desktop | logger -t repo-management > /dev/null
423- components_to_publish+=(" ${release} -desktop" )
424- snapshots_to_publish+=(" ${release} -desktop" )
425- log " Created empty ${release} -desktop snapshot for force publish"
426- fi
427- fi
428- fi
377+ # Always create desktop snapshot and include in publish (even if empty)
378+ log " Creating ${release} -desktop snapshot (packages: $desktop_count )"
379+ run_aptly -config=" ${CONFIG} " snapshot create ${release} -desktop from repo ${release} -desktop | logger -t repo-management > /dev/null
380+ components_to_publish+=(" ${release} -desktop" )
381+ snapshots_to_publish+=(" ${release} -desktop" )
429382
430383 log " Publishing $release with components: ${components_to_publish[*]} "
431384
@@ -922,44 +875,57 @@ merge_repos() {
922875 local components_to_publish=(" main" )
923876 local snapshots_to_publish=(" common" )
924877
925- # Check if utils repo has packages
878+ # Check if utils repo exists and has packages
926879 local utils_has_packages=false
927880 if aptly -config=" $main_db_config " repo show " ${release} -utils" & > /dev/null; then
928881 local utils_count=$( aptly -config=" $main_db_config " repo show " ${release} -utils" 2> /dev/null | grep " Number of packages" | awk ' {print $4}' || echo " 0" )
929882 log " Utils repo has $utils_count packages"
930- if [[ " $utils_count " -gt 0 ]]; then
931- utils_has_packages=true
932- # Drop old snapshot if exists
933- if [[ -n $( aptly -config=" $main_db_config " snapshot list -raw | awk ' {print $(NF)}' | grep " ${release} -utils" ) ]]; then
934- run_aptly -config=" $main_db_config " snapshot drop " ${release} -utils"
935- fi
936- # Create new snapshot
937- run_aptly -config=" $main_db_config " snapshot create " ${release} -utils" from repo " ${release} -utils"
938- components_to_publish+=(" ${release} -utils" )
939- snapshots_to_publish+=(" ${release} -utils" )
883+
884+ # Always drop old snapshot if exists to ensure fresh publish
885+ if [[ -n $( aptly -config=" $main_db_config " snapshot list -raw | awk ' {print $(NF)}' | grep " ${release} -utils" ) ]]; then
886+ log " Dropping existing ${release} -utils snapshot"
887+ run_aptly -config=" $main_db_config " snapshot drop " ${release} -utils"
940888 fi
889+
890+ # Always create a new snapshot for publishing, even if repo is empty
891+ # This ensures the component is included in the published repository
892+ run_aptly -config=" $main_db_config " snapshot create " ${release} -utils" from repo " ${release} -utils"
893+ components_to_publish+=(" ${release} -utils" )
894+ snapshots_to_publish+=(" ${release} -utils" )
941895 else
942- log " Utils repo does not exist in main DB"
896+ log " Utils repo does not exist in main DB - creating it"
897+ # Create the repo if it doesn't exist
898+ run_aptly -config=" $main_db_config " repo create -component=" ${release} -utils" -distribution=" ${release} " -comment=" Armbian ${release} -utils repository" " ${release} -utils"
899+ # Create empty snapshot
900+ run_aptly -config=" $main_db_config " snapshot create " ${release} -utils" from repo " ${release} -utils"
901+ components_to_publish+=(" ${release} -utils" )
902+ snapshots_to_publish+=(" ${release} -utils" )
943903 fi
944904
945- # Check if desktop repo has packages
905+ # Check if desktop repo exists and has packages
946906 local desktop_has_packages=false
947907 if aptly -config=" $main_db_config " repo show " ${release} -desktop" & > /dev/null; then
948908 local desktop_count=$( aptly -config=" $main_db_config " repo show " ${release} -desktop" 2> /dev/null | grep " Number of packages" | awk ' {print $4}' || echo " 0" )
949909 log " Desktop repo has $desktop_count packages"
950- if [[ " $desktop_count " -gt 0 ]]; then
951- desktop_has_packages=true
952- # Drop old snapshot if exists
953- if [[ -n $( aptly -config=" $main_db_config " snapshot list -raw | awk ' {print $(NF)}' | grep " ${release} -desktop" ) ]]; then
954- run_aptly -config=" $main_db_config " snapshot drop " ${release} -desktop"
955- fi
956- # Create new snapshot
957- run_aptly -config=" $main_db_config " snapshot create " ${release} -desktop" from repo " ${release} -desktop"
958- components_to_publish+=(" ${release} -desktop" )
959- snapshots_to_publish+=(" ${release} -desktop" )
910+
911+ # Always drop old snapshot if exists to ensure fresh publish
912+ if [[ -n $( aptly -config=" $main_db_config " snapshot list -raw | awk ' {print $(NF)}' | grep " ${release} -desktop" ) ]]; then
913+ log " Dropping existing ${release} -desktop snapshot"
914+ run_aptly -config=" $main_db_config " snapshot drop " ${release} -desktop"
960915 fi
916+
917+ # Always create a new snapshot for publishing, even if repo is empty
918+ run_aptly -config=" $main_db_config " snapshot create " ${release} -desktop" from repo " ${release} -desktop"
919+ components_to_publish+=(" ${release} -desktop" )
920+ snapshots_to_publish+=(" ${release} -desktop" )
961921 else
962- log " Desktop repo does not exist in main DB"
922+ log " Desktop repo does not exist in main DB - creating it"
923+ # Create the repo if it doesn't exist
924+ run_aptly -config=" $main_db_config " repo create -component=" ${release} -desktop" -distribution=" ${release} " -comment=" Armbian ${release} -desktop repository" " ${release} -desktop"
925+ # Create empty snapshot
926+ run_aptly -config=" $main_db_config " snapshot create " ${release} -desktop" from repo " ${release} -desktop"
927+ components_to_publish+=(" ${release} -desktop" )
928+ snapshots_to_publish+=(" ${release} -desktop" )
963929 fi
964930
965931 # Always publish - at minimum, the main/common component is included
0 commit comments