File:  [mozdev] / googlebar / CreateXPI.bat
Revision 1.7: download - view: text, annotated - select for diffs - revision graph
Fri May 7 20:11:40 2004 UTC (15 years, 7 months ago) by johnrw
Branches: MAIN
CVS tags: ver_0_9_9_01, ver_0_9_8_01, ver_0_9_7_01, ver_0_9_6_03, ver_0_9_5_06, HEAD
uses PKZip and that newfangled PKZIPC which uses = signs on the
command line! Can't use it with environment variables, as SET a=b something c=d
isn't allowed, and I could find no escape on the dang thing. It works. I'll clean
it up later. Or remove it from project, as zip should be done with unixes, until
moz fixes the mangled permissions whern unpacking on unixes.

@echo off
cls
rem ##############################################
rem # Helper script to create googlebar installers
rem # You need the following tools in you PATH:
rem # cvs
rem # pkzip, pkzipc
rem #(I have tested this with pkz commandline 4.x)
rem ##############################################

rem setlocal, nice but not universal enuff

rem ##############################################
rem # no options given == don't parse commandline
rem ##############################################
if "%1"=="" goto help

rem ##############################################
rem # help options
rem ##############################################
if "%1"==""    goto help
if "%1"=="/?"  goto help
if "%1"=="/h"  goto help
if "%1"=="-h"  goto help
if "%1"=="--h" goto help


rem ##############################################
rem # This Section test the available environment
rem # space. You would think they would have come
rem # up w/an easy way like a getenv eg ERRORLEVEL 
rem # eg. SET gt somefile.txt, dir somefile.txt
rem # shows the used amount.
rem ##############################################


set xpi=
set update=
set zip=
set defaults=
set ZIPOPTS=
set ZIPINCLUDE=
set ZIPEXCLUDE=
set envtest=;
set result=
set IGNOREFILE=
set LISTCREATEPARM=
set LISTUSEPARM=

rem reset any lingering errorlevel before we were run.
attrib *.* > nul


rem Test for 287 bytes free in the env
set a=0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999
set b=0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
set c=****************************************************************************************

if errorlevel 1 goto ONE
:ZERO
echo Environmment space OK!
goto END_1
:ONE
echo Aborting: OUT of Environmment space!

:END_1
if errorlevel 0 if not errorlevel 1 goto envpass
set a=
set b=
set c=
goto notenuoughenv
:envpass
set a=
set b=
set c=
set envtest=ok
rem ##############################################
rem # End of Environment space test
rem ##############################################


rem ##############################################
rem # default values
rem ##############################################
set xpi=XPI-rimental.xpi
set update=NO
set zip=pkzip
set defaults=NO
set ZIPOPTS=-rp
set ZIPINCLUDE=*.*
set ZIPEXCLUDE=ZIPXLIST
set IGNOREFILE=cvs ZIPXLIST Entries Repository Root Template Entries.Extra Entries.Extra.Old Entries.Old
set LISTCREATEPARM=-@
set LISTUSEPARM=-x@


rem ##############################################
rem # parse commandline
rem ##############################################
:parse
if "%1"=="/d" set defaults=YES
if "%1"=="/v" set xpi=%2.xpi
if "%1"=="/u" set update=YES
if "%1"=="/zip" set zip=%2
if "%1"=="-d" set defaults=YES
if "%1"=="-v" set xpi=%2.xpi
if "%1"=="-u" set update=YES
if "%1"=="-zip" set zip=%2

if "%1"=="/D" set defaults=YES
if "%1"=="/V" set xpi=%2.xpi
if "%1"=="/U" set update=YES
if "%1"=="/ZIP" set zip=%2
if "%1"=="-D" set defaults=YES
if "%1"=="-V" set xpi=%2.xpi
if "%1"=="-U" set update=YES
if "%1"=="-ZIP" set zip=%2

shift
if not "%1"=="" goto parse

if "%zip%"=="%PKZIP%" set zip=pkzip
if "%zip%"=="%PKZIPC%" set zip=pkzipc



rem ##############################################
rem here you can use the good old archive bit to 
rem tell zip not to get cvs files
goto skipattr
set ZIPOPTS=-rp -i
set ZIPINCLUDE=*.*

attrib *.* +a /s
attrib Entries -a /s
attrib Repository -a /s
attrib Root -a /s
attrib Template -a /s
attrib Entries.Extra -a /s
attrib Entries.Extra.Old -a /s
attrib Entries.Old -a /s

