Fixed part that cleans up files from a replaced package

This commit is contained in:
2016-10-31 13:53:18 -05:00
parent db84b56b51
commit 388430ed37
9 changed files with 4 additions and 5 deletions

View File

@@ -0,0 +1,95 @@
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation here:
# (http://www.gnu.org/licenses/gpl-2.0.html)
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
PWD := $(shell pwd)
PACKAGE := $(shell echo $(PWD)|sed 's/.*\///')
SNAPDIR = $(PWD)/SNAP
ROOT = $(PWD)/ROOT
BYTES = 0
SNAP = $(PACKAGE)-$(VERSION).snap
SNAPINFO = $(SNAPDIR)/snapinfo
MANIFEST = $(SNAPDIR)/manifest
USHER = $(SNAPDIR)/usher
FILES = $(SNAPDIR)/files.tar.gz
# The following values must be set in the Makefile for the package
ifndef ARCHIVE
$(error ARCHIVE is not set)
endif
ifndef SRCDIR
$(error SRCDIR is not set)
endif
ifndef VERSION
$(error VERSION is not set)
endif
$(SNAP): $(SNAPINFO) $(FILES)
@if [ -f $(SNAP) ]; then \
rm -v $(SNAP); \
fi
@ar cvr $(SNAP) $(SNAPINFO) $(MANIFEST); \
if [ -f $(USHER) ]; then \
chmod +x $(USHER); \
ar cvr $(SNAP) $(USHER); \
fi; \
ar cvr $(SNAP) $(FILES)
@echo "Successfully built $(SNAP)"
$(SNAPINFO): $(MANIFEST)
@>$(SNAPINFO)
$(eval BYTES := $(shell du -sB1 $(ROOT)|awk '{print $$1}'))
@printf "package: $(PACKAGE)\nversion: $(VERSION)\n" > $(SNAPINFO); \
printf "depends: $(DEPENDS)\narch: $(ARCH)\nbytes: $(BYTES)\n" \
>> $(SNAPINFO); \
printf "url: $(URL)\ndescription: $(DESC)\n" >> $(SNAPINFO)
$(MANIFEST): $(FILES)
@>$(MANIFEST)
@bytes=0; \
rootfiles=`cd $(ROOT) && find ! -path .|sed 's/^\.\///'|sort -r`; \
while read -r file; do \
info=`ls -ld "$(ROOT)/$$file"`; \
perm=`echo $$info|awk '{print $$1}'`; \
type=`echo $$perm|head -c1`; \
sha='________________________________________'; \
if [ $$type = 'c' ]; then \
size=0; \
fi; \
if [ -f "$(ROOT)/$$file" ]; then \
sha=`sha1sum "$(ROOT)/$$file"|awk '{print $$1}'`; \
fi; \
printf "$$sha\t$$perm\t$$file\n" >> $(MANIFEST); \
done <<< "$$rootfiles"
$(FILES): $(ROOT)
# Remove any perllocal.pod to avoid conflicts
# Should try to properly fix this some time...
@find $(ROOT) -name perllocal.pod -exec rm {} \;
@files=`find $(ROOT) -type f -exec file -i '{}' \;| grep \
'application/x-\(executable\|object\|sharedlib\);' | \
grep ' charset=binary'`; \
while read -r line; do \
file=`echo $$line|sed 's/: application\/x-.*//'`; \
if [ "$$file" != '' ]; then \
strip --strip-unneeded $$file; \
fi; \
done <<< "$$files"
@cd $(ROOT) && tar cvzf $(FILES) *