Serious work on the buildall script (and project.clj) to capture a

build signature in the MANIFEST.MF file; also, getting rid of dependency
on collage.
This commit is contained in:
Simon Brooke 2014-07-27 09:40:06 +01:00
parent 75475ece29
commit 0652a9ba61
3 changed files with 171 additions and 50 deletions

View file

@ -8,27 +8,123 @@
# Simon Broooke <simon@jasmine.org.uk> # Simon Broooke <simon@jasmine.org.uk>
email=`grep ${USER} /etc/passwd | awk -F\: '{print $5}' | awk -F\, '{print $4}'`
fullname=`grep ${USER} /etc/passwd | awk -F\: '{print $5}' | awk -F\, '{print $1}'`
webappsdir="/var/lib/tomcat7/webapps"
release="" release=""
trial="FALSE"
case $1 in # Builds the build signature properties in the manifest map file
build) # expected arguments: old version tag, version tag, full name of user,
# 'build' is the expected normal case. # email of user; if not passed, all these will be set to "unset".
;; # The objective I'm trying to achieve is that when committed to version
release) # control, these are all always unset; but they're all valid in a build.
# release is branch a release and upversion to new label function setup-build-sig {
release=$2; if [ "${1}" = "" ]
if [ "${release}" = "" ] then
then o="unset"
echo "Release flagged, but no release tag supplied" 1>&2; else
exit 1; o="${1}"
fi;; fi
*) if [ "${2}" = "" ]
echo "Usage:" 1>&2; then
echo " ${0} build Build all components and commit to master" 1>&2; v="unset"
echo " ${0} release [LABEL] Build all components, branch for release on " 1>&2; else
echo " old label, then upversion to new LABEL and commit to master" 1>&2; v="${2}"
exit 1;; fi
esac if [ "${3}" = "" ]
then
u="unset"
else
u="${3}"
fi
if [ "${4}" = "" ]
then
e="unset"
else
e="${4}"
fi
if [ "${2}${3}${4}" = "" ]
then
t="unset"
else
t=`date --rfc-3339 seconds`
fi
if [ ! -d "target" ]
then
mkdir "target"
fi
cat <<-EOF > target/manifest.sed
s/${o}/${v}/g
s/^ *"build-signature-version" ".*" *\$/\t\t"build-signature-version" "${v}"/
s/^ *"build-signature-user" ".*" *\$/\t\t"build-signature-user" "${u}"/
s/^ *"build-signature-email" ".*" *\$/\t\t"build-signature-email" "${e}"/
s/^ *"build-signature-timestamp" ".*" *\$/\t\t"build-signature-timestamp" "${t}"/
EOF
}
if [ $# -lt 1 ]
then
cat <<-EOF 1>&2
Usage:
-build Build all components and commit to master.
-email [ADDRESS] Your email address, to be recorded in the build signature.
-fullname [NAME] Your full name, to be recorded in the build signature.
-release [LABEL] Build all components, branch for release on old label, then
upversion to new LABEL and commit to master.
-trial Trial build only, do not commit.
-webapps [PATH] Set the path to the local tomcat webapps directory
EOF
exit 1
fi
while (( "$#" ))
do
case $1 in
-b|-build)
# 'build' is the expected normal case.
trial="FALSE";
;;
-e|-email)
shift;
email=$1;;
-f|-fullname)
shift;
fullname=$1;;
-r|-release)
# release is branch a release and upversion to new label
shift;
release=$1;
trial="FALSE";
if [ "${release}" = "" ]
then
echo "Release flagged, but no release tag supplied" 1>&2;
exit 1;
fi;;
-t|-trial)
trial="TRUE";;
-w|-webapps)
# Set the tomcat webapps directory to release to
shift;
webappsdir=$1;;
*)
echo "Unrecognised option '${1}', exiting." 1>&2;
exit 1;;
esac
shift
done
echo "Trial: ${trial}; email: ${email}; fullname ${fullname}; release: ${release}; webapps: $webappsdir"
ls mw-* > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "No subdirectories matching 'mw-*' found, exiting." 1>&2;
exit 1;
fi
for dir in mw-* for dir in mw-*
do do
@ -51,7 +147,8 @@ do
exit 1; exit 1;
fi fi
cat project.clj > project.bak.1 cat project.clj > project.bak.1
sed "s/${old}/${interim}/" project.bak.1 > project.clj setup-build-sig "${old}" "${interim}" "${fullname}" "${email}"
sed -f target/manifest.sed project.bak.1 > project.clj
message="Upversioned from ${old} to ${interim} for release" message="Upversioned from ${old} to ${interim} for release"
old=${interim} old=${interim}
fi fi
@ -67,7 +164,7 @@ do
exit 1 exit 1
fi fi
lein test lein test
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "Sub-project ${dir} failed in test" 1>&2 echo "Sub-project ${dir} failed in test" 1>&2
@ -77,21 +174,33 @@ do
lein marg lein marg
lein install lein install
if [ "${message}" = "" ] cat project.clj > project.bak.2
setup-build-sig "${old}"
sed -f target/manifest.sed project.bak.2 > project.clj
if [ "${trial}" = "FALSE" ]
then then
git commit -a if [ "${message}" = "" ]
else then
git commit -a -m "$message" git commit -a
else
git commit -a -m "$message"
fi
git push origin master
fi fi
git push origin master
if [ "${release}" != "" ] if [ "${release}" != "" ]
then then
branch="${old}_MAINTENANCE" branch="${old}_MAINTENANCE"
git branch "${branch}" if [ "${trial}" = "FALSE" ]
# git push origin "${branch}" then
cat project.clj > project.bak.2 git branch "${branch}"
sed "s/${interim}/${release}-SNAPSHOT/" project.bak.2 > project.clj git push origin "${branch}"
fi
cat project.clj > project.bak.3
setup-build-sig "${old}" "${release}-SNAPSHOT" "${fullname}" "${email}"
sed -f target/manifest.sed project.bak.3 > project.clj
message="Upversioned from ${interim} to ${release}-SNAPSHOT" message="Upversioned from ${interim} to ${release}-SNAPSHOT"
echo $message echo $message
@ -105,19 +214,27 @@ do
fi fi
lein marg lein marg
lein install lein install
git commit -a -m "${message}"
echo ${message} cat project.clj > project.bak.4
git push origin master setup-build-sig "${release}-SNAPSHOT"
sed -f target/manifest.sed project.bak.4 > project.clj
if [ "${trial}" = "FALSE" ]
then
git commit -a -m "${message}"
echo ${message}
git push origin master
fi
fi fi
# Finally, if we're in the UI project, build the uberwar - and should probably deploy it # Finally, if we're in the UI project, build the uberwar - and should
# to local Tomcat for test # probably deploy it to local Tomcat for test
if [ "${dir}" = "mw-ui" ] if [ "${dir}" = "mw-ui" ]
then then
lein ring uberwar lein ring uberwar
sudo cp target/microworld.war /var/lib/tomcat7/webapps sudo cp target/microworld.war /var/lib/tomcat7/webapps
echo "Deployed new WAR file to local Tomcat" echo "Deployed new WAR file to local Tomcat"
fi fi
popd popd
done done

