clean-ed up and documented gh_pages build script
This commit is contained in:
parent
b72273b2a9
commit
81765ee971
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILD="$(mktemp -dt solaar-gh-pages-XXXXXX)"
|
BUILD="$(/bin/mktemp --directory --tmpdir solaar-gh-pages-XXXXXX)"
|
||||||
cd "$(dirname "$0")"/..
|
cd "$(/usr/bin/dirname "$0")/.."
|
||||||
SELF="$PWD"
|
SELF="$PWD"
|
||||||
SITE="$(readlink -f "$SELF/../gh-pages")"
|
SITE="$(/bin/readlink --canonicalize "$SELF/../gh-pages")"
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -13,10 +13,10 @@ SITE="$(readlink -f "$SELF/../gh-pages")"
|
||||||
|
|
||||||
add_md() {
|
add_md() {
|
||||||
local SOURCE="$SELF/$1"
|
local SOURCE="$SELF/$1"
|
||||||
local TARGET="$BUILD/${2:-$(basename "$1")}"
|
local TARGET="$BUILD/${2:-$(/usr/bin/basename "$1")}"
|
||||||
|
|
||||||
LAYOUT=default
|
LAYOUT=default
|
||||||
TITLE=$(grep '^# ' "$SOURCE" -m 1 | cut -c 3-)
|
TITLE=$(/bin/grep --max-count=1 '^# ' "$SOURCE" | /usr/bin/cut --characters=3-)
|
||||||
if test -n "$TITLE"; then
|
if test -n "$TITLE"; then
|
||||||
local TITLE="Solaar - $TITLE"
|
local TITLE="Solaar - $TITLE"
|
||||||
LAYOUT=page
|
LAYOUT=page
|
||||||
|
@ -24,8 +24,8 @@ add_md() {
|
||||||
local TITLE=Solaar
|
local TITLE=Solaar
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$(dirname "$TARGET")"
|
/bin/mkdir --parents "$(dirname "$TARGET")"
|
||||||
cat >"$TARGET" <<-FRONTMATTER
|
/bin/cat >"$TARGET" <<-FRONTMATTER
|
||||||
---
|
---
|
||||||
layout: $LAYOUT
|
layout: $LAYOUT
|
||||||
title: $TITLE
|
title: $TITLE
|
||||||
|
@ -33,7 +33,7 @@ add_md() {
|
||||||
|
|
||||||
FRONTMATTER
|
FRONTMATTER
|
||||||
|
|
||||||
cat "$SOURCE" >>"$TARGET"
|
/bin/cat "$SOURCE" >>"$TARGET"
|
||||||
}
|
}
|
||||||
|
|
||||||
fix_times() {
|
fix_times() {
|
||||||
|
@ -43,68 +43,80 @@ fix_times() {
|
||||||
|
|
||||||
if test -d "$SOURCE"; then
|
if test -d "$SOURCE"; then
|
||||||
for f in "$SOURCE"/*; do
|
for f in "$SOURCE"/*; do
|
||||||
f=$(basename "$f")
|
f=$(/usr/bin/basename "$f")
|
||||||
fix_times "$1/$f" "$2/$f"
|
fix_times "$1/$f" "$2/$f"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
touch -r "$SOURCE" "$TARGET"
|
/usr/bin/touch --reference="$SOURCE" "$TARGET"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
cp -upr "$SELF/jekyll"/* "$BUILD/"
|
/bin/cp --archive --update "$SELF/jekyll"/* "$BUILD/"
|
||||||
convert.im6 "$SELF/share/solaar/icons/solaar.svg" -transparent white \
|
# convert the svg logo to png for the web site
|
||||||
|
/usr/bin/convert.im6 "$SELF/share/solaar/icons/solaar.svg" -transparent white \
|
||||||
-resize 48x48 "$BUILD/images/solaar-logo.png"
|
-resize 48x48 "$BUILD/images/solaar-logo.png"
|
||||||
convert.im6 "$SELF/share/solaar/icons/solaar.svg" -transparent white \
|
/usr/bin/convert.im6 "$SELF/share/solaar/icons/solaar.svg" -transparent white \
|
||||||
-resize 32x32 "$BUILD/images/favicon.png"
|
-resize 16x16 "$BUILD/images/favicon.png"
|
||||||
|
|
||||||
|
# optimize the converted pngs
|
||||||
|
command -V optipng && optipng -preserve -quiet -o 7 "$BUILD/images"/*.png
|
||||||
|
#command -V pngcrush && pngcrush -d "$BUILD/images" -oldtimestamp -q "$BUILD/images"/*.png
|
||||||
|
|
||||||
add_md docs/devices.md
|
add_md docs/devices.md
|
||||||
add_md docs/installation.md
|
add_md docs/installation.md
|
||||||
|
|
||||||
add_md README.md index.md
|
add_md README.md index.md
|
||||||
sed -i -e 's#\[docs/\([a-z]*\)\.md\]#[\1]#g' "$BUILD/index.md"
|
# fix local links to the proper .html files
|
||||||
sed -i -e 's#(docs/\([a-z]*\)\.md)#(\1.html)#g' "$BUILD/index.md"
|
/bin/sed --in-place --expression='s#\[docs/\([a-z]*\)\.md\]#[\1]#g' "$BUILD/index.md"
|
||||||
sed -i -e 's#(COPYING)#({{ site.repository }}/blob/master/COPYING)#g' "$BUILD/index.md"
|
/bin/sed --in-place --expression='s#(docs/\([a-z]*\)\.md)#(\1.html)#g' "$BUILD/index.md"
|
||||||
|
/bin/sed --in-place --expression='s#(COPYING)#({{ site.repository }}/blob/master/COPYING)#g' "$BUILD/index.md"
|
||||||
|
|
||||||
|
# remove empty lines, to minimze html sizes
|
||||||
for l in "$BUILD/_layouts"/*.html; do
|
for l in "$BUILD/_layouts"/*.html; do
|
||||||
sed -e '/^$/d' "$l" | tr -d '\t' >"$l="
|
/bin/sed --expression='/^$/d' "$l" | /usr/bin/tr --delete '\t' >"$l="
|
||||||
mv "$l=" "$l"
|
/bin/mv "$l=" "$l"
|
||||||
done
|
done
|
||||||
|
|
||||||
mkdir -p "$SITE/../packages" "$SITE/packages/"
|
# create packages/ sub-directory
|
||||||
cp -up "$SELF/dist/debian"/solaar_* "$SITE/../packages/"
|
/bin/mkdir --parents "$SITE/../packages" "$SITE/packages/"
|
||||||
cp -up "$SELF/dist/debian"/solaar-gnome3_* "$SITE/../packages/"
|
/bin/cp --archive --update --target-directory="$SITE/../packages/" "$SELF/dist/debian"/solaar_* || true
|
||||||
|
/bin/cp --archive --update --target-directory="$SITE/../packages/" "$SELF/dist/debian"/solaar-gnome3_* || true
|
||||||
if test -x /usr/bin/dpkg-scanpackages; then
|
if test -x /usr/bin/dpkg-scanpackages; then
|
||||||
cd "$SITE/../packages/"
|
cd "$SITE/../packages/"
|
||||||
rm -f *.build
|
/bin/rm --force *.build
|
||||||
dpkg-scanpackages -m . > Packages
|
/usr/bin/dpkg-scanpackages --multiversion . > Packages
|
||||||
dpkg-scansources . > Sources
|
/usr/bin/dpkg-scansources . > Sources
|
||||||
add_md docs/debian.md
|
add_md docs/debian.md
|
||||||
cd -
|
cd -
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check for the latest released version, and update the jekyll configuration
|
||||||
if test -x /usr/bin/uscan; then
|
if test -x /usr/bin/uscan; then
|
||||||
TAG=$(uscan --no-conf --report-status --check-dirname-regex packaging ./packaging/ \
|
TAG=$(/usr/bin/uscan --no-conf --report-status --check-dirname-regex packaging ./packaging/ \
|
||||||
| grep 'Newest version' \
|
| /bin/grep 'Newest version' \
|
||||||
| grep -ow '[0-9.]*' | head -1)
|
| /bin/grep --only-matching --word-regexp '[0-9.]*' | /usr/bin/head --lines=1)
|
||||||
if test -n "$TAG"; then
|
if test -n "$TAG"; then
|
||||||
sed -i -e 's#^version: .*$#'"version: $TAG#" "$SELF/jekyll/_config.yml"
|
/bin/sed --in-place --expression='s#^version: .*$#'"version: $TAG#" "$SELF/jekyll/_config.yml"
|
||||||
sed -i -e 's#/archive/[0-9.]*\.tar\.gz$#'"/archive/$TAG.tar.gz#" "$SELF/jekyll/_config.yml"
|
/bin/sed --in-place --expression='s#/archive/[0-9.]*\.tar\.gz$#'"/archive/$TAG.tar.gz#" "$SELF/jekyll/_config.yml"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GIT_BACKUP="$(mktemp -ud --tmpdir="$SITE/.." git-backup-XXXXXX)"
|
# Jekyll nukes the .git folder in the target
|
||||||
mv "$SITE/.git" "$GIT_BACKUP"
|
# so move it out of the way while building.
|
||||||
|
GIT_BACKUP="$(/bin/mktemp --dry-run --directory --tmpdir="$SITE/.." git-backup-XXXXXX)"
|
||||||
|
/bin/mv --no-target-directory "$SITE/.git" "$GIT_BACKUP"
|
||||||
jekyll --kramdown "$BUILD" "$SITE"
|
jekyll --kramdown "$BUILD" "$SITE"
|
||||||
mv "$GIT_BACKUP" "$SITE/.git"
|
/bin/mv --no-target-directory "$GIT_BACKUP" "$SITE/.git"
|
||||||
|
|
||||||
cp -al "$SITE/../packages/" "$SITE/"
|
/bin/cp --archive --link "$SITE/../packages/" "$SITE/"
|
||||||
|
|
||||||
|
# fix some html formatting
|
||||||
for p in "$SITE"/*.html; do
|
for p in "$SITE"/*.html; do
|
||||||
sed -i -e 's#^[ ]*##g' "$p"
|
/bin/sed --in-place --expression='s#^[ ]*##g' "$p"
|
||||||
sed -i -f- "$p" <<-SED
|
/bin/sed --in-place --file=- "$p" <<-SED
|
||||||
bstart
|
bstart
|
||||||
:eop /<\/p>/ brepl
|
:eop /<\/p>/ brepl
|
||||||
{ N; beop; }
|
{ N; beop; }
|
||||||
|
@ -115,6 +127,7 @@ for p in "$SITE"/*.html; do
|
||||||
SED
|
SED
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# set timestmap of the created files to match the sources
|
||||||
fix_times README.md index.html
|
fix_times README.md index.html
|
||||||
fix_times docs/devices.md devices.html
|
fix_times docs/devices.md devices.html
|
||||||
fix_times docs/installation.md installation.html
|
fix_times docs/installation.md installation.html
|
||||||
|
|
Loading…
Reference in New Issue