summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-07-29 09:43:30 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-07-29 09:43:30 (EDT)
commit1c7e4ba3944d835bc268d3ec081085ffafe2b600 (patch)
treec4d4a6c03a488ace89b88f9f5e682417a17a6822 /lib
parentd131b8ee170bd44670904f1641dac8fb2ef85cdb (diff)
update_feeds(): Remove empty feeds.
Diffstat (limited to 'lib')
-rw-r--r--lib/index.sh47
1 files changed, 32 insertions, 15 deletions
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