linux install script

Bruno Medeiros brunodomedeiros+spam at com.gmail
Sat Jun 23 05:25:10 PDT 2007


BCS wrote:
> I wrote a script that downloads and installs dmd on linux
> 
> here it is for whatever it's worth:
>

Let me share my install script for Windows as well. It downloads the 
latest dmd, unpacks it, copies the previous DMD version to an archive 
dir, and does a diff of the html doc. It requires MINGW/CYGWIN and tools 
like wget, grep, unzip, diff.
I could improve this script (to clean some trivial html doc differences) 
if I knew a way to do multi-line regexp substitutions. What I know of 
sed only does substitutions inside each line.

------------------------------
#!/bin/sh
# DMD install script, requires wget, grep, unzip, diff,

DMDARCHIVEDIR="dmd-archive"
DMDINSTALLDIR="."
DMDBASEURL="http://www.digitalmars.com/d"
# Use URL below for 1.0 series
#DMDBASEURL="http://www.digitalmars.com/d/1.0"

wget -nv $DMDBASEURL/changelog.html -O changelog.html

URLKEY="ftp.digitalmars.com/dmd\.[1-4].[0-9][0-9][0-9]\.zip"
DMDURL=`grep -G -o "$URLKEY" changelog.html | line -n 1`
rm changelog.html
# Uncomment the following to download a specific version
#DMDURL=ftp.digitalmars.com/dmd.1.011.zip
echo ">>" DMDURL: $DMDURL

DMDVER=`echo $DMDURL | grep -G -o "[1-4].[0-9][0-9][0-9]"`
DMDVERMAJOR=`echo $DMDVER | grep -G -o "[1-4]\\."`
DMDVERMINOR=`echo $DMDVER | grep -G -o "[0-9][0-9][0-9]"`
DMDVEROLD=`$DMDINSTALLDIR/dmd/bin/dmd | grep Compiler | sed "s/.*v//"`
echo ">>" DMDVER: $DMDVER Major: $DMDVERMAJOR Minor: $DMDVERMINOR 
DMDVEROLD: $DMDVEROLD

wget -nv http://$DMDURL -O dmd.$DMDVER.zip

# copy to the archives
mkdir -p $DMDARCHIVEDIR/dmd-$DMDVER
unzip -o -q "dmd.$DMDVER.zip" -d $DMDARCHIVEDIR/dmd-$DMDVER

# clean the old DMD, and install the new
rm -R $DMDINSTALLDIR/dmd
unzip -o -q "dmd.$DMDVER.zip" -d $DMDINSTALLDIR
rm "dmd.$DMDVER.zip"

if grep -q CYGWIN <<< `uname`; then
   echo ">>" Doing Windows fix for cygwin/mingw shells
# Do Windows fix, the linux non .exe files confuse cygwin/mingw shells
   rm $DMDINSTALLDIR/dmd/bin/dmd
   rm $DMDINSTALLDIR/dmd/bin/rdmd
   rm $DMDINSTALLDIR/dmd/bin/obj2asm
fi;

##### Diff analysis #####


DMDVERMINOR_NOZEROES=`sed -e "s/^0\+/ /" <<< $DMDVERMINOR`
# use printf to pad DMDVERMINOR-1 with zeros
# must have no trailing zeroes otherwise it's interpreted as an octal
DMDVERPREV=$DMDVERMAJOR`printf %03i $[DMDVERMINOR_NOZEROES-1]`

# Use (current_version - 1) as the old version for diff comparison
#DMDVEROLD=DMDVERPREV

echo ">>" Generating diff for $DMDVEROLD "->" $DMDVER
DOCDIRNEW=$DMDARCHIVEDIR/dmd-$DMDVER/dmd/html/d
DOCDIROLD=$DMDARCHIVEDIR/dmd-$DMDVEROLD/dmd/html/d
echo ">>" Running diff -ruN $DOCDIROLD $DOCDIRNEW
echo ">>   Output: >" "$DMDARCHIVEDIR/dmd-$DMDVEROLD-$DMDVER.diff.txt"
diff -ruN $DOCDIROLD $DOCDIRNEW > 
"$DMDARCHIVEDIR/dmd-$DMDVEROLD-$DMDVER.diff.txt"


############### Some regexp util ##################


#@@ -[0-9]*,7 \+[0-9]*,7 
@@.*\n.*\n.*\n.*\n-.*lastupdate.*\n\+.*lastupdate.*\n.*\n.*\n.*\n
#---.*\n\+\+\+.*\n---
#Index: .*\n=====.*\n---.*\n\+\+\+.*\nIndex

#@@ -[0-9]*,7 \+[0-9]*,7 @@.*\n.*\n.*\n.*\n-.*D Programming 
Language.*\n+.*D Programming Language 1.0.*\n.*\n.*\n.*\n


-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list