Commit 97113a13 authored by Allan Blanchard's avatar Allan Blanchard

[Release] Changes website target

parent 743001d2
......@@ -5,14 +5,14 @@ set -u
# Executing this script requires bash 4.0 or higher
# (special use of the 'case' construct)
if test `echo $BASH_VERSION | sed "s/\([0-9]\).*/\1/" ` -lt 4; then
echo "bash version >= 4 is required."
exit 99
echo "bash version >= 4 is required."
exit 99
fi
# git-lfs needs to be installed
if ! command -v git-lfs >/dev/null 2>/dev/null; then
echo "git-lfs is required"
exit 99
echo "git-lfs is required"
exit 99
fi
# Set it to "no" in order to really execute the commands.
......@@ -37,6 +37,8 @@ FRAMAC_VERSION_AND_CODENAME="${FRAMAC_VERSION}-${FRAMAC_VERSION_CODENAME}"
TARGZ_FILENAME=frama-c-${FRAMAC_VERSION_AND_CODENAME}.tar.gz
VERSION_MODIFIER=$(cat VERSION | sed -e s/[0-9.]*\\\(.*\\\)/\\1/)
VERSION_MAJOR=$(cat VERSION | sed -e s/\\\([0-9]*\\\).[0-9]*.*/\\1/)
VERSION_MINOR=$(cat VERSION | sed -e s/[0-9]*.\\\([0-9]*\\\).*/\\1/)
if test -n "$VERSION_MODIFIER"; then FINAL_RELEASE=no; else FINAL_RELEASE=yes; fi
......@@ -47,35 +49,36 @@ if test "$FRAMAC_VERSION" != "$FRAMAC_TAG"; then
fi
run () {
cmd=$1
echo "$cmd"
if test "$DEBUG" == "no"; then
sh -c "$cmd" || { echo "Aborting step ${STEP}."; exit "${STEP}"; }
fi
cmd=$1
echo "$cmd"
if test "$DEBUG" == "no"; then
sh -c "$cmd" || { echo "Aborting step ${STEP}."; exit "${STEP}"; }
fi
}
GITLAB_DIR=./pub-frama-c
GITLAB_GIT="git@git.frama-c.com:pub/frama-c.git"
# GITLAB_DIR=./pub-frama-c
# GITLAB_GIT="git@git.frama-c.com:pub/frama-c.git"
# if test ! -d $GITLAB_DIR/.git; then
# echo "WARNING: $GITLAB_DIR/.git directory not found; do you want to clone it? (y/n)"
# read CHOICE
# case "${CHOICE}" in
# "Y"|"y")
# run "git clone $GITLAB_GIT $GITLAB_DIR"
# ;;
# *)
# echo "gitlab's public Frama-C project must be linked at $GITLAB_DIR \
# (clone or symbolic link)"
# exit 1
# ;&
# esac
# fi
# GITLAB_BRANCH=$(git --git-dir=$GITLAB_DIR/.git rev-parse --abbrev-ref HEAD)
# if test "$FRAMAC_BRANCH" != "$GITLAB_BRANCH"; then
# echo "WARNING: switching pub-frama-c to current branch $FRAMAC_BRANCH"
# run "git -C $GITLAB_DIR checkout -b $FRAMAC_BRANCH"
# fi
if test ! -d $GITLAB_DIR/.git; then
echo "WARNING: $GITLAB_DIR/.git directory not found; do you want to clone it? (y/n)"
read CHOICE
case "${CHOICE}" in
"Y"|"y")
run "git clone $GITLAB_GIT $GITLAB_DIR"
;;
*)
echo "gitlab's public Frama-C project must be linked at $GITLAB_DIR \
(clone or symbolic link)"
exit 1
;&
esac
fi
GITLAB_BRANCH=$(git --git-dir=$GITLAB_DIR/.git rev-parse --abbrev-ref HEAD)
if test "$FRAMAC_BRANCH" != "$GITLAB_BRANCH"; then
echo "WARNING: switching pub-frama-c to current branch $FRAMAC_BRANCH"
run "git -C $GITLAB_DIR checkout -b $FRAMAC_BRANCH"
fi
GITLAB_WIKI_GIT="git@git.frama-c.com:pub/frama-c.wiki"
GITLAB_WIKI=./frama-c.wiki
if test ! -d $GITLAB_WIKI/.git; then
......@@ -121,14 +124,23 @@ fi
MANUALS_DIR="./doc/manuals"
# push on frama-c.com only for final releases
WEBSITE_GIT="git@git.frama-c.com:pub/pub.frama-c.com.git"
if test "$FINAL_RELEASE" = "yes"; then
WEBSITE_DIR="./website"
if test \! -d $WEBSITE_DIR/.git ; then
echo "ERROR: $WEBSITE_DIR/.git directory not found"
echo "The Frama-C website repository must be linked at $WEBSITE_DIR (clone or symbolic link)"
exit 1
fi
WEBSITE_BRANCH=`git --git-dir=$WEBSITE_DIR/.git rev-parse --abbrev-ref HEAD`
WEBSITE_DIR="./website"
if test \! -d $WEBSITE_DIR/.git ; then
echo "ERROR: $WEBSITE_DIR/.git directory not found; do you want to clone it? (y/n)"
read CHOICE
case "${CHOICE}" in
"Y"|"y")
run "git clone $WEBSITE_GIT website"
;;
*)
echo "The Github Website repository must be linked at $WEBSITE_DIR (clone or symbolic link)"
exit 1
;&
esac
fi
WEBSITE_BRANCH=`git --git-dir=$WEBSITE_DIR/.git rev-parse --abbrev-ref HEAD`
fi # FINAL_RELEASE == yes
BUILD_DIR_ROOT="/tmp/release"
......@@ -137,24 +149,24 @@ BUILD_DIR="$BUILD_DIR_ROOT/frama-c"
echo "Frama-C Version : $FRAMAC_VERSION"
echo "Frama-C Branch : $FRAMAC_BRANCH"
echo "Final release : $FINAL_RELEASE"
echo "pub/frama-c dir : $GITLAB_DIR"
echo "pub/frama-c branch : $GITLAB_BRANCH"
# echo "pub/frama-c dir : $GITLAB_DIR"
# echo "pub/frama-c branch : $GITLAB_BRANCH"
echo "pub/frama-c wiki : $GITLAB_WIKI"
echo "Manuals Dir : $MANUALS_DIR"
if test "$FINAL_RELEASE" = "yes"; then
echo "Website Dir : $WEBSITE_DIR"
echo "Website Branch : $WEBSITE_BRANCH"
echo "Website Dir : $WEBSITE_DIR"
echo "Website Branch : $WEBSITE_BRANCH"
else
echo "Intermediate release: website not updated"
echo "Intermediate release: website not updated"
fi
echo "Build Dir : $BUILD_DIR"
DOWNLOAD_DIR="www/download"
DOWNLOAD_DIR="download"
step () {
STEP=$1
echo
echo "Step $1: $2"
STEP=$1
echo
echo "Step $1: $2"
}
export LC_CTYPE=en_US.UTF-8
......@@ -174,157 +186,161 @@ Start at which step? (default is N, which cancels everything)
read STEP
case "${STEP}" in
""|"N")
echo "Exiting without doing anything.";
exit 0;
;&
0)
step 0 "COMPILING PDF MANUALS"
run "rm -rf $MANUALS_DIR"
run "mkdir -p $MANUALS_DIR"
run "doc/build-manuals.sh"
;&
1)
run "git -C $GITLAB_DIR reset --hard"
run "git -C $GITLAB_WIKI reset --hard"
if test "$FINAL_RELEASE" = "yes"; then
run "git -C $WEBSITE_DIR reset --hard"
fi
;&
2)
step 2 "BUILDING THE SOURCE DISTRIBUTION"
# WARNING! MUST RUN git update-index BEFORE git diff-index!
# See: https://stackoverflow.com/questions/36367190/git-diff-files-output-changes-after-git-status
run "git update-index --refresh"
if ! git diff-index HEAD --; then
echo ""
echo "### WARNING: uncommitted git changes will be discarded when creating archive!"
echo "Proceed anyway? [y/N]"
read CHOICE
case "${CHOICE}" in
"Y"|"y")
""|"N")
echo "Exiting without doing anything.";
exit 0;
;&
0)
step 0 "COMPILING PDF MANUALS"
run "rm -rf $MANUALS_DIR"
run "mkdir -p $MANUALS_DIR"
run "doc/build-manuals.sh"
;&
1)
# run "git -C $GITLAB_DIR reset --hard"
run "git -C $GITLAB_WIKI reset --hard"
if test "$FINAL_RELEASE" = "yes"; then
run "git -C $WEBSITE_DIR reset --hard"
fi
;&
2)
step 2 "BUILDING THE SOURCE DISTRIBUTION"
# WARNING! MUST RUN git update-index BEFORE git diff-index!
# See: https://stackoverflow.com/questions/36367190/git-diff-files-output-changes-after-git-status
run "git update-index --refresh"
if ! git diff-index HEAD --; then
echo ""
echo "### WARNING: uncommitted git changes will be discarded when creating archive!"
echo "Proceed anyway? [y/N]"
read CHOICE
case "${CHOICE}" in
"Y"|"y")
;;
*)
echo "Stash or commit local changes, then run the script again."
exit 1
esac
fi
run "mkdir -p $BUILD_DIR_ROOT"
run "rm -rf $BUILD_DIR"
run "git worktree add -f --detach $BUILD_DIR $FRAMAC_BRANCH"
run "cd $BUILD_DIR; autoconf"
run "cd $BUILD_DIR; ./configure"
run "cd $BUILD_DIR; make -j OPEN_SOURCE=yes src-distrib"
# sanity check: markdown-report must be distributed
run "tar tf $BUILD_DIR/$TARGZ_FILENAME | grep -q src/plugins/markdown-report"
# populate release assets in wiki
run "mkdir -p $GITLAB_WIKI/downloads"
run "cp $BUILD_DIR/$TARGZ_FILENAME $GITLAB_WIKI/downloads/"
if test "$FINAL_RELEASE" = "yes"; then
SPEC_FILE="$DOWNLOAD_DIR/$TARGZ_FILENAME"
run "rm -f $WEBSITE_DIR/$SPEC_FILE"
run "cp $BUILD_DIR/$TARGZ_FILENAME $WEBSITE_DIR/$SPEC_FILE"
run "git -C $WEBSITE_DIR add $SPEC_FILE"
run "cp Changelog $WEBSITE_DIR/src/last-release/Changelog"
run "cp src/plugins/wp/Changelog $WEBSITE_DIR/src/wpChangelog"
run "cp src/plugins/wp/Changelog $WEBSITE_DIR/src/last-release/wpChangelog"
run "cp src/plugins/e-acsl/doc/Changelog $WEBSITE_DIR/src/eacslChangelog"
run "cp src/plugins/e-acsl/doc/Changelog $WEBSITE_DIR/src/last-release/eacslChangelog"
fi
;&
3)
#note: this step may fail if step 4 was performed,
# because it will erase BUILD_DIR
step 3 "BUILDING THE API BUNDLE"
if test \! -d "$BUILD_DIR" ; then
echo "ERROR: $BUILD_DIR does not exist, possibly removed by another step"
exit 1
fi
run "cd $BUILD_DIR; make -j doc-distrib"
if test "$FINAL_RELEASE" = "yes"; then
SPEC_FILE="$DOWNLOAD_DIR/frama-c-${FRAMAC_VERSION_AND_CODENAME}-api.tar.gz"
run "rm -f $WEBSITE_DIR/$SPEC_FILE"
run "cp $BUILD_DIR/frama-c-api.tar.gz $WEBSITE_DIR/$SPEC_FILE"
run "git -C $WEBSITE_DIR add $SPEC_FILE"
fi
;&
4)
step 4 "BUILDING THE DOCUMENTATION COMPANIONS"
if test \! -d "$BUILD_DIR" ; then
echo "ERROR: $BUILD_DIR does not exist, possibly removed by another step"
exit 1
fi
run "cd $BUILD_DIR; make -j doc-companions"
if test "$FINAL_RELEASE" = "yes"; then
SPEC_FILE="$DOWNLOAD_DIR/hello-${FRAMAC_VERSION_AND_CODENAME}.tar.gz"
RELE_FILE="$DOWNLOAD_DIR/hello.tar.gz"
run "rm -f $WEBSITE_DIR/$SPEC_FILE $WEBSITE_DIR/$RELE_FILE"
run "cp $BUILD_DIR/hello-${FRAMAC_VERSION_AND_CODENAME}.tar.gz $WEBSITE_DIR/$SPEC_FILE"
run "git -C $WEBSITE_DIR add $SPEC_FILE"
run "ln -s hello-${FRAMAC_VERSION_AND_CODENAME}.tar.gz $WEBSITE_DIR/$RELE_FILE";
run "git -C $WEBSITE_DIR add $RELE_FILE"
*)
echo "Stash or commit local changes, then run the script again."
exit 1
esac
fi
run "mkdir -p $BUILD_DIR_ROOT"
run "rm -rf $BUILD_DIR"
run "git worktree prune"
fi
;&
5)
step 5 "COPYING AND STAGING THE DISTRIBUTED MANUALS"
PAGE_NAME=Frama-C-${FRAMAC_VERSION_AND_CODENAME}.md
WIKI_PAGE=$GITLAB_WIKI/$PAGE_NAME
run "mkdir -p $GITLAB_WIKI/manuals"
run "sed -i -e '/<!-- LAST RELEASE -->/a \
run "git worktree add -f --detach $BUILD_DIR $FRAMAC_BRANCH"
run "cd $BUILD_DIR; autoconf"
run "cd $BUILD_DIR; ./configure"
run "cd $BUILD_DIR; make -j OPEN_SOURCE=yes src-distrib"
# sanity check: markdown-report must be distributed
run "tar tf $BUILD_DIR/$TARGZ_FILENAME | grep -q src/plugins/markdown-report"
# populate release assets in wiki
run "mkdir -p $GITLAB_WIKI/downloads"
run "cp $BUILD_DIR/$TARGZ_FILENAME $GITLAB_WIKI/downloads/"
if test "$FINAL_RELEASE" = "yes"; then
SPEC_FILE="$DOWNLOAD_DIR/$TARGZ_FILENAME"
run "rm -f $WEBSITE_DIR/$SPEC_FILE"
run "cp $BUILD_DIR/$TARGZ_FILENAME $WEBSITE_DIR/$SPEC_FILE"
run "git -C $WEBSITE_DIR add $SPEC_FILE"
fi
;&
3)
#note: this step may fail if step 4 was performed,
# because it will erase BUILD_DIR
step 3 "BUILDING THE API BUNDLE"
if test \! -d "$BUILD_DIR" ; then
echo "ERROR: $BUILD_DIR does not exist, possibly removed by another step"
exit 1
fi
run "cd $BUILD_DIR; make -j doc-distrib"
if test "$FINAL_RELEASE" = "yes"; then
SPEC_FILE="$DOWNLOAD_DIR/frama-c-${FRAMAC_VERSION_AND_CODENAME}-api.tar.gz"
run "rm -f $WEBSITE_DIR/$SPEC_FILE"
run "cp $BUILD_DIR/frama-c-api.tar.gz $WEBSITE_DIR/$SPEC_FILE"
run "git -C $WEBSITE_DIR add $SPEC_FILE"
fi
;&
4)
step 4 "BUILDING THE DOCUMENTATION COMPANIONS"
if test \! -d "$BUILD_DIR" ; then
echo "ERROR: $BUILD_DIR does not exist, possibly removed by another step"
exit 1
fi
run "cd $BUILD_DIR; make -j doc-companions"
if test "$FINAL_RELEASE" = "yes"; then
SPEC_FILE="$DOWNLOAD_DIR/hello-${FRAMAC_VERSION_AND_CODENAME}.tar.gz"
RELE_FILE="$DOWNLOAD_DIR/hello.tar.gz"
run "rm -f $WEBSITE_DIR/$SPEC_FILE $WEBSITE_DIR/$RELE_FILE"
run "cp $BUILD_DIR/hello-${FRAMAC_VERSION_AND_CODENAME}.tar.gz $WEBSITE_DIR/$SPEC_FILE"
run "git -C $WEBSITE_DIR add $SPEC_FILE"
run "ln -s hello-${FRAMAC_VERSION_AND_CODENAME}.tar.gz $WEBSITE_DIR/$RELE_FILE";
run "git -C $WEBSITE_DIR add $RELE_FILE"
run "rm -rf $BUILD_DIR"
run "git worktree prune"
fi
;&
5)
step 5 "COPYING AND STAGING THE DISTRIBUTED MANUALS"
PAGE_NAME=Frama-C-${FRAMAC_VERSION_AND_CODENAME}.md
WIKI_PAGE=$GITLAB_WIKI/$PAGE_NAME
run "mkdir -p $GITLAB_WIKI/manuals"
run "sed -i -e '/<!-- LAST RELEASE -->/a \
- [${FRAMAC_VERSION} (${FRAMAC_VERSION_CODENAME})](Frama-C-${FRAMAC_VERSION_AND_CODENAME})' $GITLAB_WIKI/Home.md"
if test "$FINAL_RELEASE" = "yes"; then
release_type="FINAL"
else
release_type="BETA"
fi
run "sed -i -e '/<!-- LAST ${release_type} RELEASE -->/a \
if test "$FINAL_RELEASE" = "yes"; then
release_type="FINAL"
else
release_type="BETA"
fi
run "sed -i -e '/<!-- LAST ${release_type} RELEASE -->/a \
- [${FRAMAC_VERSION} (${FRAMAC_VERSION_CODENAME})](Frama-C-${FRAMAC_VERSION_AND_CODENAME})' $GITLAB_WIKI/_sidebar.md"
echo "# Frama-C release ${FRAMAC_VERSION} (${FRAMAC_VERSION_CODENAME})" > $WIKI_PAGE
echo "## Sources" >> $WIKI_PAGE
echo " - [$TARGZ_FILENAME](downloads/$TARGZ_FILENAME)" >> $WIKI_PAGE
echo "" >> $WIKI_PAGE
echo "## Manuals" >> $WIKI_PAGE
for fpath in $MANUALS_DIR/*; do
f=$(basename $fpath)
f_no_ext=${f%.*}
# E-ACSL-related files are stored in subdirectory e-acsl
if [[ $f_no_ext =~ ^e-acsl.*$ ]]; then
destdir="$WEBSITE_DIR/$DOWNLOAD_DIR/e-acsl"
else
destdir="$WEBSITE_DIR/$DOWNLOAD_DIR"
fi
if [[ -L $fpath ]]; then
# symbolic links are copied to the website and prepended with 'frama-c-'
# (except for acsl.pdf, which is copied as is)
if [[ $f_no_ext =~ ^(e-)?acsl$ ]]; then
ln="$f"
else
ln="frama-c-$f"
fi
run "rm -f $destdir/$ln"
run "cp -P $fpath $destdir/$ln"
run "git -C $destdir add $ln"
else
# non-symbolic links are copied as-is to the website, and also to
# the Gitlab wiki, where they are also added as links
f_no_pdf_ext="${f%.pdf}"
echo "- [${f_no_pdf_ext%-${FRAMAC_VERSION_AND_CODENAME}}](manuals/$f)" >> $WIKI_PAGE
run "cp $fpath $GITLAB_WIKI/manuals/"
run "git -C $GITLAB_WIKI add manuals/$f"
run "cp $fpath $destdir/$f"
run "git -C $destdir add $f"
fi
done
echo "# Frama-C release ${FRAMAC_VERSION} (${FRAMAC_VERSION_CODENAME})" > $WIKI_PAGE
echo "## Sources" >> $WIKI_PAGE
echo " - [$TARGZ_FILENAME](downloads/$TARGZ_FILENAME)" >> $WIKI_PAGE
echo "" >> $WIKI_PAGE
echo "## Manuals" >> $WIKI_PAGE
for fpath in $MANUALS_DIR/*; do
f=$(basename $fpath)
f_no_ext=${f%.*}
# E-ACSL-related files are stored in subdirectory e-acsl
if [[ $f_no_ext =~ ^e-acsl.*$ ]]; then
destdir="$WEBSITE_DIR/$DOWNLOAD_DIR/e-acsl"
else
destdir="$WEBSITE_DIR/$DOWNLOAD_DIR"
fi
if [[ -L $fpath ]]; then
# symbolic links are copied to the website and prepended with 'frama-c-'
# (except for acsl.pdf, which is copied as is)
if [[ $f_no_ext =~ ^(e-)?acsl$ ]]; then
ln="$f"
else
ln="frama-c-$f"
fi
run "rm -f $destdir/$ln"
run "cp -P $fpath $destdir/$ln"
run "git -C $destdir add $ln"
else
# non-symbolic links are copied as-is to the website, and also to
# the Gitlab wiki, where they are also added as links
f_no_pdf_ext="${f%.pdf}"
echo "- [${f_no_pdf_ext%-${FRAMAC_VERSION_AND_CODENAME}}](manuals/$f)" >> $WIKI_PAGE
run "cp $fpath $GITLAB_WIKI/manuals/"
run "git -C $GITLAB_WIKI add manuals/$f"
run "cp $fpath $destdir/$f"
run "git -C $destdir add $f"
fi
done
INSTALL_WEBPAGE=html/installations/$(echo "$FRAMAC_VERSION_CODENAME" | tr '[:upper:]' '[:lower:]').md
INSTALL_WEBPAGE_PATH=$WEBSITE_DIR/$INSTALL_WEBPAGE
echo "----" > $INSTALL_WEBPAGE_PATH
echo "layout: doc_page" >> $INSTALL_WEBPAGE_PATH
echo "title: Installation instructions for $FRAMAC_VERSION_CODENAME" >> $INSTALL_WEBPAGE_PATH
echo "----" >> $INSTALL_WEBPAGE_PATH
cat ./INSTALL.md >> $INSTALL_WEBPAGE_PATH
run "git -C $WEBSITE_DIR add $INSTALL_WEBPAGE"
run "git -C $GITLAB_WIKI add $PAGE_NAME"
;;
*)
echo "Bad entry: ${STEP}"
echo "Exiting without doing anything.";
exit 31
;;
run "git -C $GITLAB_WIKI add $PAGE_NAME"
;;
*)
echo "Bad entry: ${STEP}"
echo "Exiting without doing anything.";
exit 31
;;
esac
exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment