You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
312 lines
8.2 KiB
312 lines
8.2 KiB
14 years ago
|
#!/bin/sh
|
||
|
#
|
||
12 years ago
|
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||
14 years ago
|
#
|
||
|
# This file is part of cdist.
|
||
|
#
|
||
|
# cdist is free software: you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation, either version 3 of the License, or
|
||
|
# (at your option) any later version.
|
||
|
#
|
||
|
# cdist is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||
|
#
|
||
|
#
|
||
12 years ago
|
# This file contains the heavy lifting found usually in the Makefile
|
||
14 years ago
|
#
|
||
14 years ago
|
|
||
12 years ago
|
basedir=${0%/*}
|
||
12 years ago
|
version=$(cd "$basedir" && git describe)
|
||
13 years ago
|
|
||
14 years ago
|
# Manpage and HTML
|
||
13 years ago
|
A2XM="a2x -f manpage --no-xmllint -a encoding=UTF-8"
|
||
13 years ago
|
A2XH="a2x -f xhtml --no-xmllint -a encoding=UTF-8"
|
||
14 years ago
|
|
||
14 years ago
|
# Developer webbase
|
||
12 years ago
|
WEBDIR=$HOME/www.nico.schottelius.org
|
||
12 years ago
|
WEBBLOG=$WEBDIR/blog
|
||
12 years ago
|
WEBTOPDIR=$WEBDIR/software
|
||
|
WEBBASE=$WEBTOPDIR/cdist
|
||
13 years ago
|
WEBMAN=$WEBBASE/man/$version
|
||
14 years ago
|
WEBPAGE=${WEBBASE}.mdwn
|
||
14 years ago
|
|
||
14 years ago
|
# Documentation
|
||
12 years ago
|
MANDIR=docs/man
|
||
14 years ago
|
MAN1DSTDIR=${MANDIR}/man1
|
||
|
MAN7DSTDIR=${MANDIR}/man7
|
||
12 years ago
|
SPEECHESDIR=docs/speeches
|
||
14 years ago
|
|
||
12 years ago
|
# Change to checkout directory
|
||
|
cd "$basedir"
|
||
|
|
||
14 years ago
|
case "$1" in
|
||
12 years ago
|
manbuild)
|
||
|
trap abort INT
|
||
|
abort() {
|
||
|
kill 0
|
||
|
}
|
||
|
for section in 1 7; do
|
||
|
for src in ${MANDIR}/man${section}/*.text; do
|
||
|
manpage="${src%.text}.$section"
|
||
|
if [ ! -f "$manpage" -o "$manpage" -ot "$src" ]; then
|
||
|
echo "Compiling man page for $src"
|
||
|
$A2XM "$src"
|
||
|
fi
|
||
|
htmlpage="${src%.text}.html"
|
||
|
if [ ! -f "$htmlpage" -o "$htmlpage" -ot "$src" ]; then
|
||
|
echo "Compiling html page for $src"
|
||
|
$A2XH "$src"
|
||
|
fi
|
||
|
done
|
||
|
done
|
||
12 years ago
|
;;
|
||
|
|
||
12 years ago
|
mantype)
|
||
12 years ago
|
for mansrc in cdist/conf/type/*/man.text; do
|
||
|
dst="$(echo $mansrc | sed -e 's;cdist/conf/;cdist-;' -e 's;/;;' -e 's;/man;;' -e 's;^;docs/man/man7/;')"
|
||
12 years ago
|
ln -sf "../../../$mansrc" "$dst"
|
||
|
done
|
||
|
;;
|
||
12 years ago
|
|
||
12 years ago
|
release-man)
|
||
12 years ago
|
version=$($0 changelog-version)
|
||
|
|
||
12 years ago
|
rm -rf "${WEBMAN}"
|
||
|
mkdir -p "${WEBMAN}/man1" "${WEBMAN}/man7"
|
||
|
cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${WEBMAN}/man1
|
||
|
cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${WEBMAN}/man7
|
||
12 years ago
|
cd ${WEBMAN} && git add . && git commit -m "Cdist Manpage update: $version"
|
||
12 years ago
|
;;
|
||
|
|
||
12 years ago
|
changelog-changes)
|
||
|
awk -F: 'BEGIN { start=0 } { if ($0 ~ /^[[:digit:]]/) { if(start == 0) {start = 1 } else { exit } } else { if(start==1) {print $0 }} }' "$basedir/docs/changelog"
|
||
12 years ago
|
;;
|
||
|
|
||
12 years ago
|
changelog-version)
|
||
|
# get version from changelog and ensure it's not already present
|
||
|
grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/:.*//'
|
||
|
;;
|
||
|
|
||
12 years ago
|
check-version)
|
||
12 years ago
|
changelog_version=$($0 changelog-version)
|
||
12 years ago
|
echo "Target version from changelog: $changelog_version"
|
||
12 years ago
|
|
||
|
if git show --quiet $changelog_version >/dev/null 2>&1; then
|
||
|
echo "Version $changelog_version already exists, aborting."
|
||
|
exit 1
|
||
|
fi
|
||
12 years ago
|
;;
|
||
12 years ago
|
|
||
12 years ago
|
check-date)
|
||
12 years ago
|
# verify date in changelog
|
||
|
date_today="$(date +%Y-%m-%d)"
|
||
|
date_changelog=$(grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/.*: //')
|
||
|
|
||
|
if [ "$date_today" != "$date_changelog" ]; then
|
||
|
echo "Date in changelog is not today"
|
||
|
echo "Changelog: $date_changelog"
|
||
|
exit 1
|
||
|
fi
|
||
12 years ago
|
;;
|
||
14 years ago
|
|
||
12 years ago
|
blog)
|
||
|
version=$($0 changelog-version)
|
||
|
blogfile=$WEBBLOG/cdist-${version}-released.mdwn
|
||
|
cat << eof > "$blogfile"
|
||
|
[[!meta title="Cdist $version released"]]
|
||
|
|
||
|
Here's a short overview about the changes found in this release:
|
||
|
|
||
|
eof
|
||
|
|
||
|
$0 changelog-changes >> "$blogfile"
|
||
|
|
||
|
cat << eof >> "$blogfile"
|
||
|
For more information visit the [[cdist homepage|software/cdist]].
|
||
|
|
||
|
[[!tag cdist config unix]]
|
||
|
eof
|
||
|
;;
|
||
|
|
||
12 years ago
|
release-blog)
|
||
12 years ago
|
version=$($0 changelog-version)
|
||
|
file=cdist-${version}-released.mdwn
|
||
12 years ago
|
cd "$WEBBLOG"
|
||
12 years ago
|
git add "$file"
|
||
|
git commit -m "New cdist version (blogentry): $version" "$file"
|
||
|
git push
|
||
|
;;
|
||
|
|
||
12 years ago
|
release-ml)
|
||
12 years ago
|
version=$($0 changelog-version)
|
||
|
to_a=cdist
|
||
|
to_d=l.schottelius.org
|
||
|
to=${to_a}@${to_d}
|
||
|
|
||
|
from_a=nico-cdist
|
||
|
from_d=schottelius.org
|
||
|
from=${from_a}@${from_d}
|
||
|
|
||
|
(
|
||
|
cat << eof
|
||
|
From: Nico -telmich- Schottelius <$from>
|
||
|
To: cdist mailing list <$to>
|
||
12 years ago
|
Subject: cdist $version released
|
||
12 years ago
|
|
||
|
Hello .*,
|
||
|
|
||
|
cdist $version has been released with the following changes:
|
||
|
|
||
|
eof
|
||
|
|
||
|
"$0" changelog-changes
|
||
|
cat << eof
|
||
|
|
||
|
Cheers,
|
||
|
|
||
|
Nico
|
||
|
|
||
|
--
|
||
|
Automatisation at its best level. With cdist.
|
||
|
eof
|
||
|
) | /usr/sbin/sendmail -f "$from" "$to"
|
||
|
;;
|
||
|
|
||
|
|
||
12 years ago
|
dist-tag)
|
||
|
version=$($0 changelog-version)
|
||
|
# add tag
|
||
|
printf "Enter tag description for %s> " "$version"
|
||
|
read tagmessage
|
||
|
git tag "$version" -m "$tagmessage"
|
||
|
;;
|
||
|
|
||
|
dist-branch-merge)
|
||
|
version=$($0 changelog-version)
|
||
|
target_branch=${version%\.*}
|
||
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||
12 years ago
|
|
||
12 years ago
|
if [ "$target_branch" = "$current_branch" ]; then
|
||
|
echo "Skipping merge, already on destination branch"
|
||
|
else
|
||
|
printf "Press enter to git merge $current_branch into \"$target_branch\" > "
|
||
|
read prompt
|
||
|
git checkout "$target_branch"
|
||
|
git merge "$current_branch"
|
||
|
git checkout "$current_branch"
|
||
|
fi
|
||
|
;;
|
||
12 years ago
|
|
||
12 years ago
|
release-freecode)
|
||
12 years ago
|
version=$($0 changelog-version)
|
||
|
api_token=$(awk '/machine freecode login/ { print $8 }' ~/.netrc)
|
||
|
|
||
|
printf "Enter tag list for freecode release %s> " "$version"
|
||
|
read taglist
|
||
|
|
||
|
printf "Enter changelog for freecode release %s> " "$version"
|
||
|
read changelog
|
||
|
|
||
|
echo "Submit preview"
|
||
|
cat << eof
|
||
|
tag_list = $taglist
|
||
|
changelog = $changelog
|
||
|
version = $version
|
||
|
eof
|
||
|
printf "Press enter to submit to freecode> "
|
||
|
read dummy
|
||
|
|
||
12 years ago
|
cat << eof | cfreecode-api release-add cdist
|
||
12 years ago
|
{
|
||
|
"auth_code": "$api_token",
|
||
|
"release": {
|
||
12 years ago
|
"tag_list": "$taglist",
|
||
12 years ago
|
"version": "$version",
|
||
12 years ago
|
"changelog": "$changelog",
|
||
12 years ago
|
"hidden_from_frontpage": false
|
||
|
}
|
||
|
}
|
||
|
eof
|
||
|
|
||
|
;;
|
||
|
|
||
12 years ago
|
dist-speeches)
|
||
12 years ago
|
cd "$SPEECHESDIR"
|
||
|
for speech in *tex; do
|
||
|
pdflatex "$speech"
|
||
|
pdflatex "$speech"
|
||
|
pdflatex "$speech"
|
||
13 years ago
|
done
|
||
12 years ago
|
;;
|
||
12 years ago
|
|
||
12 years ago
|
web-doc)
|
||
12 years ago
|
rsync -av "${basedir}/docs/web/" "${WEBTOPDIR}"
|
||
12 years ago
|
|
||
12 years ago
|
cd "${WEBDIR}" && git add "${WEBBASE}"
|
||
|
cd "${WEBDIR}" && git commit -m "cdist update" "${WEBBASE}" "${WEBPAGE}"
|
||
|
cd "${WEBDIR}" && make pub
|
||
12 years ago
|
;;
|
||
12 years ago
|
|
||
12 years ago
|
release-web)
|
||
12 years ago
|
set -e
|
||
12 years ago
|
# Fix ikiwiki, which does not like symlinks for pseudo security
|
||
|
ssh tee.schottelius.org \
|
||
|
"cd /home/services/www/nico/www.nico.schottelius.org/www/software/cdist/man &&
|
||
|
rm -f latest && ln -sf "$version" latest"
|
||
|
;;
|
||
|
|
||
12 years ago
|
pub)
|
||
12 years ago
|
for remote in "" github sf; do
|
||
12 years ago
|
echo "Pushing to $remote"
|
||
|
git push --mirror $remote
|
||
|
done
|
||
|
;;
|
||
|
|
||
12 years ago
|
clean)
|
||
|
rm -f ${MAN7DSTDIR}/cdist-reference.text
|
||
12 years ago
|
|
||
12 years ago
|
find "${MANDIR}" -mindepth 2 -type l \
|
||
|
-o -name "*.1" \
|
||
|
-o -name "*.7" \
|
||
|
-o -name "*.html" \
|
||
|
-o -name "*.xml" \
|
||
|
| xargs rm -f
|
||
|
|
||
|
find * -name __pycache__ | xargs rm -rf
|
||
|
;;
|
||
12 years ago
|
distclean)
|
||
12 years ago
|
rm -f cdist/version.py MANIFEST PKGBUILD
|
||
12 years ago
|
rm -rf cache/ dist/
|
||
12 years ago
|
|
||
|
# Archlinux
|
||
|
rm -f cdist-*.pkg.tar.xz cdist-*.tar.gz
|
||
|
rm -rf pkg/ src/
|
||
12 years ago
|
;;
|
||
|
|
||
12 years ago
|
test)
|
||
|
shift # skip t
|
||
12 years ago
|
export PYTHONPATH="$(pwd -P)"
|
||
12 years ago
|
|
||
|
if [ $# -lt 1 ]; then
|
||
|
python3 -m cdist.test
|
||
|
else
|
||
|
python3 -m unittest "$@"
|
||
|
fi
|
||
12 years ago
|
;;
|
||
12 years ago
|
version)
|
||
12 years ago
|
echo "VERSION = \"$(git describe)\"" > cdist/version.py
|
||
12 years ago
|
;;
|
||
14 years ago
|
|
||
12 years ago
|
*)
|
||
12 years ago
|
echo "Unknown target $@ - aborting"
|
||
12 years ago
|
exit 1
|
||
|
;;
|
||
13 years ago
|
|
||
14 years ago
|
esac
|