common-test/make-archive.sh

38 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
#
# Make the archivefile for Make mockbuild
# Called from the arhcivefile rule in common/Makefile.common
#
NAME=$(basename `pwd`)
VER_REL=$(rpm -q --qf "%{VERSION}\n" --specfile ${NAME}.spec | head -1)
ARCHIVEFILE=$(cat ${NAME}.spec | grep Source | sed -r 's/^Source[0..9]*:\s*//' | xargs basename)
ARCHIVEFILE=$(rpm --queryformat "${ARCHIVEFILE}\n" --specfile ${NAME}.spec | head -n 1)
TEMPDIR=`mktemp -d`
TREEPATH="$NAME-$VER_REL"
echo -e "\n$NAME $ARCHIVEFILE $TREEPATH"
echo -e "\nMaking archive file ${ARCHIVEFILE} `pwd`" ; \
if [ "${NAME#smeserver}" = "${NAME}" ] || [ "${NAME#e-smith}" = "${NAME}" ] ; then \
echo -e "\nBuilding for SME package"; \
echo -e "\nMaking archive ${ARCHIVEFILE}"; \
TEMPDIR=`mktemp -d`; \
mkdir -p ${TEMPDIR}/${TREEPATH}; \
cp -r root ${TEMPDIR}/${TREEPATH}; \
if test -f createlinks ; then cp createlinks ${TEMPDIR}/${TREEPATH} ; fi ; \
if test -f COPYING ; then cp COPYING ${TEMPDIR}/${TREEPATH} ; fi ; \
if test -f LICENSE ; then cp LICENSE ${TEMPDIR}/${TREEPATH} ; fi ; \
if test -f Copying ; then cp Copying ${TEMPDIR}/${TREEPATH} ; fi ; \
if test -f Artistic ; then cp Artistic ${TEMPDIR}/${TREEPATH} ; fi ; \
if test -f *.c ; then cp *.c ${TEMPDIR}/${TREEPATH} ; fi ; \
rm -f ${ARCHIVEFILE}; \
tar -czf ${ARCHIVEFILE} -C ${TEMPDIR} ${TREEPATH}; \
ls -l ${ARCHIVEFILE}; \
find ${TEMPDIR} -delete; \
else \
echo "3rd party package should already be there"; \
if [ ! -e "${ARCHIVEFILE}" ] ; then \
$(error "Can't find 3rd party archive: ${ARCHIVEFILE} "); \
else \
echo "Found 3rd party ${ARCHIVEFILE}"; \
fi ; \
fi
exit 0