3 RELEASE_BUILDDIR=${RELEASE_BUILDDIR:-/var/tmp/portage-release}
4 SOURCE_DIR=${RELEASE_BUILDDIR}/checkout
5 BRANCH=${BRANCH:-master}
12 echo "Usage: ${0##*/} [--changelog-rev <tree-ish>] [-t|--tag] [-u|--upload <location>] <version>"
16 ARGS=$(getopt -o tu: --long changelog-rev:,tag,upload: \
18 [ $? != 0 ] && die "initialization error"
41 die "unknown option: $1"
46 [ -z "$1" ] && die "Need version argument"
47 [ -n "${1/[0-9]*}" ] && die "Invalid version argument"
50 RELEASE=portage-${VERSION}
51 RELEASE_DIR=${RELEASE_BUILDDIR}/${RELEASE}
52 RELEASE_TARBALL="${RELEASE_BUILDDIR}/${RELEASE}.tar.bz2"
54 if [[ $USE_TAG = true ]] ; then
58 echo ">>> Cleaning working directories ${RELEASE_DIR} ${SOURCE_DIR}"
59 rm -rf "${RELEASE_DIR}" "${SOURCE_DIR}" || die "directory cleanup failed"
60 mkdir -p "${RELEASE_DIR}" || die "directory creation failed"
61 mkdir -p "$SOURCE_DIR" || die "mkdir failed"
63 echo ">>> Starting GIT archive"
64 git archive --format=tar $TREE_ISH | \
65 tar -xf - -C "$SOURCE_DIR" || die "git archive failed"
67 echo ">>> Building release tree"
68 cp -a "${SOURCE_DIR}/"{bin,cnf,doc,man,pym} "${RELEASE_DIR}/" || die "directory copy failed"
69 cp "${SOURCE_DIR}/"{DEVELOPING,LICENSE,NEWS,RELEASE-NOTES,TEST-NOTES} \
70 "${RELEASE_DIR}/" || die "file copy failed"
72 rm -rf "$SOURCE_DIR" || die "directory cleanup failed"
74 echo ">>> Setting portage.VERSION"
75 sed -e "s/^VERSION=.*/VERSION=\"${VERSION}\"/" \
76 -i "${RELEASE_DIR}/pym/portage/__init__.py" || \
77 die "Failed to patch portage.VERSION"
79 echo ">>> Creating Changelog"
81 if [ -n "$CHANGELOG_REVISION" ] ; then
82 git_log_opts+=" $CHANGELOG_REVISION^..$TREE_ISH"
84 git_log_opts+=" $TREE_ISH"
87 git log $git_log_opts | fmt -w 80 -p " " | while read -r ; do
88 if [[ $skip_next = true ]] ; then
90 elif [[ $REPLY = " svn path="* ]] ; then
95 done > "$RELEASE_DIR/ChangeLog" || die "ChangeLog creation failed"
97 cd "${RELEASE_BUILDDIR}"
99 echo ">>> Creating release tarball ${RELEASE_TARBALL}"
100 tar --owner portage --group portage -cjf "${RELEASE_TARBALL}" "${RELEASE}" || \
101 die "tarball creation failed"
103 DISTDIR=$(portageq distdir)
104 if [ -n "${DISTDIR}" -a -d "${DISTDIR}" -a -w "${DISTDIR}" ]; then
105 echo ">>> Copying release tarball into ${DISTDIR}"
106 cp "${RELEASE_TARBALL}" "${DISTDIR}"/ || echo "!!! tarball copy failed"
109 if [ -n "${UPLOAD_LOCATION}" ]; then
110 echo ">>> Uploading ${RELEASE_TARBALL} to ${UPLOAD_LOCATION}"
111 scp "${RELEASE_TARBALL}" "dev.gentoo.org:${UPLOAD_LOCATION}" || die "upload failed"
113 echo "${RELEASE_TARBALL} created"