View file

@ -1,11 +1,19 @@
(defproject mw-engine "0.1.2-SNAPSHOT" (defproject mw-engine "0.1.2-SNAPSHOT"
:description "Cellular automaton world builder." :description "Cellular automaton world builder."
:url "http://example.com/FIXME" :url "http://www.journeyman.cc/microworld/"
:manifest {
;; do not reformat this! It is important for the buildall script
;; that each of these properties is on a line with nothing else.
"build-signature-version" "unset"
"build-signature-user" "unset"
"build-signature-email" "unset"
"build-signature-timestamp" "unset"
}
:license {:name "GNU General Public License v2" :license {:name "GNU General Public License v2"
:url "http://www.gnu.org/licenses/gpl-2.0.html"} :url "http://www.gnu.org/licenses/gpl-2.0.html"}
:plugins [[lein-marginalia "0.7.1"]] :plugins [[lein-marginalia "0.7.1"]]
:dependencies [[org.clojure/clojure "1.5.1"] :dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/math.combinatorics "0.0.7"] [org.clojure/math.combinatorics "0.0.7"]
[org.clojure/tools.trace "0.7.8"] [org.clojure/tools.trace "0.7.8"]
[net.mikera/imagez "0.3.1"] [net.mikera/imagez "0.3.1"]])
[fivetonine/collage "0.2.1"]])

View file

@ -7,11 +7,8 @@
(:import [java.awt.image BufferedImage]) (:import [java.awt.image BufferedImage])
(:use mw-engine.utils (:use mw-engine.utils
mw-engine.world mw-engine.world
;; interestingly the imagez load-image is failing for me, while the [mikera.image.core :only [load-image filter-image get-pixels]]
;; collage version is problem free.
[mikera.image.core :only [filter-image get-pixels]]
[mikera.image.filters] [mikera.image.filters]
[fivetonine.collage.util]
)) ))
(defn- abs (defn- abs
@ -42,7 +39,7 @@
[world] [world]
(map-world world tag-gradient)) (map-world world tag-gradient))
(defn transform-altitude (defn tag-altitude
"Set the altitude of this cell from the corresponding pixel of this heightmap. "Set the altitude of this cell from the corresponding pixel of this heightmap.
If the heightmap you supply is smaller than the world, this will break. If the heightmap you supply is smaller than the world, this will break.
@ -52,7 +49,7 @@
* `heightmap` an (ideally) greyscale image, whose x and y dimensions should * `heightmap` an (ideally) greyscale image, whose x and y dimensions should
exceed those of the world of which the `cell` forms part." exceed those of the world of which the `cell` forms part."
([world cell heightmap] ([world cell heightmap]
(transform-altitude cell heightmap)) (tag-altitude cell heightmap))
([cell heightmap] ([cell heightmap]
(merge cell (merge cell
{:altitude {:altitude
@ -73,14 +70,13 @@
a world the size of the heightmap will be created. a world the size of the heightmap will be created.
* `imagepath` a file path or URL which indicates an image file." * `imagepath` a file path or URL which indicates an image file."
([world imagepath] ([world imagepath]
;; bizarrely, the collage load-util is working for me, but the imagez version isn't.
(let [heightmap (filter-image (grayscale)(load-image imagepath))] (let [heightmap (filter-image (grayscale)(load-image imagepath))]
(map-world (map-world
(map-world world transform-altitude (list heightmap)) (map-world world tag-altitude (list heightmap))
tag-gradient))) tag-gradient)))
([imagepath] ([imagepath]
(let [heightmap (filter-image (grayscale)(load-image imagepath)) (let [heightmap (filter-image (grayscale)(load-image imagepath))
world (make-world (.getWidth heightmap) (.getHeight heightmap))] world (make-world (.getWidth heightmap) (.getHeight heightmap))]
(map-world (map-world
(map-world world transform-altitude (list heightmap)) (map-world world tag-altitude (list heightmap))
tag-gradient)))) tag-gradient))))