1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
#!/bin/sh
ORIGIN_URL=$(git config --get remote.origin.url)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
PACKAGE='@PACKAGE@'
PACKAGE_VERSION='@PACKAGE_VERSION@'
abs_srcdir='@abs_srcdir@'
srcdir='@srcdir@'
abs_top_builddir='@abs_top_builddir@'
dist_man_MANS='lsrc.1 mkrc.1 rcdn.1 rcup.1 rcrc.5 rcm.7'
edit_package() {
sed \
-e "s|@PACKAGE[@]|$PACKAGE|g" \
-e "s|@PACKAGE_VERSION[@]|$PACKAGE_VERSION|g" \
-e "s|@DIST_ARCHIVES[@]|$DIST_ARCHIVES|g" \
-e "s|@DIST_SHA[@]|$DIST_SHA|g" \
"$1"
}
# Tarball
release_build_tarball() {
([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \
([ -d gh-pages/dist ] || mkdir gh-pages/dist) && \
cp $DIST_ARCHIVES gh-pages/dist && \
cd gh-pages && \
git add dist/$DIST_ARCHIVES && \
git commit -m "Release version $PACKAGE_VERSION tarball"
}
release_push_tarball() {
cd gh-pages && \
git push
}
release_clean_tarball() {
rm -rf gh-pages
rm -rf $DIST_ARCHIVES
}
# Arch
release_build_arch() {
([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \
([ -d gh-pages/arch ] || mkdir gh-pages/arch) && \
generate_dist_sha && \
edit_package arch/PKGBUILD.in > gh-pages/arch/PKGBUILD &&\
cd gh-pages &&\
git add arch/PKGBUILD &&\
git commit -m "Release version $PACKAGE_VERSION Arch package"
}
release_push_arch() {
cd gh-pages && \
git push
}
release_clean_arch() {
rm -rf gh-pages
rm -rf $DIST_ARCHIVES
}
# Deb
release_build_deb() {
mkdir deb-build && \
cp ${DIST_ARCHIVES} deb-build/${PACKAGE}_${PACKAGE_VERSION}.orig.tar.gz && \
tar -C deb-build -xf deb-build/${PACKAGE}_${PACKAGE_VERSION}.orig.tar.gz && \
cp -R debian deb-build/${PACKAGE}-${PACKAGE_VERSION} && \
cd deb-build/${PACKAGE}-${PACKAGE_VERSION} && \
dch -d "New upstream release" && dch -r "" && \
debuild --prepend-path=/usr/local/bin -F && \
cd ${abs_top_builddir} && \
([ -d gh-pages ] || git clone --branch gh-pages ${ORIGIN_URL} gh-pages) && \
mkdir gh-pages/debs && \
mkdir gh-pages/deb-src && \
cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.deb gh-pages/debs && \
cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.dsc gh-pages/deb-src && \
cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.orig.tar.?z gh-pages/deb-src && \
cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.debian.tar.?z gh-pages/deb-src && \
cd gh-pages && \
git add debs/${PACKAGE}_${PACKAGE_VERSION}*deb && \
git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*dsc && \
git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*orig.tar.?z && \
git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*debian.tar.?z && \
git commit -m "Release version ${PACKAGE_VERSION} for Debian" -- debs/${PACKAGE}_${PACKAGE_VERSION}*deb
}
release_push_deb() {
cd gh-pages && \
git push
}
release_clean_deb() {
rm -rf gh-pages
rm -rf deb-build
rm -rf $DIST_ARCHIVES
}
# Tag
release_build_tag() {
git tag -s v$PACKAGE_VERSION -m "Release $PACKAGE_VERSION"
}
release_push_tag() {
git push origin --tags
}
release_clean_tag() {
:
}
generate_dist_sha() {
export DIST_SHA=$(openssl sha256 $srcdir/$DIST_ARCHIVES | cut -d' ' -f2)
}
# manpages as HTML
release_build_man_html() {
([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \
for i in $dist_man_MANS; do \
mandoc -Thtml -Oman=%N.%S.html man/$i > $abs_top_builddir/gh-pages/$i.html ; \
done && \
cd $abs_top_builddir/gh-pages && \
cp rcm.7.html index.html && \
git add -A && \
git commit -m "HTML documentation for $PACKAGE_VERSION"
}
release_push_man_html() {
cd $abs_top_builddir/gh-pages && \
git push -f $ORIGIN_URL gh-pages
}
release_clean_man_html() {
rm -rf $abs_top_builddir/gh-pages
}
# Main:
if [ $# -lt 3 ]; then
echo "Usage: release (build|push|clean) (tarball|arch|deb|tag|man_html) DIST_ARCHIVES" >&2
exit 64
fi
verb="$1"
noun="$2"
DIST_ARCHIVES="$3"
cmd="release_${verb}_${noun}"
${cmd}
|