echo %zip% %ZIPOPTS% %ZIPINCLUDE% %xpi%
rem ##############################################
:skipattr


rem ##############################################
rem # Generate an exclude listfile ZIPXLIST
rem # of files we don't want, into ZIPXLIST
rem ##############################################
rem pkzip -rp -@ZIPXLIST %IGNOREFILE%
rem pkzipc -add -dir -listfile=ZIPXLIST %IGNOREFILE%

if "%zip%"=="pkzip"  set ZIPOPTS=-rp
if "%zip%"=="pkzipc" set ZIPOPTS=-add -dir

cd googlebar
if "%zip%"=="pkzipc" set LISTCREATEPARM=-listfile

if "%zip%"=="pkzip"  %zip% %ZIPOPTS% %LISTCREATEPARM%%ZIPEXCLUDE% %IGNOREFILE%
if "%zip%"=="pkzipc" %zip% %ZIPOPTS% %LISTCREATEPARM%=%ZIPEXCLUDE% %IGNOREFILE%
cd..
pause


:skipopts
rem ##############################################

:noparse
cd googlebar
if not "%update%"=="YES" goto noupdate 

rem ##############################################
rem # get latest cvs version
rem ##############################################
echo Updating from cvs
cvs update -dP

:noupdate
rem ##############################################
rem # create installer
rem ##############################################
echo.
echo ... creating %xpi%

if exist %xpi% del %xpi% >nul

rem #############################################
rem # fix case of en-us directory, it may emit a harmless error
cd googlebar\locale
ren en-us en-US
cd ..\..

rem ##############################################
rem # do the Deed
rem # zip everything excluding CVS directories
rem ##############################################

if "%zip%"=="pkzipc" set LISTUSEPARM=-exclude
if "%zip%"=="pkzipc" set ZIPOPTS=-add -dir -nozipextension

if "%zip%"=="pkzip" %zip% %ZIPOPTS% %xpi% %LISTUSEPARM%%ZIPEXCLUDE% >NUL
if "%zip%"=="pkzipc" %zip% %ZIPOPTS% %xpi% %LISTUSEPARM%=@%ZIPEXCLUDE% >NUL

del ZIPXLIST >NUL

rem ##############################################
rem # move installer to downloads
rem ##############################################
echo ... copying installer
if exist %xpi%.zip goto fixupext
goto nofixup
:fixupext
echo Stripping/Fixing pkzip .zip extension addon
if exist %xpi% del %xpi%
ren %xpi%.zip %xpi%
:nofixup

if exist %xpi% copy /b /y %xpi% ..\downloads\%xpi%

find "PK" %xpi% >nul
echo.
if ERRORLEVEL 1 goto FIND_ONE

:FIND_ZERO
set RESULT=Was
goto END_FIND
:FIND_ONE
set RESULT=Was Not
:END_FIND


echo ... cleaning up
if exist %xpi% del %xpi%

cd ..
echo ... done!
echo.
echo %xpi% %RESULT% copied to the downloads directory.


goto done

:help
echo.
echo Usage: %0 [/d] [/u] [/v versionString] [/zip ZipToolToUse]
echo.
echo.
echo        /d                 Use defaults, noupdate, XPI-rimental.xpi, pkzip.exe
echo. 
echo        /u                 update from cvs before packing
echo.
echo        /v versionString   create XPI named versionString.xpi
echo.
echo                           default is XPI-rimental.xpi
echo                           example: c:\googlebarSource\>CreateXPI /v: 9.0.0.0
echo.
echo        /zip               name of zip tool to use, default is pkzip
echo                           example: c:\googlebarSource\>CreateXPI /zip pkzipc
echo.
goto done

:notenuoughenv
echo the DOS environment space is too small.
echo To remedy this problem permanently:
echo add the next line to your c:\config.sys
echo SHELL=C:\WINDOWS\COMMAND.COM /E:4096 /P
echo.
echo Or if you are in a Windows DOS session
echo select the window control menu.
echo Select Properties - Memory - Initial Environment
echo A setting of "Auto" should be changed to 4096.
echo Then start another DOS session, the same way you did before.
echo This work, but it didn't give me 4096!

del ZIPXLIST>NUL


:done
echo bye!
set xpi=
set update=
set zip=
set defaults=
set ZIPOPTS=
set ZIPINCLUDE=
set ZIPEXCLUDE=
set IGNOREFILE=
set envtest=
set result=
set LISTUSEPARM=
set LISTCREATEPARM=


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