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 (12 years, 4 months ago) by petejc
Branches: MAIN
CVS tags: HEAD
fixes so script runs on OSX

    1: #!/bin/sh
    2: 
    3: # Version: MPL 1.1/GPL 2.0/LGPL 2.1
    4: #
    5: # The contents of this file are subject to the Mozilla Public License Version
    6: # 1.1 (the "License"); you may not use this file except in compliance with
    7: # the License. You may obtain a copy of the License at
    8: # http://www.mozilla.org/MPL/
    9: #
   10: # Software distributed under the License is distributed on an "AS IS" basis,
   11: # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
   12: # for the specific language governing rights and limitations under the
   13: # License.
   14: #
   15: # The Original Code is Mozdev Group, Inc.
   16: #
   17: # The Initial Developer of the Original Code is
   18: # Pete Collins for Mozdev Group Inc.
   19: # Portions created by the Initial Developer are Copyright (C) 2006
   20: # the Initial Developer. All Rights Reserved.
   21: #
   22: # Contributor(s):
   23: #
   24: # Alternatively, the contents of this file may be used under the terms of
   25: # either the GNU General Public License Version 2 or later (the "GPL"), or
   26: # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
   27: # in which case the provisions of the GPL or the LGPL are applicable instead
   28: # of those above. If you wish to allow use of your version of this file only
   29: # under the terms of either the GPL or the LGPL, and not to allow others to
   30: # use your version of this file under the terms of the MPL, indicate your
   31: # decision by deleting the provisions above and replace them with the notice
   32: # and other provisions required by the GPL or the LGPL. If you do not delete
   33: # the provisions above, a recipient may use your version of this file under
   34: # the terms of any one of the MPL, the GPL or the LGPL.
   35: #
   36: ## usage and help global vars
   37: 
   38: PROG=$0;
   39: AUTHORS="Pete Collins";
   40: AUTH_EMAIL="<pete@mozdevgroup.com>";
   41: CONTACT="<info@mozdevgroup.com>";
   42: DATE="$Date: 2007/10/08 15:29:15 $";
   43: REV="$Revision: 1.9 $";
   44: REV_NUM=`echo "\$Revision: 1.9 $" | cut -d" " -f2`;
   45: VER="0."$REV_NUM;
   46: MSG="Copyright (C) 2006, \nMozdev Group, Inc.\n";
   47: MSG=$MSG"This is free software; see the source for copying conditions.\n";
   48: MSG=$MSG"There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n";
   49: MSG=$MSG"PARTICULAR PURPOSE.\n\n";
   50: SPC="                   ";
   51: SPC2="              ";
   52: SPC1="        ";
   53: LOGGING="/dev/null";
   54: URL=http://www.mozdevgroup.com;
   55: URL_SCRIPTS=$URL/scripts;
   56: DOCS=$URL/docs/;
   57: 
   58: FTMP="/tmp/distrostubs_tmp_file.dat";
   59: year=`date  +%Y`;
   60: list=list.txt;
   61: 
   62: ## see if make is called gmake
   63: which make > /dev/null 2>&1
   64: if [ $? -eq 0 ]; then
   65:   make_bin=`which make`;
   66: else
   67:   make_bin=`which gmake`;
   68: fi
   69: 
   70: # help function
   71: help () {
   72:   echo "$0, version $VER, by $AUTHORS $AUTH_EMAIL.";
   73:   printf "$MSG";
   74:   printf "Docs: $DOCS\n";
   75:   printf "Contact: $CONTACT\n";
   76:   printf "Bugs: $BUG_URL\n";
   77:   echo
   78:   printf "Usage: $PROG [options] [projectname] [destination path]\n";
   79:   echo
   80:   printf "Options:\n";
   81:   printf "  help, -h, --help, -?, h   Print this message and exit.\n";
   82:   printf "  -V $SPC    Print version number and exit.\n";
   83:   printf "  -v $SPC    Verbose Mode.\n";
   84:   printf "  -l $SPC    Turn on Logging.\n";
   85:   printf "  -r $SPC    Remove the named project.\n";
   86:   echo
   87:   printf "For Example: \n";
   88:   echo
   89:   printf "  If I want to create a new mozilla app called 'spiderman',\n";
   90:   printf "  I would execute the command below from the top of my distrostubs\n";
   91:   printf "  source tree.\n";
   92:   echo
   93:   printf "$SPC1  $ sh $PROG spiderman path/to/target/folder\n";
   94:   echo
   95:   printf "  and then to remove it, I would execute the command below\n";
   96:   echo
   97:   printf "$SPC1  $ sh $PROG -r spiderman path/to/target/folder\n";
   98:   echo
   99: }
  100: 
  101: case "$1" in
  102:   ""|"help"|"h"|"--help"|"-?"|"-h")
  103:     help;
  104:     exit;
  105: esac
  106: 
  107: project_name=$1;
  108: 
  109: # force name to lowercase
  110: project_name=`echo $project_name | tr [A-Z] [a-z]`;
  111: 
  112: dest=$2;
  113: 
  114: ## check cmdline args
  115: while [ $# -gt 0 ]
  116:   do
  117:     case "$1" in
  118:       -h)
  119:         help;
  120:         exit; 
  121:         ;;
  122:       -v)
  123:         echo Not Implemented Yet. Sorry!;
  124:         exit 0;
  125:         ;;
  126:       -V)
  127:         echo $VER;
  128:         exit; 
  129:         ;;
  130:       -l)
  131:         echo Not Implemented Yet. Sorry!;
  132:         exit 0;
  133:         ;;
  134:       -r)
  135:         shift;
  136:         if [ -z "$1" ] || [ -z "$2" ]; then 
  137:           help;
  138:           exit 1;
  139:         fi
  140:         project_name=$1;
  141:         dest=$2;
  142:         if [ -d $dest/$project_name ]; then
  143:           ## remove project
  144:           echo removing [$dest/$project_name];
  145:           rm -rf $dest/$project_name;
  146:           echo Finished . . .;
  147:           exit 0;
  148:         else
  149:           echo Bad path: [$dest/$project_name] 
  150:           exit 1;
  151:         fi
  152:         ;;
  153:     esac
  154:     shift;
  155: done
  156: 
  157: # ensure sanity
  158: if [ -z "$project_name" ] || [ -z "$dest" ];
  159:   then
  160:   help;
  161:   exit 1;
  162: fi
  163: 
  164: # force name to lowercase
  165: project_name=`echo $project_name | tr [A-Z] [a-z]`;
  166: 
  167: # get the Capitalization name
  168: cap_char=`echo $project_name | cut -b1 | tr [a-z] [A-Z]`;
  169: first_char=`echo $project_name | cut -b1`;
  170: cap_name=`echo $project_name | sed -e 's:^'$first_char':'$cap_char':g'`;
  171: all_cap_name=`echo $project_name | tr [a-z] [A-Z]`;
  172: 
  173: # echo project_name: $project_name;
  174: # echo cap_name: $cap_name;
  175: # echo all_cap_name: $all_cap_name;
  176: # echo dest: $dest;
  177: 
  178: 
  179: #######################################
  180: # BEGIN MAIN                          #
  181: #######################################
  182: 
  183: target=$dest;
  184: 
  185: cp -r bootstrap $target/;
  186: cp -r src $target/;
  187: 
  188: ## see if uuidgen is on the system
  189: which uuidgen > /dev/null 2>&1;
  190: 
  191: if [ $? -eq 0 ]; then
  192:   uuidbin=`which uuidgen`;
  193:   uuid=`"$uuidbin"`;
  194:   echo using uuid: [$uuid];
  195: else
  196:   uuid="acb35334-d312-4fe8-bc72-4f2e6c0eb7ff";
  197:   echo uuidgen tool not found on system;
  198:   echo defaulting to preset [$uuid];
  199: fi
  200: 
  201: for f in `cat $list`
  202:   do
  203:     file=$f;
  204:     echo writing $file;
  205:     sed -e's:__PROJECT_NAME__:'$project_name':g' \
  206:     -e's:__CODENAME__:'$project_name':g' \
  207:     -e's:__CAPNAME__:'$cap_name':g' \
  208:     -e's:__ALLCAPNAME__:'$all_cap_name':g' \
  209:     -e's:__YEAR__:'$year':g' \
  210:     -e's:__UUID__:'$uuid':g' \
  211:     $f > $target/$file;
  212:   done
  213: 
  214: # bootstrap
  215: bs=$target/bootstrap;
  216: mv $bs/project_name-core-changes.patch $bs/$project_name-core-changes.patch;
  217: mv $bs/project_name_client.mk          $bs/$project_name-client.mk
  218: 
  219: # app
  220: app=$target/src/app;
  221: mv $app/nsCapNameApp.cpp          $app/ns$cap_name.cpp;
  222: mv $app/project_name.js           $app/$project_name.js;
  223: mv $app/project_name.exe.manifest $app/$project_name.exe.manifest;
  224: mv $app/project_name.ico          $app/$project_name.ico;
  225: 
  226: # content
  227: content=$target/src/content;
  228: mv $content/project_name.xul $content/$project_name.xul;
  229: 
  230: # icons
  231: icons=$target/src/icons;
  232: mv $icons/gtk/project_name-main16.xpm  $icons/gtk/$project_name-main16.xpm;
  233: mv $icons/gtk/project_name.xpm         $icons/gtk/$project_name.xpm;
  234: mv $icons/mac/project_name.icns        $icons/mac/$project_name.icns;
  235: mv $icons/win/project_name-main.ico    $icons/win/$project_name-main.ico;
  236: 
  237: # locales
  238: locales=$target/src/locales/en-US;
  239: mv $locales/project_name.dtd  $locales/$project_name.dtd;
  240: 
  241: # skin
  242: skin=$target/src/skin;
  243: mv $skin/project_name.css $skin/$project_name.css;
  244: 
  245: # installer
  246: inst=$target/src/installer/windows;
  247: mv $inst/project_name.jst $inst/$project_name.jst;
  248: 
  249: rm -rf $target/bootstrap/CVS;
  250: 
  251: cd $target/src;
  252: find . -name CVS | xargs rm -rf;
  253: 
  254: exit 0;

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