script to patch garnome (to avoid recompiling everything)



Attached is a sh-script which patches an existing garnome dir structure
to a new revision and downloads and compiles only files necessary for
the upgrade.
If you have a previous compiled version in ~garnome/garnome-0.15.0 untar
garnome-0.16.2 in ~garnome and run the script in ~garnome.
For example:
update-garnome garnome-0.15.0 garnome-0.16.2 desktop fifth-toe
//will patch garnome-0.15.0 to garnome-0.16.2 and build
garnome-0.15.0/meta/gnome-desktop and ... gnome-fifth-toe.

It is also possible to keep control and run every single step.
For example:

update-garnome garnome-0.15.0 garnome-0.16.2 newdiff 
//creates a new diff file and cp files from files dir creating a backup
file if the file exist

update-garnome garnome-0.15.0 garnome-0.16.2 patch 
//patches from existing diff file

update-garnome garnome-0.15.0 garnome-0.16.2 update 
//updates dir structure by rm cookies and work dirs, needs existing diff
file for files changed

update-garnome garnome-0.15.0 garnome-0.16.2 all-changed
//every thing from above plus runs make on every changed Makefile, use
with care since it's possible to link to old libs, there is no enforced
sequence 

update-garnome garnome-0.15.0 garnome-0.16.2 desktop
//first 3 [newdiff, patch, update] plus runs make in meta/gnome-desktop

The 4th - x  parameter(s) can be any meta dir or for that matter any
fully qualified dir with a Makefile in it.
Example:
update-garnome garnome-0.15.0 garnome-0.16.2 desktop fifth-toe kde
garnome-0.15.0/misc/redhat-artwork/

No 3rd parameter:
update-garnome garnome-0.15.0 garnome-0.16.2
//runs (newdiff, patch, update), so it's possible to run make as usual

Let me know if I missed something, most likely :-).

Hope this helps,
Ronald



#!/bin/bash

#remove tailing / from pathname expansion
ORG=${1%/}
NEW=${2%/}

#make sure we have two parameters
USAGE='ERROR usage: update-garnome orginal-garnome new-garname'
echo  "${ORG:?$USAGE} ${NEW:?$USAGE} " > /dev/null

RMDIRS="cookies work"
BASE=$PWD
UPDATE=update.appl
MAKEALL="NO"

#create a patch file for changed files cp with backup all files from the files dir
function newdiff() {
echo "newdiff"
rm -f $NEW.diff
for FILE in `find $NEW -name "*.mk"`
do
diff -uN ${FILE/$NEW/$ORG} $FILE >> $NEW.diff
done
for FILE in `find $NEW -name checksums`
do
diff -uN ${FILE/$NEW/$ORG} $FILE >> $NEW.diff
done
for FILE in `find $NEW -name Makefile`
do
diff -uN ${FILE/$NEW/$ORG} $FILE >> $NEW.diff
done
for FILE in `find $NEW -path '*files*' -type f -or -type l`
do
mkdir -p `dirname ${FILE/$NEW/$ORG}`
cp -ab $FILE ${FILE/$NEW/$ORG}
done
}

#patch old dir structure so we don't download all dependency files again
function patch() {
echo "patch"
if [ -f $NEW.diff ];then
 cd $ORG
 /usr/bin/patch -p1 <../$NEW.diff
 cd $BASE
fi
}


#create file for appl to update
function update() {
echo "update"
grep $ORG $NEW.diff |awk '{print $2}' > $UPDATE

#remove old dirs, [run make] 
while read FILE
do
DIR=`dirname $FILE`
FILENAME=`basename $FILE`
if [ -d $DIR ]; then
 if [ $FILENAME == "Makefile" ]; then
  cd $DIR
  if [ -d "cookies" ]; then 
    rm -rf $RMDIRS
    if [ $MAKEALL == "YES" ];then
     make
    fi
  fi
 fi
 cd $BASE
fi
done <  $UPDATE
}

function gnome-desktop() {
newdiff
patch
update
 cd $BASE
 cd $ORG/meta/gnome-desktop
  echo "Compiling desktop" 
  make
 cd $BASE
}

function gnome-meta() {
 if [ -d $ORG/meta/gnome-$1 ];then	
   cd $ORG/meta/gnome-$1
   echo "Compiling $ORG/meta/gnome-$1"
   make
 elif [ -d $ORG/meta/$1 ];then	
   cd $ORG/meta/$1
   echo "Compiling $ORG/meta/$1"
   make
 elif [ -d $1 ];then	
   cd $1
   echo "Compiling $1"
   make
 fi
 cd $BASE
}


function loop_args(){
 for META in $@
 do
 gnome-meta $META
 done
}

case "$3" in
  newdiff)
	newdiff
	;;	
  patch)
	patch
	;;
  update)
	update
	;;
  all-changed)
        MAKEALL="YES"
	newdiff
	patch
	update
	;;
  desktop)
        gnome-desktop
	shift 3
	loop_args $@
	;;
  gnome-desktop)
        gnome-desktop
	shift 3
	loop_args $@
	;;

  *)
	newdiff
	patch
	update
esac



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]