#!/bin/bash # # Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com # # This file is licensed under the terms of the GNU General Public # License version 2. This program is licensed "as is" without any # warranty of any kind, whether express or implied. # This file is a part of the Armbian build script # https://github.com/armbian/build/ # This script shows packages in local repository # load user config [[ -f "../userpatches/lib.config" ]] && source "../userpatches/lib.config" # define debs path POT="../output/debs/" # load functions source general.sh DISTROS=("jessie" "xenial" "stretch") ParseOptions() { case $@ in show) # display repository content for release in "${DISTROS[@]}"; do display_alert "Displaying repository contents for" "$release" "ext" aptly repo show -with-packages -config=../config/aptly.conf $release | tail -n +7 aptly repo show -with-packages -config=../config/aptly.conf ${release}-desktop | tail -n +7 done display_alert "Displaying repository contents for" "common utils" "ext" aptly repo show -with-packages -config=../config/aptly.conf utils | tail -n +7 echo "done." exit 0 ;; update) # display full help test # run repository update addtorepo # add a key to repo cp ../config/armbian.key ../output/repository/public echo "done." exit 0 ;; purge) for release in "${DISTROS[@]}"; do repo-remove-old-packages "$release" "armhf" "5" repo-remove-old-packages "$release" "arm64" "5" aptly -config=../config/aptly.conf -passphrase=$GPG_PASS publish update $release done exit 0 ;; *) DisplayUsage exit 0 ;; esac } # ParseOptions # Removes old packages in the received repo # # $1: Repository # $2: Architecture # $3: Amount of packages to keep repo-remove-old-packages() { local repo=$1 local arch=$2 local keep=$3 for pkg in $(aptly repo search -config=../config/aptly.conf $repo "Architecture ($arch)" | grep -v "ERROR: no results" | sort -rV); do local pkg_name=$(echo $pkg | cut -d_ -f1) if [ "$pkg_name" != "$cur_pkg" ]; then local count=0 local deleted="" local cur_pkg="$pkg_name" fi test -n "$deleted" && continue let count+=1 if [ $count -gt $keep ]; then pkg_version=$(echo $pkg | cut -d_ -f2) aptly repo remove -config=../config/aptly.conf $repo "Name ($pkg_name), Version (<= $pkg_version)" deleted='yes' fi done } DisplayUsage() { echo -e "Usage: repository show | update | purge\n" echo -e "Purge removes all but last 5 versions\n" } # DisplayUsage ParseOptions "$@"