Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
First cut at automating the tag-and-release process.
Matthew Seaman committed 13 years ago
commit 5ba53b810f35e897f3b71ac0d0e0d83dc880858c
parent efd4ae6
5 files changed +207 -5
modified Makefile
@@ -1,9 +1,75 @@
+

SUBDIR=	external \
	libpkg \
	pkg

+
SUBDIR_TARGETS=	set-version
+

+
NEWVERS=	newvers.sh
+

.if !defined(NOSTATIC)
SUBDIR+=	pkg-static
.endif

+
PKGVERSION!=    sh ${NEWVERS} pkg
+

+
# All the files modified by changing version strings.  Changes to
+
# these files will be commited to git unconditionally as part of the
+
# 'release' target.
+

+
VERSIONED_FILES=	Doxyfile libpkg/pkg.h ${NEWVERS}
+

+
# Set CREATE_SNAPSHOT=yes to create a snapshot, which will update
+
# Doxyfile, libpkg/pkg.h etc. but not newvers.sh.  To clear the
+
# snapshot, either update ${NEWVERS} or set CREATE_SNAPSHOT=no
+

+
.if defined(CREATE_SNAPSHOT)
+
_snapshot=	snapshot
+

+
${_snapshot}:
+
.endif
+

+
TARBALL_BASENAME=	pkg-${PKGVERSION}
+
TARBALL_EXT=		tar.xz
+
TARBALL_FILE=		${TARBALL_BASENAME}.${TARBALL_EXT}
+

+
.PHONY: release do-release set-tag make-tarball regression-test \
+
	set-version do-set-version ${_snapshot} 
+

+
all:	set-version
+

+
do-set-version:
+
	@${ECHO} "==> Update version strings (${PKGVERSION})" 
+

+
set-version: do-set-version Doxyfile
+

+
regression-test: all
+
	@${ECHO} "==> Regression Test"
+

+
do-release: regression-test
+
	@${ECHO} "==> Create New Release (${PKGVERSION})"
+

+
release: do-release set-tag make-tarball
+

+
set-tag:
+
	if git tag -l | grep -F ${PKGVERSION} ; then \
+
	    ${ECHO} "---> Error: tag ${PKGVERSION} already exists" ; \
+
	    ${ECHO} "---> Either delete the tag (git tag -d ${PKGVERSION})" ; \
+
	    ${ECHO} "---> (but only if you haven't pushed yet) or edit" ; \
+
	    ${ECHO} "---> ${NEWVERS} to set the new release version" ; \
+
	    false ; \
+
	fi
+
	git commit -m "New Release ${PKGVERSION}" ${VERSIONED_FILES}
+
	git tag -m "New Release ${PKGVERSION}" ${PKGVERSION}
+

+

+
# Note: you will need to update ~/.gitconfig so git understands tar.xz
+
# as a format
+
make-tarball:
+
	git archive --format=${TARBALL_EXT} --prefix=${TARBALL_BASENAME}/ \
+
	    -o ${TARBALL_FILE} ${PKGVERSION}
+

+
Doxyfile: ${NEWVERS} ${_snapshot}
+
	sed -e "/^PROJECT_NUMBER/s,= .*,= ${PKGVERSION}," -i '' ${.TARGET}
+

.include <bsd.subdir.mk>
modified external/Makefile
@@ -5,4 +5,8 @@ SUBDIR= sqlite \
SUBDIR+= libelf
.endif

+
.PHONY: set-version
+

+
set-version:
+

.include <bsd.subdir.mk>
modified libpkg/Makefile
@@ -39,13 +39,23 @@ SRCS= backup.c \
PC=	pkg.pc
CLEANFILES=	${PC}

+
NEWVERS=	../newvers.sh
+

+
PKGVERSION!=	sh ${NEWVERS} pkg
+
PORTVERSION!=	sh ${NEWVERS} port
+

+
.if defined(CREATE_SNAPSHOT)
+
_snapshot=	snapshot
+

+
${_snapshot}:
+
.endif
+

all: ${PC}

realinstall: ${PC}
	${INSTALL} -m 644 ${PC} ${PREFIX}/libdata/pkgconfig

HAVE_GRUTILS!=	grep -q gr_copy /usr/include/libutil.h && echo yes || echo no
-
VERSION!=	awk '$$2 == "PKGVERSION" { print $$3 }' pkg.h

.if ${HAVE_GRUTILS} != yes
SRCS+=	gr_util.c
@@ -98,8 +108,16 @@ NOMAN= yes

.SUFFIXES: .pc.in .pc

-
.pc.in.pc:
+
.PHONY:	set-version ${_snapshot}
+

