2 # Copyright 2008-2014 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
5 RELEASE_BUILDDIR=${RELEASE_BUILDDIR:-/var/tmp/portage-release}
6 SOURCE_DIR=${RELEASE_BUILDDIR}/checkout
7 BRANCH=${BRANCH:-master}
14 echo "Usage: ${0##*/} [--changelog-rev <tree-ish>] [-t|--tag] [-u|--upload <location>] [--runtests] <version>"
19 printf 'error: %s\n' "$*"
23 ARGS=$(getopt -o htu: --long help,changelog-rev:,runtests,tag,upload: \
24 -n "${0##*/}" -- "$@")
25 [ $? != 0 ] && die "initialization error"
55 die "unknown option: $1"
60 [ $# != 1 ] && die "Need version argument"
61 [[ -n ${1/[0-9]*} ]] && die "Invalid version argument"
64 RELEASE=portage-${VERSION}
65 RELEASE_DIR=${RELEASE_BUILDDIR}/${RELEASE}
66 RELEASE_TARBALL="${RELEASE_BUILDDIR}/${RELEASE}.tar.bz2"
68 if [[ ${USE_TAG} == "true" ]] ; then
69 TREE_ISH="v${VERSION}"
72 echo ">>> Cleaning working directories ${RELEASE_DIR} ${SOURCE_DIR}"
73 rm -rf "${RELEASE_DIR}" "${SOURCE_DIR}" || die "directory cleanup failed"
74 mkdir -p "${RELEASE_DIR}" || die "directory creation failed"
75 mkdir -p "${SOURCE_DIR}" || die "mkdir failed"
77 echo ">>> Starting GIT archive"
78 git archive --format=tar ${TREE_ISH} | \
79 tar -xf - -C "${SOURCE_DIR}" || die "git archive failed"
81 echo ">>> Building release tree"
82 cp -a "${SOURCE_DIR}/"{bin,cnf,doc,man,misc,pym} "${RELEASE_DIR}/" || die "directory copy failed"
83 cp "${SOURCE_DIR}/"{DEVELOPING,LICENSE,Makefile,NEWS,README,RELEASE-NOTES,TEST-NOTES} \
84 "${RELEASE_DIR}/" || die "file copy failed"
86 if [[ ${RUNTESTS} == "true" ]] ; then
87 pushd "${SOURCE_DIR}" >/dev/null
88 ./runtests.sh --python-versions=supported || die "tests failed"
92 rm -rf "${SOURCE_DIR}" || die "directory cleanup failed"
94 echo ">>> Setting portage.VERSION"
95 sed -e "s/^VERSION=.*/VERSION=\"${VERSION}\"/" \
96 -i "${RELEASE_DIR}/pym/portage/__init__.py" || \
97 die "Failed to patch portage.VERSION"
99 echo ">>> Creating Changelog"
101 if [[ -n ${CHANGELOG_REVISION} ]] ; then
102 git_log_opts+=" ${CHANGELOG_REVISION}^..${TREE_ISH}"
104 git_log_opts+=" ${TREE_ISH}"
107 git log ${git_log_opts} | fmt -w 80 -p " " | while read -r ; do
108 if [[ ${skip_next} == "true" ]] ; then
110 elif [[ ${REPLY} == " svn path="* ]] ; then
115 done > "${RELEASE_DIR}/ChangeLog" || die "ChangeLog creation failed"
117 cd "${RELEASE_BUILDDIR}"
119 echo ">>> Creating release tarball ${RELEASE_TARBALL}"
120 tar --owner portage --group portage -cjf "${RELEASE_TARBALL}" "${RELEASE}" || \
121 die "tarball creation failed"
123 DISTDIR=$(portageq distdir)
124 if [[ -n ${DISTDIR} && -d ${DISTDIR} && -w ${DISTDIR} ]] ; then
125 echo ">>> Copying release tarball into ${DISTDIR}"
126 cp "${RELEASE_TARBALL}" "${DISTDIR}"/ || echo "!!! tarball copy failed"
129 if [[ -n ${UPLOAD_LOCATION} ]] ; then
130 echo ">>> Uploading ${RELEASE_TARBALL} to ${UPLOAD_LOCATION}"
131 scp "${RELEASE_TARBALL}" "dev.gentoo.org:${UPLOAD_LOCATION}" || die "upload failed"
133 du -h "${RELEASE_TARBALL}"