diff --git a/tools/repository/repo b/tools/repository/repo index 6795b41851db..51ed6d2bcb2e 100755 --- a/tools/repository/repo +++ b/tools/repository/repo @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -e # Drop unsupported releases drop_unsupported_releases() { @@ -44,9 +45,8 @@ for f in "${4}${2}"/*.deb; do version=$(echo "${package}" | awk /Version/'{print $2}') arch=$(echo "${package}" | awk /Architecture/'{print $2}') # add if not already there - aptly repo search -architectures="${arch}" -config="${CONFIG}" "${1}" \ - 'Name (% '${name}'), $Version (='${version}'), $Architecture (='${arch}')' &> /dev/null - if [[ $? -ne 0 ]]; then + if aptly repo search -architectures="${arch}" -config="${CONFIG}" "${1}" \ + 'Name (% '${name}'), $Version (='${version}'), $Architecture (='${arch}')' &> /dev/null; then echo -e "Checking and adding \x1B[92m$name\x1B[0m to repository \x1B[92m$release $3\x1B[0m" aptly repo add -config="${CONFIG}" "${1}" "${f}" &> /dev/null fi @@ -160,7 +160,7 @@ for release in "${distributions[@]}"; do sudo date +%s > ${2}/public/control # publish echo "Publishing: ${release}" - aptly publish \ + if aptly publish \ -acquire-by-hash \ -architectures="armhf,arm64,amd64,riscv64,i386,all" \ -passphrase="${4}" \ @@ -168,8 +168,7 @@ for release in "${distributions[@]}"; do -label="Armbian" \ -config="${CONFIG}" \ -component="${COMPONENTS// /,}" \ - -distribution="${release}" repo "${release}" ${COMPONENTS//main/} > /dev/null - if [[ $? -ne 0 ]]; then + -distribution="${release}" repo "${release}" ${COMPONENTS//main/} > /dev/null; then echo "Publishing failed ${release}" errors=$((errors + 1)) exit 0 @@ -277,11 +276,8 @@ case $3 in LIST=("${new_list[@]}") LIST_LENGTH=$((${#LIST[@]} / 2)) exec 3>&1 - TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "BACKTITLE" --no-collapse --title \ - "Remove packages from repositories" --clear --menu "Delete" $((9 + LIST_LENGTH)) 82 65 "${LIST[@]}" 2>&1 1>&3) - exitstatus=$? - exec 3>&- - if [[ $exitstatus -eq 0 ]]; then + if TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "BACKTITLE" --no-collapse --title \ + "Remove packages from repositories" --clear --menu "Delete" $((9 + LIST_LENGTH)) 82 65 "${LIST[@]}" 2>&1 1>&3); then for release in "${DISTROS[@]}"; do aptly repo remove -config="${CONFIG}" "${release}" "$TARGET_VERSION" aptly repo remove -config="${CONFIG}" "${release}-utils" "$TARGET_VERSION" @@ -290,6 +286,7 @@ case $3 in else return 1 fi + exec 3>&- aptly db cleanup -config="${CONFIG}" > /dev/null 2>&1 # remove empty folders find $2/public -type d -empty -print -exec rm -rf {} \; @@ -399,6 +396,4 @@ sed 's|"rootDir": ".*"|"rootDir": "'$output'"|g' tools/repository/aptly.conf > " CONFIG="${TempDir}/aptly.conf" # main -repo-manipulate "$input" "$output" "$command" "$password" "$releases" "$list" -RETURN=$? -exit $RETURN +exit $(repo-manipulate "$input" "$output" "$command" "$password" "$releases" "$list")