From 1c7e4ba3944d835bc268d3ec081085ffafe2b600 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 29 Jul 2013 09:43:30 -0400 Subject: update_feeds(): Remove empty feeds. --- diff --git a/lib/index.sh b/lib/index.sh index 5fcaf5c..28d053c 100644 --- a/lib/index.sh +++ b/lib/index.sh @@ -86,41 +86,53 @@ feed_remove_package() update_feeds() { - local script= local suite_dirent= + local chan= + local dist= + local suite= local archplat_dirent= + local plat= + local arch= + local archplat= local sect_dirent= - local feed= + local sect= local hash_dirent= local idx= - script='s|^.*//*\(..*\)_\(..*\)//*\(..*\)_\(..*\)//*\(..*\)/$' - script="${script}|${opt_base_dir}/feeds/"'\1/\2/\3/\4/\5|' - # For each suite: for suite_dirent in "${opt_base_dir}/feeds/.db/"*_*/; do if [ ! -d "${suite_dirent}" ]; then continue fi + chan="${suite_dirent%/}" + chan="${chan##*/}" + dist="${chan##*_}" + chan="${chan%_*}" + suite="${opt_base_dir}/feeds/${chan}/${dist}" # For each archplat: for archplat_dirent in "${suite_dirent}/"*_*/; do if [ ! -d "${archplat_dirent}" ]; then continue fi + plat="${archplat_dirent%/}" + plat="${plat##*/}" + arch="${plat##*_}" + plat="${plat%_*}" + archplat="${suite}/${plat}/${arch}" # For each section: for sect_dirent in "${archplat_dirent}/"*/; do if [ ! -d "${sect_dirent}" ]; then continue fi - # Get the feed path from the index path. - feed="$(printf '%s\n' "${sect_dirent}" | \ - sed "${script}")" + sect="${sect_dirent%/}" + sect="${sect##*/}" + sect="${archplat}/${sect}" # For each package name hash: for hash_dirent in "${sect_dirent}/"*; do if [ ! -f "${hash_dirent}" ]; then continue fi - idx="${feed}/.db/${hash_dirent##*/}" + idx="${sect}/.db/${hash_dirent##*/}" # Ensure there are still packages here. if [ -d "${idx}/info" ]; then cat "${idx}/info/"*.control \ @@ -132,19 +144,24 @@ update_feeds() rm -f "${hash_dirent}" done # Ensure there are still packages here. - if ! try_rmdir "${feed}/.db"; then - cat "${feed}/.db/"*/Packages \ - >"${feed}/Packages~" - mv "${feed}/Packages~" \ - "${feed}/Packages" + if ! try_rmdir "${sect}/.db"; then + cat "${sect}/.db/"*/Packages \ + >"${sect}/Packages~" + mv "${sect}/Packages~" \ + "${sect}/Packages" else - >"${feed}/Packages" + rm -f "${sect}/Packages" fi rmdir "${sect_dirent}" + try_rmdir "${sect}" done rmdir "${archplat_dirent}" + try_rmdir "${archplat}" + try_rmdir "${archplat%/*}" done rmdir "${suite_dirent}" + try_rmdir "${suite}" + try_rmdir "${suite%/*}" done return 0 -- cgit v0.9.1