Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev default tip
authorDan Fuhry <dan@enanocms.org>
Mon, 05 Jul 2010 23:57:56 -0400
changeset 5 7d3b7009399d
parent 4 c6c431cf0a89
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
generate.sh
stage/autorun.sh
--- a/generate.sh	Mon Jul 05 23:29:07 2010 -0400
+++ b/generate.sh	Mon Jul 05 23:57:56 2010 -0400
@@ -3,6 +3,7 @@
 VERSION="hg-$DATE"
 REPO="./enano-hg"
 REVISION="tip"
+MINIMAL=
 
 usage()
 {
@@ -14,6 +15,8 @@
   -v version        Specify version of package (default: hg-$DATE)
   -r revision       Mercurial revision to pull (default: tip)
   -R repopath       Path to Mercurial repository (default: ./enano-hg)
+  -m                If set, installer doesn't pack a copy of Enano. Instead,
+                    it downloads and runs mkenanodev.sh.
 
 EOF
   exit 1
@@ -39,6 +42,9 @@
       REPO="$2"
       shift
       ;;
+    -m)
+      MINIMAL=true
+      ;;
     *)
       usage
       ;;
@@ -50,7 +56,7 @@
   usage
 fi
 
-if [ ! -d "$REPO/.hg" ]; then
+if [ ! -d "$REPO/.hg" -a -z "$MINIMAL" ]; then
   echo "ERROR: Could not find the Enano Mercurial repository at $REPO."
   echo "Perhaps you need to obtain a copy?"
   echo "  $ hg clone http://hg.enanocms.org/repos/enano-1.1 ./enano-hg"
@@ -62,15 +68,19 @@
 printf "Compacting self-extraction script..."
 sed -f compact-shellscript.sed self-extract-src.sh > self-extract.sh || fail "Failed to generate compacted self-extract script"
 
-printf "\nPulling latest code..."
-hg -R $REPO archive -r $REVISION -t tgz enano-$VERSION.tar.gz || fail "Could not pull revision $REVISION from Mercurial repo"
-printf "\nExtracting..."
-tar xzCf `dirname $0`/stage enano-$VERSION.tar.gz || fail "Could not extract tarball"
-rm -f enano-$VERSION.tar.gz
+if [ -z "$MINIMAL" ]; then
+	printf "\nPulling latest code..."
+	hg -R $REPO archive -r $REVISION -t tgz enano-$VERSION.tar.gz || fail "Could not pull revision $REVISION from Mercurial repo"
+	printf "\nExtracting..."
+	tar xzCf `dirname $0`/stage enano-$VERSION.tar.gz || fail "Could not extract tarball"
+	rm -f enano-$VERSION.tar.gz
+fi
 printf "\nCreating payload..."
 cd stage
 tar cjf ../enano-$VERSION-selfextract.tar.bz2 * || fail "Could not create staging tarball"
-rm -rf enano-$VERSION
+if [ -z "$MINIMAL" ]; then
+	rm -rf enano-$VERSION
+fi
 cd ..
 printf "\nWriting output..."
 cat self-extract.sh enano-$VERSION-selfextract.tar.bz2 > enano-$VERSION-bitnami-module.sh || fail "Could not write output"
--- a/stage/autorun.sh	Mon Jul 05 23:29:07 2010 -0400
+++ b/stage/autorun.sh	Mon Jul 05 23:57:56 2010 -0400
@@ -29,13 +29,35 @@
 cd `dirname $0`
 
 echo "Welcome to the Enano CMS BitNami module installer."
+if [ ! -d ./enano-* ]; then
+	HG_BASE=${HG_BASE:-http://hg.enanocms.org/repos}
+	cat <<EOF
+This is the Mercurial-based installer. It doesn't include the Enano source
+tree - instead it's created based on the latest Mercurial sources. To use this
+installer, you must have Mercurial on your system.
+
+The current repository path is ${HG_BASE}.
+To override it, set HG_BASE.
+
+You can safely Control-C out of this installer at any time and temporary files
+will be cleaned up.
+
+EOF
+fi
+
 autobitnami=""
 if test -n "$HOME"; then
-  autobitnami=$(echo $HOME/lampstack-*)
+  autobitnami=`echo $HOME/lampstack-*`
   if test ! -d "$autobitnami"; then
     autobitnami=""
   fi
 fi
+if test -d /Applications/; then
+	autobitnami=`echo /Applications/mampstack-*`
+	if test ! -d "$autobitnami"; then
+		autobitnami=""
+	fi
+fi
 while true; do
   if test -n "$autobitnami"; then
     read -p "Path to BitNami directory [$autobitnami]: " bitnami
@@ -62,18 +84,38 @@
   echo $out
 done
 
+my_tr()
+{
+	# this is needed under OS X, its terminal emulator tends to mess up tr
+	LC_ALL=C tr $@
+	return $?
+}
+
 echo "Creating database."
 
 bitnami_db="bn_enanocms"
 bitnami_user="bn_enanocms"
-bitnami_pass=`dd if=/dev/urandom bs=256 count=1 2>/dev/null | tr -cd '\41-\46\50-\176' | cut -c 1-12`
+bitnami_pass=`dd if=/dev/urandom bs=256 count=1 2>/dev/null | my_tr -cd '\41-\46\50-\176' | cut -c 1-12`
 
 query='CREATE DATABASE IF NOT EXISTS `'$bitnami_db'`; GRANT ALL PRIVILEGES ON '$bitnami_db'.* TO '"$bitnami_user"'@localhost IDENTIFIED BY '"'$bitnami_pass'"'; FLUSH PRIVILEGES;'
 echo "$query" | $mysql -u root --password="$mysqlpass" || exit 1
 
 echo "Installing files."
 mkdir -p $bitnami/apps/enanocms/{conf,licenses} || exit 1
-cp -r ./enano-* $bitnami/apps/enanocms/htdocs || exit 1
+if [ -d ./enano-* ]; then
+	cp -r ./enano-* $bitnami/apps/enanocms/htdocs || exit 1
+else
+	# There's no Enano source tree in this installer. Pull the latest from Mercurial.
+	oldpwd=`pwd`
+	cd $bitnami/apps/enanocms || exit 1
+	curl -q -o mkenanodev.sh http://hg.enanocms.org/mkenanodev.sh || exit 1
+	chmod u+x mkenanodev.sh || exit 1
+	./mkenanodev.sh 1.1 $HG_BASE || exit 1
+	rm -f mkenanodev.sh
+	mv enano-1.1 htdocs || exit 1
+	
+	cd $oldpwd
+fi
 cp ./COPYING $bitnami/apps/enanocms/licenses/ || exit 1
 cat <<EOF > $bitnami/apps/enanocms/conf/enanocms.conf
 Alias /enanocms "$bitnami/apps/enanocms/htdocs"