build: fix STAGING_DIR cleaning for packages

This fixes two issues with cleaning package files from STAGING_DIR:

* CleanStaging currently can only remove files and not directories. This
  changes CleanStaging to use clean-package.sh, which does remove
  directories.

* Because of the way directories are ordered in the staging files list,
  clean-package.sh currently tries (and fails) to remove parent
  directories before removing subdirectories. This changes
  clean-package.sh to process the staging files list in reverse, so that
  subdirectories are removed first.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
openwrt-19.07
Jeffery To 2018-12-13 01:33:36 +08:00 committed by Jo-Philipp Wich
parent ed514e7f9e
commit a117093679
2 changed files with 5 additions and 4 deletions

View File

@ -81,9 +81,10 @@ STAGING_FILES_LIST:=$(PKG_DIR_NAME)$(if $(BUILD_VARIANT),.$(BUILD_VARIANT),).lis
define CleanStaging define CleanStaging
rm -f $(STAMP_INSTALLED) rm -f $(STAMP_INSTALLED)
@-(\ @-(\
cd "$(STAGING_DIR)"; \ if [ -f $(STAGING_DIR)/packages/$(STAGING_FILES_LIST) ]; then \
if [ -f packages/$(STAGING_FILES_LIST) ]; then \ $(SCRIPT_DIR)/clean-package.sh \
cat packages/$(STAGING_FILES_LIST) | xargs -r rm -f 2>/dev/null; \ "$(STAGING_DIR)/packages/$(STAGING_FILES_LIST)" \
"$(STAGING_DIR)"; \
fi; \ fi; \
) )
endef endef

View File

@ -14,7 +14,7 @@ cat "$1" | (
[ -f "$entry" ] && rm -f $entry [ -f "$entry" ] && rm -f $entry
done done
) )
cat "$1" | ( sort -r "$1" | (
cd "$2" cd "$2"
while read entry; do while read entry; do
[ -n "$entry" ] || break [ -n "$entry" ] || break