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}
13 echo "Usage: ${0##*/} [--changelog-rev <tree-ish>] [-t|--tag] [-u|--upload <location>] <version>"
18 printf 'error: %s\n' "$*"
22 ARGS=$(getopt -o htu: --long help,changelog-rev:,tag,upload: \
23 -n "${0##*/}" -- "$@")
24 [ $? != 0 ] && die "initialization error"
50 die "unknown option: $1"
55 [ $# != 1 ] && die "Need version argument"
56 [[ -n ${1/[0-9]*} ]] && die "Invalid version argument"
59 RELEASE=portage-${VERSION}
60 RELEASE_DIR=${RELEASE_BUILDDIR}/${RELEASE}
61 RELEASE_TARBALL="${RELEASE_BUILDDIR}/${RELEASE}.tar.bz2"
63 if [[ ${USE_TAG} == "true" ]] ; then
64 TREE_ISH="v${VERSION}"
67 echo ">>> Cleaning working directories ${RELEASE_DIR} ${SOURCE_DIR}"
68 rm -rf "${RELEASE_DIR}" "${SOURCE_DIR}" || die "directory cleanup failed"
69 mkdir -p "${RELEASE_DIR}" || die "directory creation failed"
70 mkdir -p "${SOURCE_DIR}" || die "mkdir failed"
72 echo ">>> Starting GIT archive"
73 git archive --format=tar ${TREE_ISH} | \
74 tar -xf - -C "${SOURCE_DIR}" || die "git archive failed"
76 echo ">>> Building release tree"
77 cp -a "${SOURCE_DIR}/"{bin,cnf,doc,man,misc,pym} "${RELEASE_DIR}/" || die "directory copy failed"
78 cp "${SOURCE_DIR}/"{DEVELOPING,LICENSE,Makefile,NEWS,README,RELEASE-NOTES,TEST-NOTES} \
79 "${RELEASE_DIR}/" || die "file copy failed"
81 rm -rf "${SOURCE_DIR}" || die "directory cleanup failed"
83 echo ">>> Setting portage.VERSION"
84 sed -e "s/^VERSION=.*/VERSION=\"${VERSION}\"/" \
85 -i "${RELEASE_DIR}/pym/portage/__init__.py" || \
86 die "Failed to patch portage.VERSION"
88 echo ">>> Creating Changelog"
90 if [[ -n ${CHANGELOG_REVISION} ]] ; then
91 git_log_opts+=" ${CHANGELOG_REVISION}^..${TREE_ISH}"
93 git_log_opts+=" ${TREE_ISH}"
96 git log ${git_log_opts} | fmt -w 80 -p " " | while read -r ; do
97 if [[ ${skip_next} == "true" ]] ; then
99 elif [[ ${REPLY} == " svn path="* ]] ; then
104 done > "${RELEASE_DIR}/ChangeLog" || die "ChangeLog creation failed"
106 cd "${RELEASE_BUILDDIR}"
108 echo ">>> Creating release tarball ${RELEASE_TARBALL}"
109 tar --owner portage --group portage -cjf "${RELEASE_TARBALL}" "${RELEASE}" || \
110 die "tarball creation failed"
112 DISTDIR=$(portageq distdir)
113 if [[ -n ${DISTDIR} && -d ${DISTDIR} && -w ${DISTDIR} ]] ; then
114 echo ">>> Copying release tarball into ${DISTDIR}"
115 cp "${RELEASE_TARBALL}" "${DISTDIR}"/ || echo "!!! tarball copy failed"
118 if [[ -n ${UPLOAD_LOCATION} ]] ; then
119 echo ">>> Uploading ${RELEASE_TARBALL} to ${UPLOAD_LOCATION}"
120 scp "${RELEASE_TARBALL}" "dev.gentoo.org:${UPLOAD_LOCATION}" || die "upload failed"
122 du -h "${RELEASE_TARBALL}"