diff options
-rwxr-xr-x | buildrepo | 59 |
1 files changed, 34 insertions, 25 deletions
@@ -28,17 +28,6 @@ listpackages() { done } -# purge obsolete packages -purge() { - [ -z "$dopurge" ] && return 0 - local tmp=$(mktemp /tmp/$program-XXXXXX) - cd "$repodir/$1" || return 1 - trap 'rm -f "$tmp"; exit 1' INT - ( listpackages "$1") >$tmp - ls *.apk 2>/dev/null | grep -v -w -f $tmp | xargs rm 2>/dev/null - return 0 -} - build() { local repo="$1" i indexupdate needbuild @@ -69,11 +58,6 @@ build() { indexupdate="$indexupdate $i" done - if [ -z "$indexupdate" ] && [ -z "$needbuild" ]; then - echo ">>> Repository $repo is up-to-date." - return 0 - fi - # build the postponed packages if any if [ -n "$needbuild" ]; then for i in $needbuild; do @@ -83,18 +67,43 @@ build() { fi # kill old packages in repo - purge "$repo" + if [ -n "$dopurge" ]; then + local tmp=$(mktemp /tmp/$program-XXXXXX) + local purgefiles + cd "$repodir/$1" || return 1 + trap 'rm -f "$tmp"; exit 1' INT + ( listpackages "$1") >$tmp + purge=$(ls *.apk 2>/dev/null | grep -v -w -f $tmp) + if [ -n "$purge" ]; then + rm -f $purge + indexupdate="$indexupdate $purge" + fi + rm -f "$tmp" + fi - # generate the repository index + # check if we have any .apk newer than our index cd "$repodir/$repo" - echo ">>> Generating Index for $repo..." - md5sum *.apk | gzip -9 > INDEX.md5.gz - if which apk >/dev/null; then - local deps - for i in $deprepo; do - deps="--repo $repodir/$i" + if [ -z "$indexupdate" ]; then + for i in *.apk; do + if [ $i -nt APK_INDEX.gz ]; then + indexupdate=1 + break; + fi done - apk $deps index *.apk | gzip -9 > APK_INDEX.gz + fi + + # generate the repository index if needed + if [ -z "$indexupdate" ]; then + echo ">>> Index for $repo is up-to-date" + else + echo ">>> Generating Index for $repo..." + if which apk >/dev/null; then + local deps + for i in $deprepo; do + deps="--repo $repodir/$i" + done + apk $deps index *.apk | gzip -9 > APK_INDEX.gz + fi fi } |