generate.sh
author Dan Fuhry <dan@enanocms.org>
Mon, 05 Jul 2010 23:57:56 -0400
changeset 5 7d3b7009399d
parent 3 859eeb3579b2
permissions -rwxr-xr-x
Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
     1
#!/bin/bash
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
     2
DATE=`date "+%Y%m%d"`
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
     3
VERSION="hg-$DATE"
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
     4
REPO="./enano-hg"
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
     5
REVISION="tip"
5
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
     6
MINIMAL=
0
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
     7
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
     8
usage()
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
     9
{
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    10
  cat <<EOF
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    11
Usage: $0 [flags]
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    12
Available command-line parameters:
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    13
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    14
  -h                This help
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    15
  -v version        Specify version of package (default: hg-$DATE)
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    16
  -r revision       Mercurial revision to pull (default: tip)
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    17
  -R repopath       Path to Mercurial repository (default: ./enano-hg)
5
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    18
  -m                If set, installer doesn't pack a copy of Enano. Instead,
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    19
                    it downloads and runs mkenanodev.sh.
0
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    20
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    21
EOF
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    22
  exit 1
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    23
}
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    24
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    25
fail()
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    26
{
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    27
  echo $1
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    28
  exit 1
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    29
}
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    30
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    31
while [ -n "$1" ]; do
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    32
  case "$1" in
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    33
    -v)
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    34
      VERSION="$2"
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    35
      shift
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    36
      ;;
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    37
    -r)
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    38
      REVISION="$2"
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    39
      shift
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    40
      ;;
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    41
    -R)
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    42
      REPO="$2"
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    43
      shift
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    44
      ;;
5
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    45
    -m)
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    46
      MINIMAL=true
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    47
      ;;
0
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    48
    *)
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    49
      usage
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    50
      ;;
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    51
  esac
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    52
  shift
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    53
done
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    54
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    55
if [ -z "$VERSION" -o -z "$REVISION" -o -z "$REPO" ]; then
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    56
  usage
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    57
fi
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    58
5
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    59
if [ ! -d "$REPO/.hg" -a -z "$MINIMAL" ]; then
0
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    60
  echo "ERROR: Could not find the Enano Mercurial repository at $REPO."
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    61
  echo "Perhaps you need to obtain a copy?"
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    62
  echo "  $ hg clone http://hg.enanocms.org/repos/enano-1.1 ./enano-hg"
2
7dddb5fb1595 Me and my obsession with getting files to exactly 2048 bytes.
Dan
parents: 1
diff changeset
    63
  echo "If you have a copy somewhere else, make a symlink:"
0
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    64
  echo "  $ ln -s /path/to/enano/hg ./enano-hg"
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    65
  exit 1
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    66
fi
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    67
1
dbce0b16b0c1 Added shellscript compactor to reduce size of self-extract script
Dan
parents: 0
diff changeset
    68
printf "Compacting self-extraction script..."
dbce0b16b0c1 Added shellscript compactor to reduce size of self-extract script
Dan
parents: 0
diff changeset
    69
sed -f compact-shellscript.sed self-extract-src.sh > self-extract.sh || fail "Failed to generate compacted self-extract script"
dbce0b16b0c1 Added shellscript compactor to reduce size of self-extract script
Dan
parents: 0
diff changeset
    70
5
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    71
if [ -z "$MINIMAL" ]; then
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    72
	printf "\nPulling latest code..."
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    73
	hg -R $REPO archive -r $REVISION -t tgz enano-$VERSION.tar.gz || fail "Could not pull revision $REVISION from Mercurial repo"
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    74
	printf "\nExtracting..."
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    75
	tar xzCf `dirname $0`/stage enano-$VERSION.tar.gz || fail "Could not extract tarball"
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    76
	rm -f enano-$VERSION.tar.gz
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    77
fi
0
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    78
printf "\nCreating payload..."
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    79
cd stage
3
859eeb3579b2 Added uninstall script and warning about SSE2-only build of GMP
Dan Fuhry <dan@enanocms.org>
parents: 2
diff changeset
    80
tar cjf ../enano-$VERSION-selfextract.tar.bz2 * || fail "Could not create staging tarball"
5
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    81
if [ -z "$MINIMAL" ]; then
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    82
	rm -rf enano-$VERSION
7d3b7009399d Added OS X tr workaround; added support for making Mercurial-only packages that pull Enano from Mercurial and install it using mkenanodev
Dan Fuhry <dan@enanocms.org>
parents: 3
diff changeset
    83
fi
0
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    84
cd ..
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    85
printf "\nWriting output..."
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    86
cat self-extract.sh enano-$VERSION-selfextract.tar.bz2 > enano-$VERSION-bitnami-module.sh || fail "Could not write output"
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    87
chmod +x enano-$VERSION-bitnami-module.sh
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    88
rm -f enano-$VERSION-selfextract.tar.bz2
8e044e762a6c First revision, but working.
Dan
parents:
diff changeset
    89
echo -e "\nDone! Output written to enano-$VERSION-bitnami-module.sh"