Just slight improvements over work-in-progress Debian package builder.

* variable substitution in .spec files
* abort reading %description in .spec files after running into %
* now .tar.gz is built less often (meaning 'make distclean' is called less often)

Still, only gnustep-make can be built, unfortunately.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@37789 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Ivan Vučica 2014-04-07 01:20:27 +00:00
parent befda337de
commit 551cf1669f
2 changed files with 28 additions and 13 deletions

View file

@ -66,25 +66,26 @@ _ABS_OBJ_DIR=$(shell (cd "$(GNUSTEP_BUILD_DIR)"; pwd))/obj
ifeq ($(DEB_BUILD_DEPENDS), )
DEB_BUILD_DEPENDS=gnustep-make (=$(GNUSTEP_MAKE_VERSION))
else
DEB_BUILD_DEPENDS=$(DEB_BUILD_DEPENDS), gnustep-make (=$(GNUSTEP_MAKE_VERSION))
DEB_BUILD_DEPENDS+=, gnustep-make (=$(GNUSTEP_MAKE_VERSION))
endif
.PHONY: deb
ifeq ($(_DEB_SHOULD_EXPORT), )
../$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz: dist
deb: ../$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz
_DEB_SHOULD_EXPORT=1 make deb
else
# Export all variables, but only in explicit invocation of 'make deb'
export
deb:
if [ ! -e ../$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz ] ; then make dist ; else echo "Source file already exists; NOT rebuilding. Please manually remove if desired." ; fi
$(ECHO_NOTHING)echo "Generating the deb package..."$(END_ECHO)
-rm -rf $(_ABS_OBJ_DIR)/debian_dist
mkdir -p $(_ABS_OBJ_DIR)/debian_dist
cp ../$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz $(_ABS_OBJ_DIR)/debian_dist/$(_DEB_ORIGTARNAME).orig.tar.gz
cd $(_ABS_OBJ_DIR)/debian_dist && tar xfz $(_DEB_ORIGTARNAME).orig.tar.gz
/bin/bash $(GNUSTEP_MAKEFILES)/bake_debian_files.sh $(_ABS_OBJ_DIR)/debian_dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/
_DEB_SHOULD_EXPORT=1 make _debfiles
printf "\noverride_dh_auto_configure:\n\tdh_auto_configure -- $(DEB_CONFIGURE_FLAGS)\noverride_dh_auto_build:\n\tmake\n\tdh_auto_build\nbuild::\n\tmake" >> $(_ABS_OBJ_DIR)/debian_dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/debian/rules
cd $(_ABS_OBJ_DIR)/debian_dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/ && debuild -us -uc
else
# Export all variables, but only if we explicitly are working with bake_debian_files.sh
export
_debfiles:
/bin/bash $(GNUSTEP_MAKEFILES)/bake_debian_files.sh $(_ABS_OBJ_DIR)/debian_dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)/
endif

View file

@ -66,22 +66,31 @@ DEB_DISTRIBUTION=${DEB_DISTRIBUTION:-${default_distribution}}
if which python > /dev/null ; then
FN=$(python - << _EOF
# TODO: This code does not perform substitution of variables in .spec.in files.
import tempfile
import sys
def process_specfile(specfilename):
description_mode=False
with tempfile.NamedTemporaryFile(delete=False) as tf:
with open(specfilename) as specfile:
with open(specfilename) as specfile:
with tempfile.NamedTemporaryFile(delete=False) as tf:
print tf.name
vars={}
for line in specfile.readlines():
line=line.rstrip()
for var in vars:
line.replace('%{%s}' % var, vars[var])
if description_mode:
if len(line.lstrip()) > 0 and line.lstrip()[0] == '#':
continue
if len(line.lstrip()) > 0 and line.lstrip()[0] == '%':
description_mode=False
continue
tf.write("RPM_DESCRIPTION=\"\${RPM_DESCRIPTION}%s\\n\"\n" % line.replace('\\'', '\\\\\\'').replace('\\"', '\\\\\\"').replace('(', '\\(').replace(')', '\\)'))
continue
if not len(line):
continue
components=line.split(':')
@ -142,6 +151,11 @@ def process_specfile(specfilename):
else:
if line == "%description":
description_mode = True
elif line.startswith('%define'):
segs=line[len('%define')+1].lstrip().split(' ')
segs=[seg.rstrip().lstrip() for seg in segs]
vars[segs[0]] = ' '.segs[1:].join()
try:
process_specfile('${DEB_PACKAGE}.spec')
@ -260,7 +274,7 @@ echo "Description:" "$(echo "${DEB_DESCRIPTION}" | sed 's/^[\s]*$/./' | sed 's/\
echo "${DEB_SOURCE} (${DEB_VERSION}) ${DEB_DISTRIBUTION}; urgency=low" >> "${destination}"/changelog
echo "" >> "${destination}"/changelog
echo " * New build." >> "${destination}"/changelog
echo " * New build." >> "${destination}"/changelog
echo "" >> "${destination}"/changelog
echo "" >> "${destination}"/changelog
echo " -- ${DEB_PACKAGE_BUILDER} $(date -R)" >> "${destination}"/changelog