+
set-version: pkg.h ${PC}
+

+
pkg.h:	${NEWVERS} ${_snapshot}
+
	sed -e "/^#define PKGVERSION/s,\".*\",\"$(PKGVERSION)\","       \
+
	    -e "/^#define PKG_PORTVERSION/s,\".*\",\"$(PORTVERSION)\"," \
+
	    -i '' $(.TARGET) 
+

+
.pc.in.pc: ${NEWVERS} ${_snapshot}
	sed -e "s,__PREFIX__,${PREFIX},g" \
-
		-e "s,__VERSION__,${VERSION},g" \
+
		-e "s,__VERSION__,${PKGVERSION},g" \
		${.IMPSRC} > ${.TARGET}
-

added newvers.sh
@@ -0,0 +1,113 @@
+
#!/bin/sh -
+
# Copyright (c) 2012 Matthew Seaman <matthew@freebsd.org>
+
# All rights reserved.
+
# 
+
# Redistribution and use in source and binary forms, with or without
+
# modification, are permitted provided that the following conditions
+
# are met:
+
# 1. Redistributions of source code must retain the above copyright
+
#    notice, this list of conditions and the following disclaimer
+
#    in this position and unchanged.
+
# 2. Redistributions in binary form must reproduce the above copyright
+
#    notice, this list of conditions and the following disclaimer in the
+
#    documentation and/or other materials provided with the distribution.
+
# 
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+
# IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+

+
# This file contains the authoritative version number for the last
+
# release from this branch, and for the corresponding port..  The
+
# version number is edited into ../Doxyfile and pkg.h.
+

+
# ------------------------------------------------------------------
+

+
# The version of the pkgng software itself. See
+
# http://wiki.freebsd.org/pkgng/CharterAndRoadMap#Code_Releases for
+
# details.  Setting PKG_PATCH_LEVEL to 0 is special
+
#
+
# For testing purposes you can override these by setting any of the
+
# variables or PKGVERSION or PORTVERSION in the environment, but this
+
# should not be done routinely:
+

+
: ${PKG_MAJOR_VERSION:="1"}
+
: ${PKG_MINOR_VERSION="1"}
+
: ${PKG_PATCH_LEVEL="a1"}
+
 
+
: ${PORTREVISION:=}
+
: ${PORTEPOCH:=}
+

+
# Define this to a true value if creating a snapshot
+
: ${CREATE_SNAPSHOT:="NO"}
+

+
# ------------------------------------------------------------------
+

+
case $PKG_PATCH_LEVEL in
+
    ''|0)
+
	_patch=
+
	;;
+
    *)
+
	_patch=".${PKG_PATCH_LEVEL}"
+
	;;
+
esac
+

+
case $CREATE_SNAPSHOT in
+
    [yY][eE][sS])
+
	_snapshot=".$( date +%Y%m%d )"
+
	;;
+
    *)
+
	_snapshot=
+
	;;
+
esac
+

+
case $PORTREVISION in
+
     ''|0)
+
	 _portrevision=
+
	 ;;
+
     *)
+
	 _portrevision="_${PORTREVISION}"
+
	 ;;
+
esac
+

+
case $PORTEPOCH in
+
    ''|0)
+
	_portepoch=
+
	;;
+
    *)
+
	_portepoch=";${PORTEPOCH}"
+
	;;
+
esac
+

+
_pkgversion=${PKG_MAJOR_VERSION}.${PKG_MINOR_VERSION}${_patch}${_snapshot}
+
_portversion=${_pkgversion}${_portrevision}${_portepoch}
+

+
: ${PKGVERSION:=${_pkgversion}}
+
: ${PORTVERSION:=${_portversion}}
+

+

+
# Printout the result according to command line args
+
case $1 in
+
    pkg)
+
	echo $PKGVERSION
+
	;;
+
    port)
+
	echo $PORTVERSION
+
	;;
+
    *)
+
        # Print the results in a form suitable for eval by /bin/sh
+
	echo "PKGVERSION=\"$PKGVERSION\""
+
	echo "PORTVERSION=\"$PORTVERSION\""
+
	;;
+
esac
+

+
#
+
# That's All Folks!
+
#
+

modified pkg/Makefile
@@ -92,10 +92,11 @@ MLINKS= pkg-delete.8 pkg-remove.8 \
	pkg-lock.8 pkg-unlock.8 \
	pkg.8 pkg-static.8

-
.PHONY: fix-xrefs
+
.PHONY: fix-xrefs set-version

fix-xrefs:
	@./fix-xrefs ${MAN}

+
set-version:

.include <bsd.prog.mk>