automatic source deployment using cvs history, awk, bash, ftp macros
Here is a sequence of steps to push/upload sourcefiles to an remote server.
1.) Create a base file listing with the help of the cvs history command. e.g. cvs history -c -D 2004-04-01 [–a] > filelist.txt
use -a for committed files of all users.
2.) Filelist contains lines in the following format:
What we need is:
kat3/konverter/src/java/de/ems/kat3/xml/konverter/diff/DiffTreeBuilder.java
This can be arranged with:
3.) Now its getting interesting. We want a upload for all files in our generated Filelist. We are using FTP Macros for this. In you home directory a file .netrc has to be present; heres an example:
Now in interactive ftp mode it is possible to push a file with the command
We now want to do this for all files in our filelist. the first challenge is to use ftp in a no-interactive way so that it is possible to make a script to push several files:
attend to the backslashed ftp-macro-call. Say that the code above is stored in a executable file called ftppeput.sh. You can use it now like this: ftppeput.sh kat3/src/de/ems/konverter/CComp.java.
We want to do this for several files, assume a executable script called putfiles.sh:
Execution of putfiles.sh filelist.txt now calls ftppeput.sh for each line in file filelist.txt. Thats it. Happy scripting ... .)
1.) Create a base file listing with the help of the cvs history command. e.g. cvs history -c -D 2004-04-01 [–a] > filelist.txt
use -a for committed files of all users.
2.) Filelist contains lines in the following format:
M 2004-05-03 15:34 +0000 billg 1.8 DiffTreeBuilder.java kat3/konverter/src/java/de/ems/kat3/xml/konverter/diff == remote
What we need is:
kat3/konverter/src/java/de/ems/kat3/xml/konverter/diff/DiffTreeBuilder.java
This can be arranged with:
cat filelist.txt | awk '{ print $8 "/" $7 }' > filelist2.txtA A Tagging Skript can be created using:
awk '{ print "cvs tag -c DeploymentTagName " $8 "/" $7 }'
3.) Now its getting interesting. We want a upload for all files in our generated Filelist. We are using FTP Macros for this. In you home directory a file .netrc has to be present; heres an example:
machine servername
login johndoe
password isunknown
macdef pe
rename /application/$1 /application/$1.InTest20031204
put $1 /application/$1
Now in interactive ftp mode it is possible to push a file with the command
$pe kat3/konverter/src/java/de/ems/kat3/xml/konverter/diff/DiffTreeBuilder.java
We now want to do this for all files in our filelist. the first challenge is to use ftp in a no-interactive way so that it is possible to make a script to push several files:
#! /bin/bash
ftp kat3e << EOF
\$pe $1
bye
EOF
attend to the backslashed ftp-macro-call. Say that the code above is stored in a executable file called ftppeput.sh. You can use it now like this: ftppeput.sh kat3/src/de/ems/konverter/CComp.java.
We want to do this for several files, assume a executable script called putfiles.sh:
#! /bin/bash
for files in `cat $1`
do
ftppeput.sh $files
done
Execution of putfiles.sh filelist.txt now calls ftppeput.sh for each line in file filelist.txt. Thats it. Happy scripting ... .)

0 Comments:
Kommentar veröffentlichen
<< Home