File:  [mozdev] / distrostubs / make_distro.sh
Revision 1.9: download - view: text, annotated - select for diffs - revision graph
Mon Oct 8 15:29:15 2007 UTC (10 years, 1 month ago) by petejc
Branches: MAIN
CVS tags: HEAD
fixes so script runs on OSX

#!/bin/sh

# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozdev Group, Inc.
#
# The Initial Developer of the Original Code is
# Pete Collins for Mozdev Group Inc.
# Portions created by the Initial Developer are Copyright (C) 2006
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
## usage and help global vars

PROG=$0;
AUTHORS="Pete Collins";
AUTH_EMAIL="<pete@mozdevgroup.com>";
CONTACT="<info@mozdevgroup.com>";
DATE="$Date: 2007/10/08 15:29:15 $";
REV="$Revision: 1.9 $";
REV_NUM=`echo "\$Revision: 1.9 $" | cut -d" " -f2`;
VER="0."$REV_NUM;
MSG="Copyright (C) 2006, \nMozdev Group, Inc.\n";
MSG=$MSG"This is free software; see the source for copying conditions.\n";
MSG=$MSG"There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n";
MSG=$MSG"PARTICULAR PURPOSE.\n\n";
SPC="                   ";
SPC2="              ";
SPC1="        ";
LOGGING="/dev/null";
URL=http://www.mozdevgroup.com;
URL_SCRIPTS=$URL/scripts;
DOCS=$URL/docs/;

FTMP="/tmp/distrostubs_tmp_file.dat";
year=`date  +%Y`;
list=list.txt;

## see if make is called gmake
which make > /dev/null 2>&1
if [ $? -eq 0 ]; then
  make_bin=`which make`;
else
  make_bin=`which gmake`;
fi

# help function
help () {
  echo "$0, version $VER, by $AUTHORS $AUTH_EMAIL.";
  printf "$MSG";
  printf "Docs: $DOCS\n";
  printf "Contact: $CONTACT\n";
  printf "Bugs: $BUG_URL\n";
  echo
  printf "Usage: $PROG [options] [projectname] [destination path]\n";
  echo
  printf "Options:\n";
  printf "  help, -h, --help, -?, h   Print this message and exit.\n";
  printf "  -V $SPC    Print version number and exit.\n";
  printf "  -v $SPC    Verbose Mode.\n";
  printf "  -l $SPC    Turn on Logging.\n";
  printf "  -r $SPC    Remove the named project.\n";
  echo
  printf "For Example: \n";
  echo
  printf "  If I want to create a new mozilla app called 'spiderman',\n";
  printf "  I would execute the command below from the top of my distrostubs\n";
  printf "  source tree.\n";
  echo
  printf "$SPC1  $ sh $PROG spiderman path/to/target/folder\n";
  echo
  printf "  and then to remove it, I would execute the command below\n";
  echo
  printf "$SPC1  $ sh $PROG -r spiderman path/to/target/folder\n";
  echo
}

case "$1" in
  ""|"help"|"h"|"--help"|"-?"|"-h")
    help;
    exit;
esac

project_name=$1;

# force name to lowercase
project_name=`echo $project_name | tr [A-Z] [a-z]`;

dest=$2;

## check cmdline args
while [ $# -gt 0 ]
  do
    case "$1" in
      -h)
        help;
        exit; 
        ;;
      -v)
        echo Not Implemented Yet. Sorry!;
        exit 0;
        ;;
      -V)
        echo $VER;
        exit; 
        ;;
      -l)
        echo Not Implemented Yet. Sorry!;
        exit 0;
        ;;
      -r)
        shift;
        if [ -z "$1" ] || [ -z "$2" ]; then 
          help;
          exit 1;
        fi
        project_name=$1;
        dest=$2;
        if [ -d $dest/$project_name ]; then
          ## remove project
          echo removing [$dest/$project_name];
          rm -rf $dest/$project_name;
          echo Finished . . .;
          exit 0;
        else
          echo Bad path: [$dest/$project_name] 
          exit 1;
        fi
        ;;
    esac
    shift;
done

# ensure sanity
if [ -z "$project_name" ] || [ -z "$dest" ];
  then
  help;
  exit 1;
fi

# force name to lowercase
project_name=`echo $project_name | tr [A-Z] [a-z]`;

# get the Capitalization name
cap_char=`echo $project_name | cut -b1 | tr [a-z] [A-Z]`;
first_char=`echo $project_name | cut -b1`;
cap_name=`echo $project_name | sed -e 's:^'$first_char':'$cap_char':g'`;
all_cap_name=`echo $project_name | tr [a-z] [A-Z]`;

# echo project_name: $project_name;
# echo cap_name: $cap_name;
# echo all_cap_name: $all_cap_name;
# echo dest: $dest;


#######################################
# BEGIN MAIN                          #
#######################################

target=$dest;

cp -r bootstrap $target/;
cp -r src $target/;

## see if uuidgen is on the system
which uuidgen > /dev/null 2>&1;

if [ $? -eq 0 ]; then
  uuidbin=`which uuidgen`;
  uuid=`"$uuidbin"`;
  echo using uuid: [$uuid];
else
  uuid="acb35334-d312-4fe8-bc72-4f2e6c0eb7ff";
  echo uuidgen tool not found on system;
  echo defaulting to preset [$uuid];
fi

for f in `cat $list`
  do
    file=$f;
    echo writing $file;
    sed -e's:__PROJECT_NAME__:'$project_name':g' \
    -e's:__CODENAME__:'$project_name':g' \
    -e's:__CAPNAME__:'$cap_name':g' \
    -e's:__ALLCAPNAME__:'$all_cap_name':g' \
    -e's:__YEAR__:'$year':g' \
    -e's:__UUID__:'$uuid':g' \
    $f > $target/$file;
  done

# bootstrap
bs=$target/bootstrap;
mv $bs/project_name-core-changes.patch $bs/$project_name-core-changes.patch;
mv $bs/project_name_client.mk          $bs/$project_name-client.mk

# app
app=$target/src/app;
mv $app/nsCapNameApp.cpp          $app/ns$cap_name.cpp;
mv $app/project_name.js           $app/$project_name.js;
mv $app/project_name.exe.manifest $app/$project_name.exe.manifest;
mv $app/project_name.ico          $app/$project_name.ico;

# content
content=$target/src/content;
mv $content/project_name.xul $content/$project_name.xul;

# icons
icons=$target/src/icons;
mv $icons/gtk/project_name-main16.xpm  $icons/gtk/$project_name-main16.xpm;
mv $icons/gtk/project_name.xpm         $icons/gtk/$project_name.xpm;
mv $icons/mac/project_name.icns        $icons/mac/$project_name.icns;
mv $icons/win/project_name-main.ico    $icons/win/$project_name-main.ico;

# locales
locales=$target/src/locales/en-US;
mv $locales/project_name.dtd  $locales/$project_name.dtd;

# skin
skin=$target/src/skin;
mv $skin/project_name.css $skin/$project_name.css;

# installer
inst=$target/src/installer/windows;
mv $inst/project_name.jst $inst/$project_name.jst;

rm -rf $target/bootstrap/CVS;

cd $target/src;
find . -name CVS | xargs rm -rf;

exit 0;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>