generate.sh
changeset 5 7d3b7009399d
parent 3 859eeb3579b2
equal deleted inserted replaced
4:c6c431cf0a89 5:7d3b7009399d
     1 #!/bin/bash
     1 #!/bin/bash
     2 DATE=`date "+%Y%m%d"`
     2 DATE=`date "+%Y%m%d"`
     3 VERSION="hg-$DATE"
     3 VERSION="hg-$DATE"
     4 REPO="./enano-hg"
     4 REPO="./enano-hg"
     5 REVISION="tip"
     5 REVISION="tip"
       
     6 MINIMAL=
     6 
     7 
     7 usage()
     8 usage()
     8 {
     9 {
     9   cat <<EOF
    10   cat <<EOF
    10 Usage: $0 [flags]
    11 Usage: $0 [flags]
    12 
    13 
    13   -h                This help
    14   -h                This help
    14   -v version        Specify version of package (default: hg-$DATE)
    15   -v version        Specify version of package (default: hg-$DATE)
    15   -r revision       Mercurial revision to pull (default: tip)
    16   -r revision       Mercurial revision to pull (default: tip)
    16   -R repopath       Path to Mercurial repository (default: ./enano-hg)
    17   -R repopath       Path to Mercurial repository (default: ./enano-hg)
       
    18   -m                If set, installer doesn't pack a copy of Enano. Instead,
       
    19                     it downloads and runs mkenanodev.sh.
    17 
    20 
    18 EOF
    21 EOF
    19   exit 1
    22   exit 1
    20 }
    23 }
    21 
    24 
    37       ;;
    40       ;;
    38     -R)
    41     -R)
    39       REPO="$2"
    42       REPO="$2"
    40       shift
    43       shift
    41       ;;
    44       ;;
       
    45     -m)
       
    46       MINIMAL=true
       
    47       ;;
    42     *)
    48     *)
    43       usage
    49       usage
    44       ;;
    50       ;;
    45   esac
    51   esac
    46   shift
    52   shift
    48 
    54 
    49 if [ -z "$VERSION" -o -z "$REVISION" -o -z "$REPO" ]; then
    55 if [ -z "$VERSION" -o -z "$REVISION" -o -z "$REPO" ]; then
    50   usage
    56   usage
    51 fi
    57 fi
    52 
    58 
    53 if [ ! -d "$REPO/.hg" ]; then
    59 if [ ! -d "$REPO/.hg" -a -z "$MINIMAL" ]; then
    54   echo "ERROR: Could not find the Enano Mercurial repository at $REPO."
    60   echo "ERROR: Could not find the Enano Mercurial repository at $REPO."
    55   echo "Perhaps you need to obtain a copy?"
    61   echo "Perhaps you need to obtain a copy?"
    56   echo "  $ hg clone http://hg.enanocms.org/repos/enano-1.1 ./enano-hg"
    62   echo "  $ hg clone http://hg.enanocms.org/repos/enano-1.1 ./enano-hg"
    57   echo "If you have a copy somewhere else, make a symlink:"
    63   echo "If you have a copy somewhere else, make a symlink:"
    58   echo "  $ ln -s /path/to/enano/hg ./enano-hg"
    64   echo "  $ ln -s /path/to/enano/hg ./enano-hg"
    60 fi
    66 fi
    61 
    67 
    62 printf "Compacting self-extraction script..."
    68 printf "Compacting self-extraction script..."
    63 sed -f compact-shellscript.sed self-extract-src.sh > self-extract.sh || fail "Failed to generate compacted self-extract script"
    69 sed -f compact-shellscript.sed self-extract-src.sh > self-extract.sh || fail "Failed to generate compacted self-extract script"
    64 
    70 
    65 printf "\nPulling latest code..."
    71 if [ -z "$MINIMAL" ]; then
    66 hg -R $REPO archive -r $REVISION -t tgz enano-$VERSION.tar.gz || fail "Could not pull revision $REVISION from Mercurial repo"
    72 	printf "\nPulling latest code..."
    67 printf "\nExtracting..."
    73 	hg -R $REPO archive -r $REVISION -t tgz enano-$VERSION.tar.gz || fail "Could not pull revision $REVISION from Mercurial repo"
    68 tar xzCf `dirname $0`/stage enano-$VERSION.tar.gz || fail "Could not extract tarball"
    74 	printf "\nExtracting..."
    69 rm -f enano-$VERSION.tar.gz
    75 	tar xzCf `dirname $0`/stage enano-$VERSION.tar.gz || fail "Could not extract tarball"
       
    76 	rm -f enano-$VERSION.tar.gz
       
    77 fi
    70 printf "\nCreating payload..."
    78 printf "\nCreating payload..."
    71 cd stage
    79 cd stage
    72 tar cjf ../enano-$VERSION-selfextract.tar.bz2 * || fail "Could not create staging tarball"
    80 tar cjf ../enano-$VERSION-selfextract.tar.bz2 * || fail "Could not create staging tarball"
    73 rm -rf enano-$VERSION
    81 if [ -z "$MINIMAL" ]; then
       
    82 	rm -rf enano-$VERSION
       
    83 fi
    74 cd ..
    84 cd ..
    75 printf "\nWriting output..."
    85 printf "\nWriting output..."
    76 cat self-extract.sh enano-$VERSION-selfextract.tar.bz2 > enano-$VERSION-bitnami-module.sh || fail "Could not write output"
    86 cat self-extract.sh enano-$VERSION-selfextract.tar.bz2 > enano-$VERSION-bitnami-module.sh || fail "Could not write output"
    77 chmod +x enano-$VERSION-bitnami-module.sh
    87 chmod +x enano-$VERSION-bitnami-module.sh
    78 rm -f enano-$VERSION-selfextract.tar.bz2
    88 rm -f enano-$VERSION-selfextract.tar.bz2