Subversion Repositories general

Rev

Rev 1178 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1178 dev 1
#!/bin/sh
2
 
3
#
4
# make a FreeBSD port of the project
5
#
6
 
7
PROJ=rebootd
8
 
9
OUTDIR=output
10
FREEBSDDIR=${OUTDIR}/freebsd-port
11
COMMITDIR=releases
12
WEBDIR=26th.net:www/26th.net/html/public/projects/rebootd/bin    # scp format
13
 
1181 dev 14
VER_MAJOR=$1
15
VER_MINOR=$2
16
 
17
# check params
18
[ -n "${VER_MINOR}" ] || { echo "Version not specified" >> /dev/stderr; exit 1; }
19
 
1178 dev 20
# only commited revisions are allowed for release
21
CUR_REVISION=`svnversion .`
22
if ( ! echo ${CUR_REVISION} | grep -E '^[0-9]+$' > /dev/null ) ; then
23
	echo "Cannot make release - current revision ${CUR_REVISION} not commited" >> /dev/stderr
24
	#exit 1;
25
fi
26
 
27
# get last release version
1181 dev 28
VER_REVISION=`ls ${COMMITDIR}/${PROJ}-${VER_MAJOR}.${VER_MINOR}.*.tar.gz \
29
	| awk ' BEGIN {rev=-1;}
30
		{split($0,n,"-");split(n[2],nn,"\.");if(rev<nn[3])rev=nn[3];}
31
		END {print rev;}'`
32
[ -n "${VER_REVISION}" -a "${VER_REVISION}" != "-1" ] \
33
	|| { echo "Cannot determine release version" >> /dev/stderr; exit 1; }
1178 dev 34
 
35
RELEASE_NAME=${PROJ}-${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}
36
RELEASE_TAR=${RELEASE_NAME}.tar.gz
37
 
38
# create the tar
39
rm -rf ${FREEBSDDIR} \
40
	|| { echo "Cannot delete ${FREEBSDDIR} dir" >> /dev/stderr; exit 2; }
41
mkdir ${FREEBSDDIR} \
42
	|| { echo "Cannot create ${FREEBSDDIR} dir" >> /dev/stderr; exit 2; }
43
cp -r ports/freebsd ${FREEBSDDIR}/${PROJ} \
44
	|| { echo "Cannot copy ports/freebsd to ${FREEBSDDIR}/${PROJ}" >> /dev/stderr; exit 2; }
1181 dev 45
sed -e "s/%VER_MAJOR%/${VER_MAJOR}/" -e "s/%VER_MINOR%/${VER_MINOR}/" \
46
	-e "s/%VER_REVISION%/${VER_REVISION}/" ports/freebsd/Makefile \
1178 dev 47
	> ${FREEBSDDIR}/${PROJ}/Makefile \
48
	|| { echo "Cannot generate ${FREEBSDDIR}/${PROJ}/Makefile" >> /dev/stderr; exit 2; }
49
( cd ${COMMITDIR}; md5 ${RELEASE_TAR} ) > ${FREEBSDDIR}/${PROJ}/distinfo \
50
	|| { echo "Cannot get MD5 of ${COMMITDIR}/${RELEASE_TAR}" >> /dev/stderr; exit 2; }
51
echo "SIZE (${RELEASE_TAR}) =" `stat -f '%z' ${COMMITDIR}/${RELEASE_TAR}` >> ${FREEBSDDIR}/${PROJ}/distinfo \
52
	|| { echo "Cannot stat ${COMMITDIR}/${RELEASE_TAR}" >> /dev/stderr; exit 2; }
53
tar cf - --exclude '*/.svn' -C ${FREEBSDDIR} ${PROJ} | gzip > ${OUTDIR}/${PROJ}-freebsd-port.tar.gz \
54
	|| { echo "Cannot create ${OUTDIR}/${PROJ}-freebsd-port.tar.gz" >> /dev/stderr; exit 2; }
55
rm -rf ${FREEBSDDIR} \
56
	|| { echo "Cannot clear ${FREEBSDDIR} dir" >> /dev/stderr; exit 2; }
57
 
58
# commit the release
59
echo "Relase made successfully. Enter YES to commit it."
60
read confirm
61
if [ "$confirm" != "YES" ] ; then
62
	echo "you have to answer 'YES' to continue"
63
	exit 1
64
fi
65
 
66
cp ${OUTDIR}/${PROJ}-freebsd-port.tar.gz ${COMMITDIR} \
67
	|| { echo "Cannot copy ${OUTDIR}/${PROJ}-freebsd-port.tar.gz to releases" >> /dev/stderr; exit 2; }
68
svn commit ${COMMITDIR}/${PROJ}-freebsd-port.tar.gz \
69
	-m "${PROJ}: auto commit of FreeBSD port for release ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}" \
70
	|| { echo "Cannot commit ${COMMITDIR}/${PROJ}-freebsd-port.tar.gz" >> /dev/stderr; exit 2; }
71
svn up \
72
	|| { echo "Cannot update working copy" >> /dev/stderr; exit 2; }
73
 
74
# publish to web
75
scp ${COMMITDIR}/${PROJ}-freebsd-port.tar.gz ${WEBDIR} \
76
	|| { echo "Cannot publish ${COMMITDIR}/${PROJ}-freebsd-port.tar.gz to ${WEBDIR}" >> /dev/stderr; \
77
		exit 2; }
78
 
79
echo "FreeBSD port for relase ${RELEASE_NAME} is commited and published"
80