Rev 1178 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/sh
#
# make a FreeBSD port of the project
#
PROJ=rebootd
OUTDIR=output
FREEBSDDIR=${OUTDIR}/freebsd-port
COMMITDIR=releases
WEBDIR=26th.net:www/26th.net/html/public/projects/rebootd/bin # scp format
VER_MAJOR=$1
VER_MINOR=$2
# check params
[ -n "${VER_MINOR}" ] || { echo "Version not specified" >> /dev/stderr; exit 1; }
# only commited revisions are allowed for release
CUR_REVISION=`svnversion .`
if ( ! echo ${CUR_REVISION} | grep -E '^[0-9]+$' > /dev/null ) ; then
echo "Cannot make release - current revision ${CUR_REVISION} not commited" >> /dev/stderr
#exit 1;
fi
# get last release version
VER_REVISION=`ls ${COMMITDIR}/${PROJ}-${VER_MAJOR}.${VER_MINOR}.*.tar.gz \
| awk ' BEGIN {rev=-1;}
{split($0,n,"-");split(n[2],nn,"\.");if(rev<nn[3])rev=nn[3];}
END {print rev;}'`
[ -n "${VER_REVISION}" -a "${VER_REVISION}" != "-1" ] \
|| { echo "Cannot determine release version" >> /dev/stderr; exit 1; }
RELEASE_NAME=${PROJ}-${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}
RELEASE_TAR=${RELEASE_NAME}.tar.gz
# create the tar
rm -rf ${FREEBSDDIR} \
|| { echo "Cannot delete ${FREEBSDDIR} dir" >> /dev/stderr; exit 2; }
mkdir ${FREEBSDDIR} \
|| { echo "Cannot create ${FREEBSDDIR} dir" >> /dev/stderr; exit 2; }
cp -r ports/freebsd ${FREEBSDDIR}/${PROJ} \
|| { echo "Cannot copy ports/freebsd to ${FREEBSDDIR}/${PROJ}" >> /dev/stderr; exit 2; }
sed -e "s/%VER_MAJOR%/${VER_MAJOR}/" -e "s/%VER_MINOR%/${VER_MINOR}/" \
-e "s/%VER_REVISION%/${VER_REVISION}/" ports/freebsd/Makefile \
> ${FREEBSDDIR}/${PROJ}/Makefile \
|| { echo "Cannot generate ${FREEBSDDIR}/${PROJ}/Makefile" >> /dev/stderr; exit 2; }
( cd ${COMMITDIR}; md5 ${RELEASE_TAR} ) > ${FREEBSDDIR}/${PROJ}/distinfo \
|| { echo "Cannot get MD5 of ${COMMITDIR}/${RELEASE_TAR}" >> /dev/stderr; exit 2; }
echo "SIZE (${RELEASE_TAR}) =" `stat -f '%z' ${COMMITDIR}/${RELEASE_TAR}` >> ${FREEBSDDIR}/${PROJ}/distinfo \
|| { echo "Cannot stat ${COMMITDIR}/${RELEASE_TAR}" >> /dev/stderr; exit 2; }
tar cf - --exclude '*/.svn' -C ${FREEBSDDIR} ${PROJ} | gzip > ${OUTDIR}/${PROJ}-freebsd-port.tar.gz \
|| { echo "Cannot create ${OUTDIR}/${PROJ}-freebsd-port.tar.gz" >> /dev/stderr; exit 2; }
rm -rf ${FREEBSDDIR} \
|| { echo "Cannot clear ${FREEBSDDIR} dir" >> /dev/stderr; exit 2; }
# commit the release
echo "Relase made successfully. Enter YES to commit it."
read confirm
if [ "$confirm" != "YES" ] ; then
echo "you have to answer 'YES' to continue"
exit 1
fi
cp ${OUTDIR}/${PROJ}-freebsd-port.tar.gz ${COMMITDIR} \
|| { echo "Cannot copy ${OUTDIR}/${PROJ}-freebsd-port.tar.gz to releases" >> /dev/stderr; exit 2; }
svn commit ${COMMITDIR}/${PROJ}-freebsd-port.tar.gz \
-m "${PROJ}: auto commit of FreeBSD port for release ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}" \
|| { echo "Cannot commit ${COMMITDIR}/${PROJ}-freebsd-port.tar.gz" >> /dev/stderr; exit 2; }
svn up \
|| { echo "Cannot update working copy" >> /dev/stderr; exit 2; }
# publish to web
scp ${COMMITDIR}/${PROJ}-freebsd-port.tar.gz ${WEBDIR} \
|| { echo "Cannot publish ${COMMITDIR}/${PROJ}-freebsd-port.tar.gz to ${WEBDIR}" >> /dev/stderr; \
exit 2; }
echo "FreeBSD port for relase ${RELEASE_NAME} is commited and published"