![kueller](/assets/img/avatar_default.png)
falscher Variablen benamsung, FG=; wurde gar nicht eingefügt git-svn-id: svn://svn.compuextreme.de/Viitor/V962/ViitorMake@5397 504e572c-2e33-0410-9681-be2bf7408885
799 lines
19 KiB
Bash
799 lines
19 KiB
Bash
#!/bin/bash
|
|
#Framework, welches ein komplettes Linux System aus den Sourcen erstellt
|
|
#dieses Framework wird im CVS Repository
|
|
#:pserver:cvs.tramp-bbs.de:/opt/cvs zur Verfügung gestellt
|
|
#
|
|
#Lage dieser Datei im Archiv: $HeadURL$
|
|
#
|
|
#(c) 2007 Harald Kueller, Germany
|
|
#This program is free software; you can redistribute it and/or
|
|
#modify ist under the terms of the GNU General Public License
|
|
#as published by the Free Software Foundation; either version
|
|
#2 of the License, or (at your option) any later version.
|
|
#
|
|
#This program is distributed in the hope that it will be useful,
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
#See the GNU General Public License for more details.
|
|
#
|
|
#You should have received a copy of the GNU General Public License
|
|
#along with this program; if not write to the Free Software Foundation,
|
|
#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
#
|
|
#Beschreibung:
|
|
#Funktionssammlung für genpkg script des ViitorMake Frameworks
|
|
#
|
|
#checkError():
|
|
#Beschreibung: Ueberpruefen des zuletzt gelaufenen Befehls. Bei Erfolgreicher
|
|
# Beendigung des Befehls wir keine Aktion vorgenommen.
|
|
# Ansonsten Ausgabe der Fehlermeldung <MESSAGE>, Aufräumen mit
|
|
# cleanup Funktion, und Beenden des Scriptes
|
|
#Argumente: MESSAGE
|
|
#MESSAGE : Auszugebene Fehlermeldung
|
|
#
|
|
#
|
|
#CleanUp():
|
|
#Beschreibung: Aufräumen des Systemes nach Erstellung eines Packetes, oder
|
|
#bei Abbruch des genpkg scriptes
|
|
#
|
|
#Argumente: Keine
|
|
#Steuervariablen: Diese Variablen muessen zum Aufrufzeitpunkt gesetzt sein
|
|
# und haben folgende Bedeutung:
|
|
#CLEANUP_FLAGS : 1=MAKEDIR aufräumen
|
|
# 2=TMPROOT aufräumen
|
|
#PROGNAME : Name des Programmpacketes, welches gerade
|
|
# erstellt wurde
|
|
#TMPROOT : Verzeichniss in welchem die binär
|
|
# Dateien zur Erstellung von Packeten
|
|
# erstellt werden.
|
|
#MAKEDIR : Verzeichniss in welchem die Sourcen
|
|
# Entpackt und Übersetzt werden
|
|
#
|
|
#
|
|
#GetSuffix()
|
|
#
|
|
#Beschreibung : Ermittlung des Datei Suffixes. Datei Suffix wird auf
|
|
# : stdout ausgegeben
|
|
#
|
|
#Argumente : FILENAME
|
|
#FILENAME : Name des Files, von welchem der Datei Suffix ermittelt
|
|
# : werden soll
|
|
#
|
|
#
|
|
#SrcPatch()
|
|
#Beschreibung : Anwenden eines Patches auf ein Verzeichniss (Recursiv)
|
|
#Argumente : DSTPATH, PATCHFILE
|
|
#DSTPATH : Verzeichniss in welchem der Patch angewendet werden soll
|
|
#PATCHFILE : Patchdatei die verwendet werden soll (nicht, gzip oder bzip2
|
|
# : comprimiert)
|
|
#
|
|
#UnPack()
|
|
#Beschreibung : Entpacken von tar Archiven. Dabei wird automatisch erkannt
|
|
# ob die Archive gzip, bzip2 oder gar nicht comprimiert sind
|
|
# und die entsprechend notwendigen Tar Optionen ermittelt
|
|
#Argumente : DSTPATH; FILENAME
|
|
#DSTPATH : Zielverzeichniss, in welchem das Archiv <FILENAME> entpackt
|
|
# werden soll.
|
|
#FILENAME : Dateiname des Archives welches nach <DSTPATH> entpackt werden
|
|
# soll
|
|
#
|
|
#ArchiveName()
|
|
#Beschreibung : Generiert den pkgname aus den Namen eines source Archives
|
|
# Der pkgname wird auf stdout ausgegeben
|
|
#Argumente : $FILENAME
|
|
#FILENAME : Name des SOURCE Archives
|
|
#
|
|
#
|
|
#GetSVN()
|
|
#Beschreibung : Einspielen eines SVN Projectes (Add On zu erstellten pkgs)
|
|
# in den pkgtree
|
|
#Steuervariablen: SVNURL
|
|
#CVSROOT : Angabe des Repositorys in welchem das Project zu finden ist
|
|
#
|
|
#Argumente : CVSPROJ, PKGROOT
|
|
#CVSPROJ : Name eines Projectes
|
|
#PKGROOT : Zielverzeichniss, in welchem das pkg entpackt vorliegt
|
|
#
|
|
#Argumente : CVSPROJ, PKGROOT
|
|
#CVSPROJ : Name eines Projectes
|
|
#PKGROOT : Zielverzeichniss, in welchem das pkg entpackt vorliegt
|
|
#
|
|
#
|
|
#GenDependics()
|
|
#Beschreibung : Abhängigkeiten zu anderen Programmpacketen ermitteln
|
|
# mit ldd werden sämtliche executable Dateien eines
|
|
# PKGROOT Verzeichnisses auf Abhängigkeiten untersucht. Aus
|
|
# Anhand der Ermittelten Dateien wird mittels der Filelisten
|
|
# unter /var/install ermittelt welche Packete diese Dateien
|
|
# enthalten, und so eine liste der Packete von welchen
|
|
# die files unter PKGROOT abhängig sind, erstellt.
|
|
#Argumente : PKGROOT
|
|
#PKGROOT : Verzeichniss in welchem die Abhängigkeiten ermittelt werden
|
|
# sollen
|
|
#
|
|
#StripPkg()
|
|
#Beschreibung : Entfernt unnötigen debugging overhead aus frisch übersetzten
|
|
# binarys. Die Funktion wirkt auf alle in einem Verzeichniss
|
|
# befindlichen executable files.
|
|
#Argumente : PKGPATH
|
|
#PKGPATH Verzeichniss in welchem die Binarys "gestript" werden sollen
|
|
#
|
|
#GetFlags()
|
|
#Beschreibung : rechnet einen ASCI Rechte String (drwsrwsrwt) in die
|
|
# entsprechende 4 stellige Octalziffer um
|
|
#Argumente : Rechte String in ASCII
|
|
#
|
|
#Letzte Änderung von: $Author$
|
|
#Datum der letzten Änderung: $Date$
|
|
#Version der Datei: $Revision$
|
|
#
|
|
#
|
|
|
|
CheckError() {
|
|
MESSAGE=$1
|
|
|
|
if [ ! "$?" == 0 ]; then
|
|
echo $MESSAGE
|
|
CleanUp
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
CleanUp() {
|
|
(( TESTFLAG = $CLEANUP_FLAGS & 1 ))
|
|
if [ ! "$TESTFLAG" == "0" ]; then
|
|
rm -rf $MAKEDIR/$SRCDIR*
|
|
fi
|
|
(( TESTFLAG = $CLEANUP_FLAGS & 2 ))
|
|
if [ ! "$TESTFLAG" == "0" ]; then
|
|
rm -rf $TMPROOT
|
|
if [ -d "$MANTMPROOT" ]; then
|
|
rm -rf $MANTMPROOT
|
|
fi
|
|
if [ -d "$DEVTMPROOT" ]; then
|
|
rm -rf $DEVTMPROOT
|
|
fi
|
|
fi
|
|
(( TESTFLAG = $CLEANUP_FLAGS & 4 ))
|
|
if [ ! "$TESTFLAG" == "0" ]; then
|
|
InstallOldKernelh 0
|
|
fi
|
|
(( TESTFLAG = $CLEANUP_FLAGS & 8 ))
|
|
if [ ! "$TESTFLAG" == "0" ]; then
|
|
UseOldGcc 0
|
|
fi
|
|
(( TESTFLAG = $CLEANUP_FLAGS & 16 ))
|
|
if [ ! "$TESTFLAG" == "0" ]; then
|
|
rm -f /usr/X11R6
|
|
fi
|
|
(( TESTFLAG = $CLEANUP_FLAGS & 32 ))
|
|
if [ ! "$TESTFLAG" == "0" ]; then
|
|
Fix_Input_h 0
|
|
fi
|
|
(( TESTFLAG = $CLEANUP_FLAGS & 64 ))
|
|
if [ ! "$TESTFLAG" == "0" ]; then
|
|
PKG_CONFIG_PATH=$STOREPKG_CONFIG_PATH
|
|
fi
|
|
if [ -d /usr/include/linux.orig ]; then
|
|
rm -f /usr/include/linux
|
|
mv /usr/include/linux.orig /usr/include/linux
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
GetSuffix() {
|
|
FILENAME=$1
|
|
|
|
echo $1|awk -F. '{ print $NF }'
|
|
}
|
|
|
|
SrcPatch() {
|
|
DSTPATH=$1
|
|
PATCHFILE=$2
|
|
|
|
cd $DSTPATH
|
|
SUFFIX=`GetSuffix $PATCHFILE`
|
|
PATCHNAME=`echo $PATCHFILE|sed -e "s/\.$SUFFIX.*$//"`
|
|
case $SUFFIX in
|
|
gz)
|
|
gzip -d $PATCHFILE
|
|
CheckError "Could not ungzip $PATCHFILE"
|
|
;;
|
|
bz2)
|
|
bzip2 -d $PATCHFILE
|
|
CheckError "Could not unbzip2 $PATCHFILE"
|
|
;;
|
|
*)
|
|
PATCHNAME=$PATCHFILE
|
|
SUFFIX=bzip2
|
|
;;
|
|
esac
|
|
patch -Np1 -i $PATCHNAME
|
|
CheckError "Patch $PATCHNAME failed"
|
|
case $SUFFIX in
|
|
gz)
|
|
gzip $PATCHNAME
|
|
CheckError "Compression of $PATCHNAME with gzip failed"
|
|
;;
|
|
bz2)
|
|
bzip2 $PATCHNAME
|
|
CheckError "Compression of $PATCHNAME with bzip2 failed"
|
|
;;
|
|
esac
|
|
cd -
|
|
}
|
|
|
|
UnPack() {
|
|
DSTPATH=$1
|
|
FILENAME=$2
|
|
|
|
SUFFIX=`GetSuffix $FILENAME`
|
|
if [ "$SUFFIX" ]; then
|
|
case "$SUFFIX" in
|
|
gz|tgz|Z)
|
|
TAROPTS="zxvf"
|
|
;;
|
|
bz2|tbz)
|
|
if ( tar --version|grep 1.13.25 >/dev/null 2>&1 ); then
|
|
TAROPTS="jxvf"
|
|
else
|
|
TAROPTS="jxvf"
|
|
fi
|
|
;;
|
|
tar)
|
|
TAROPTS="xvf"
|
|
;;
|
|
*)
|
|
echo "Unknown Suffix for unpack()"
|
|
return 1
|
|
;;
|
|
esac
|
|
cd $DSTPATH
|
|
tar $TAROPTS $FILENAME
|
|
CheckError "Unpack of $FILENAME failed"
|
|
cd - >/dev/null
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
ArchiveName() {
|
|
FILENAME=$1
|
|
if [ "$2" == "1" ]; then
|
|
FLAG=$2
|
|
else
|
|
FLAG=""
|
|
fi
|
|
|
|
SUFFIX=`GetSuffix $FILENAME`
|
|
BASENAME=`echo $FILENAME|sed -e "s/\.$SUFFIX.*$//"`
|
|
SUFFIX=`GetSuffix $BASENAME`
|
|
if [ "$SUFFIX" == "tar" ]; then
|
|
BASENAME=`echo $BASENAME|sed -e "s/\.$SUFFIX.*$//"`
|
|
fi
|
|
BASENAME=`basename $BASENAME`
|
|
if [ ! "$FLAG" == "1" ]; then
|
|
ARCHIVENAME=`echo $BASENAME|sed -e "s/src/bin/"|sed -e "s/SRC/BIN/"| \
|
|
sed -e "s/source/binary/"|sed -e "s/SOURCE/BINARY/"`
|
|
else
|
|
ARCHIVENAME=$BASENAME
|
|
fi
|
|
echo $ARCHIVENAME.vpg
|
|
}
|
|
|
|
GetSVN() {
|
|
CDIR=`pwd`
|
|
SVNPROJ=$1
|
|
PKGROOT=$2
|
|
|
|
export ADDONPROJEKT=$1
|
|
mkdir /tmp/svntmp$$
|
|
cd /tmp/svntmp$$
|
|
if [ "$CVSASK" ]; then
|
|
echo "Zugriff auf $SVNURL wird benötigt"
|
|
echo "Bitte Internetverbindung herstellen"
|
|
echo "und beliebige Taste drücken"
|
|
read
|
|
fi
|
|
svn co $SVNURL/$SVNPROJ
|
|
cd $SVNPROJ
|
|
ADDONVERSION=`svn info .|grep Revision|awk '{print $2}'`
|
|
find . -name ".svn" -type d -exec rm -rf {} \;
|
|
for i in `find . -type d`; do
|
|
case $i in
|
|
./etc)
|
|
chmod 644 `find etc -type f`
|
|
;;
|
|
./etc/init.d)
|
|
chmod 755 `find etc/init.d -type f`
|
|
;;
|
|
./etc/sysconfig)
|
|
chmod 644 `find etc/sysconfig -type f`
|
|
;;
|
|
./etc/sysconfig/profile.d)
|
|
chmod 755 `find etc/sysconfig/profile.d -type f`
|
|
;;
|
|
./locale)
|
|
for i in locale/*; do
|
|
BASE=`basename $i|cut -d "." -f 1`
|
|
CO=`basename $i|cut -d "." -f 3`
|
|
DSTDIR=$PKGROOT/usr/share/locale/$CO/LC_MESSAGES
|
|
if [ ! -d $DSTDIR ]; then
|
|
mkdir -p $DSTDIR
|
|
fi
|
|
msgfmt $i -o $DSTDIR/$BASE.mo
|
|
done
|
|
rm -rf locale
|
|
;;
|
|
esac
|
|
done
|
|
if [ -f init/genpkg ]; then
|
|
source init/genpkg
|
|
rm -rf init
|
|
fi
|
|
cp -rp * $PKGROOT
|
|
cd $CDIR
|
|
rm -rf /tmp/svntmp$$
|
|
}
|
|
|
|
GenDependics() {
|
|
PKGROOT=$1
|
|
|
|
cd $PKGROOT
|
|
if [ -f /tmp/lddlist$$ ]; then
|
|
rm -f /tmp/lddlist$$
|
|
fi
|
|
for execfile in `find $PKGROOT -type f ! -type l -perm -u+rx,g+rx`; do
|
|
if file $execfile |grep "LSB executable" &>/dev/null; then
|
|
ldd $execfile|\
|
|
sed -e "/not a dynamic/d"|\
|
|
awk '{print $1}'
|
|
elif file $execfile|grep "LSB shared object" &>/dev/null; then
|
|
ldd $execfile|\
|
|
sed -e "/not a dynamic/d"|\
|
|
awk '{print $1}'
|
|
fi
|
|
done |sort -u >/tmp/lddlist$$
|
|
if [ -f /tmp/lddlist$$ ]; then
|
|
for i in `cat /tmp/lddlist$$`; do
|
|
grep "$i;" $ROOT/var/install/contents|awk -F";" '{print $1}'|sed -e "s/PN=//"
|
|
done|sort -u
|
|
rm -f /tmp/lddlist$$
|
|
fi
|
|
cd - >/dev/null
|
|
}
|
|
|
|
StripPkg() {
|
|
PKGROOT=$1
|
|
|
|
cd $PKGROOT
|
|
for checkfile in `find . -perm -1 -type f `; do
|
|
if file $checkfile|grep "LSB executable" &>/dev/null; then
|
|
strip --strip-all $checkfile
|
|
elif file $checkfile|grep "LSB shared object" &>/dev/null; then
|
|
strip $checkfile
|
|
fi
|
|
done
|
|
cd -
|
|
}
|
|
|
|
ClearHostSysNameing32() {
|
|
DESTDIR=$1
|
|
|
|
CURDIR=`pwd`
|
|
cd $DESTDIR
|
|
for i in `find . -name "$TARGET32*"`; do
|
|
NEWNAME=`basename $i`
|
|
PATHNAME=`dirname $i`
|
|
NEWNAME=`echo $NEWNAME|sed -e "s/$TARGET32-//"`
|
|
mv $i $PATHNAME/$NEWNAME
|
|
done
|
|
find . -type l -ls|grep $TARGET32 >/tmp/linklist$$
|
|
exec 3</tmp/linklist$$
|
|
read <&3 LINE
|
|
while [ "$LINE" ]; do
|
|
LINKTO=`echo $LINE|awk '{print $13}'|sed -e "s/$TARGET32-//"`
|
|
LINKFROM=`echo $LINE|awk '{print $11}'`
|
|
FILELINK=`basename $LINKFROM`
|
|
DIRLINK=`dirname $LINKFROM`
|
|
cd $DIRLINK
|
|
rm -f $FILELINK
|
|
ln -s $LINKTO $FILELINK
|
|
cd -
|
|
read <&3 LINE
|
|
done
|
|
exec 3>&-
|
|
rm -f /tmp/linklist$$
|
|
for i in `find . -type l -ls|grep $HOSTSYS`; do
|
|
LINTO=`echo $i|awk '{print $10}'`
|
|
echo $LINTO
|
|
done
|
|
cd $CURDIR
|
|
}
|
|
|
|
ClearHostSysNameing() {
|
|
DESTDIR=$1
|
|
|
|
CURDIR=`pwd`
|
|
cd $DESTDIR
|
|
for i in `find . -name "$TARGET*"`; do
|
|
NEWNAME=`basename $i`
|
|
PATHNAME=`dirname $i`
|
|
NEWNAME=`echo $NEWNAME|sed -e "s/$TARGET-//"`
|
|
mv $i $PATHNAME/$NEWNAME
|
|
done
|
|
find . -type l -ls|grep $TARGET >/tmp/linklist$$
|
|
exec 3</tmp/linklist$$
|
|
read <&3 LINE
|
|
while [ "$LINE" ]; do
|
|
LINKTO=`echo $LINE|awk '{print $13}'|sed -e "s/$TARGET-//"`
|
|
LINKFROM=`echo $LINE|awk '{print $11}'`
|
|
FILELINK=`basename $LINKFROM`
|
|
DIRLINK=`dirname $LINKFROM`
|
|
cd $DIRLINK
|
|
rm -f $FILELINK
|
|
ln -s $LINKTO $FILELINK
|
|
cd -
|
|
read <&3 LINE
|
|
done
|
|
exec 3>&-
|
|
rm -f /tmp/linklist$$
|
|
for i in `find . -type l -ls|grep $HOSTSYS`; do
|
|
LINTO=`echo $i|awk '{print $10}'`
|
|
echo $LINTO
|
|
done
|
|
cd $CURDIR
|
|
}
|
|
|
|
MakeCheck() {
|
|
if [ "$CHECK" == "true" ]; then
|
|
make $*
|
|
fi
|
|
}
|
|
|
|
|
|
RestoreOpt() {
|
|
CFLAGS=$STCFLAGS
|
|
STCXXFLAGS=$CXXFLAGS
|
|
unset STCFLAGS STCXXFLAGS
|
|
}
|
|
|
|
CleanTextFiles() {
|
|
cd $TMPROOT
|
|
for i in `find . -type f`; do
|
|
sed -i -e "s%$TMPROOT%%" $i
|
|
done
|
|
cd -
|
|
}
|
|
|
|
CheckFlag() {
|
|
FLAG=$1
|
|
CHECK=$2
|
|
|
|
(( CHECKFLAG = $FLAG & $CHECK ))
|
|
if [ $CHECKFLAG == 0 ]; then
|
|
return 1
|
|
else
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
GetFlags() {
|
|
RightString=$1
|
|
ReadBit[1]=`echo $1|cut -c2`
|
|
WriteBit[1]=`echo $1|cut -c3`
|
|
ExecBit[1]=`echo $1|cut -c4`
|
|
ReadBit[2]=`echo $1|cut -c5`
|
|
WriteBit[2]=`echo $1|cut -c6`
|
|
ExecBit[2]=`echo $1|cut -c7`
|
|
ReadBit[3]=`echo $1|cut -c8`
|
|
WriteBit[3]=`echo $1|cut -c9`
|
|
ExecBit[3]=`echo $1|cut -c10`
|
|
unset SetUID
|
|
for i in 1 2; do
|
|
if [ "${ExecBit[$i]}" == "s" ]; then
|
|
SetUID[$i]=1
|
|
ExecBit[$i]="x"
|
|
fi
|
|
if [ "${ExecBit[$i]}" == "S" ]; then
|
|
SetUID[$i]=1
|
|
ExecBit[$i]="-"
|
|
fi
|
|
done
|
|
if [ "${ExecBit[3]}" == "t" ]; then
|
|
SetUID[3]=1
|
|
ExecBit[3]="x"
|
|
fi
|
|
if [ "${ExecBit[3]}" == "T" ]; then
|
|
SetUID[3]=1
|
|
ExecBit[3]="-"
|
|
fi
|
|
NumSUID=0
|
|
AddSUID=1
|
|
for i in 3 2 1; do
|
|
if [ "${SetUID[$i]}" == "1" ]; then
|
|
(( NumSUID = $NumSUID + $AddSUID ))
|
|
fi
|
|
(( AddSUID = $AddSUID + $AddSUID ))
|
|
done
|
|
NumUID=`Asc2Oct ${ReadBit[1]} ${WriteBit[1]} ${ExecBit[1]}`
|
|
NumGID=`Asc2Oct ${ReadBit[2]} ${WriteBit[2]} ${ExecBit[2]}`
|
|
NumOTH=`Asc2Oct ${ReadBit[3]} ${WriteBit[3]} ${ExecBit[3]}`
|
|
echo "$NumSUID$NumUID$NumGID$NumOTH"
|
|
}
|
|
|
|
Asc2Oct() {
|
|
ReadBit=$1
|
|
WriteBit=$2
|
|
ExecBit=$3
|
|
NumRight=0
|
|
|
|
if [ "$ExecBit" == "x" ]; then
|
|
(( NumRight = $NumRight + 1 ))
|
|
fi
|
|
if [ "$WriteBit" == "w" ]; then
|
|
(( NumRight = $NumRight + 2 ))
|
|
fi
|
|
if [ "$ReadBit" == "r" ]; then
|
|
(( NumRight = NumRight + 4 ))
|
|
fi
|
|
echo $NumRight
|
|
}
|
|
|
|
MakeMgtFiles() {
|
|
FilePrefix=$1
|
|
TMPFILE=`mktemp`
|
|
PKGNAME=`echo $PKGNAME|sed -e "s/\.vpg$//"`
|
|
if [ "$SHORTNAME" ]; then
|
|
SHNAME=$SHORTNAME
|
|
else
|
|
SHNAME=`basename $MODULENAME`
|
|
if [ "$NoRewriteName" == "true" ]; then
|
|
SHNAME=`basename $MODULENAME`
|
|
else
|
|
SHNAME=`basename $MODULENAME|\
|
|
sed -e "s/src/bin/" |\
|
|
sed -e "s/SRC/BIN/" |\
|
|
sed -e "s/SOURCE/BINARY/" |\
|
|
sed -e "s/source/binary/" `
|
|
fi
|
|
fi
|
|
find . -type d -ls|\
|
|
awk '{ if ( $11 != "." ) print $3,$5,$6,$11 }' |\
|
|
sed -e "s/\.\//\//" >$TMPFILE
|
|
exec 3<$TMPFILE
|
|
while read <&3 RIGHTS USERID GROUPID NAME; do
|
|
echo "$NAME `GetFlags $RIGHTS` $USERID $GROUPID"
|
|
done >$TMPROOT/../$$/$FilePrefix.drg
|
|
exec 3>&-
|
|
rm -f $TMPFILE
|
|
find . ! -type d -ls|\
|
|
awk '{ print $3,$5,$6,$11 }'|\
|
|
sed -e "s/\.\//\//" >$TMPFILE
|
|
exec 3<$TMPFILE
|
|
while read <&3 RIGHTS USERID GROUPID NAME; do
|
|
TYPE=`echo $RIGHTS|cut -c1`
|
|
RIGHT=`echo $RIGHTS|GetFlags $RIGHTS`
|
|
if [ -f .$NAME ] && [ ! -h .$NAME ]; then
|
|
MDSUM=`md5sum .$NAME|cut -d" " -f1`
|
|
else
|
|
MDSUM=""
|
|
fi
|
|
case $TYPE in
|
|
"-")
|
|
FILETYPE="File"
|
|
;;
|
|
"l")
|
|
FILETYPE="Link"
|
|
;;
|
|
"d")
|
|
FILETYPE="Dir"
|
|
;;
|
|
"s")
|
|
FILETYPE="Socket"
|
|
;;
|
|
"c")
|
|
FILETYPE="DeviceC"
|
|
;;
|
|
"b")
|
|
FILETYPE="DeviceB"
|
|
;;
|
|
"p")
|
|
FILETYPE="Pipe"
|
|
;;
|
|
*)
|
|
FILETYPE="Unknown"
|
|
;;
|
|
esac
|
|
echo "PN=$SHNAME;FN=$NAME;FT=$FILETYPE;FR=$RIGHT;FO=$USERID;FG=$GROUPID;FS=$MDSUM;PK=$PKGNAME"
|
|
done >$TMPROOT/../$$/$FilePrefix.cont
|
|
exec 3>&-
|
|
rm -f $TMPFILE
|
|
}
|
|
|
|
X11R7_Fix() {
|
|
(( CLEANUP_FLAGS = $CLEANUP_FLAGS | 16 ))
|
|
cd /usr
|
|
ln -s X11R7 X11R6
|
|
cd -
|
|
}
|
|
|
|
SetConfig() {
|
|
SELECT=$1
|
|
|
|
case $SELECT in
|
|
32)
|
|
(( CLEANUP_FLAGS = $CLEANUP_FLAGS | 64 ))
|
|
STOREPKG_CONFIG_PATH=$PKG_CONFIG_PATH
|
|
PKG_CONFIG_PATH=`echo $STOREPKG_CONFIG_PATH|sed "s/lib64/lib/g"`
|
|
UARCH=32
|
|
LIBDIR=lib
|
|
;;
|
|
64)
|
|
(( CLEANUP_FLAGS = $CLEANUP_FLAGS | 64 ))
|
|
STOREPKG_CONFIG_PATH=$PKG_CONFIG_PATH
|
|
PKG_CONFIG_PATH=`echo $STOREPKG_CONFIG_PATH|sed "s/lib/lib64/g"`
|
|
UARCH=64
|
|
LIBDIR=lib64
|
|
;;
|
|
*)
|
|
PKG_CONFIG_PATH=$STOREPKG_CONFIG_PATH
|
|
;;
|
|
esac
|
|
}
|
|
|
|
MakeFifo() {
|
|
TMPFILE=`mktemp`
|
|
rm -f $TMPFILE
|
|
mkfifo --mode=600 $TMPFILE
|
|
echo $TMPFILE
|
|
return 0
|
|
}
|
|
|
|
ExecCommand() {
|
|
CMDNUM=$1
|
|
echo "$CMDNUM" >&8
|
|
while true; do
|
|
COMMAND=`cat ${CMDF[${CMDNUM}]}`
|
|
IFS=";"
|
|
for i in `echo $COMMAND|awk -F" && " '{print $1";"$2";"$3";"$4";"$5";"$6 }'`; do
|
|
unset IFS
|
|
if [[ "$i" == *wshutdown* ]]; then
|
|
rm -f ${CMDF[${CMDNUM}]}
|
|
return 0
|
|
fi
|
|
$i
|
|
IFS=";"
|
|
done
|
|
echo "$CMDNUM" >&8
|
|
done
|
|
}
|
|
|
|
InitDispatch() {
|
|
FREEF=`MakeFifo`
|
|
exec 8<>$FREEF
|
|
EXECPROCNUM=$NUMCPU
|
|
if [ ! $EXECPROCNUM ]; then
|
|
EXECPROCNUM=1
|
|
fi
|
|
NUMCMD=1
|
|
while [ ${NUMCMD} -le $EXECPROCNUM ]; do
|
|
CMDF[$NUMCMD]=`MakeFifo`
|
|
ExecCommand $NUMCMD&
|
|
(( NUMCMD++ ))
|
|
done
|
|
}
|
|
|
|
DispatchCMD() {
|
|
read <&8 FREE
|
|
NUM=1
|
|
while [ "$1" ]; do
|
|
if [ "$NUM" == "1" ]; then
|
|
CMDALL="$1"
|
|
NUM=0
|
|
else
|
|
CMDALL=$CMDALL" && $1"
|
|
fi
|
|
shift
|
|
done
|
|
echo $CMDALL >${CMDF[${FREE}]}
|
|
}
|
|
|
|
EndDispatch() {
|
|
NUMCMD=1
|
|
EXECPROCNUM=$NUMCPU
|
|
while [ "${NUMCMD}" -le "$EXECPROCNUM" ]; do
|
|
cat >${CMDF[${NUMCMD}]} <<EOF
|
|
|
|
wshutdown
|
|
EOF
|
|
(( NUMCMD++ ))
|
|
done
|
|
wait
|
|
exec 8<&-
|
|
rm -f $FREEF
|
|
}
|
|
|
|
GenDynLib32() {
|
|
STATLIB=$1
|
|
DYNLIBVER=$2
|
|
BASEVER=`echo $DYNLIBVER|awk -F"." '{print $1}'`
|
|
LIBNAME=`basename $1|sed -e "s/\.a$//"`
|
|
DYNLIBDIR=`dirname $STATLIB`
|
|
echo "Generating Dynamic Lib $LIBNAME.so.$DYNLIBVER. BaseVersion = $BASEVER"
|
|
mkdir /tmp/libgen$$
|
|
cd /tmp/libgen$$
|
|
ar -x $STATLIB
|
|
gcc $BUILDOPTIONS32 -shared -Wl,-soname,$LIBNAME.so.$BASEVER -o $DYNLIBDIR/$LIBNAME.so.$DYNLIBVER *.o
|
|
ln -s $LIBNAME.so.$DYNLIBVER $DYNLIBDIR/$LIBNAME.so.$BASEVER
|
|
ln -sf $LIBNAME.so.$DYNLIBVER $DYNLIBDIR/$LIBNAME.so
|
|
cd -
|
|
rm -rf /tmp/libgen$$
|
|
}
|
|
|
|
GenDynLib() {
|
|
STATLIB=$1
|
|
DYNLIBVER=$2
|
|
BASEVER=`echo $DYNLIBVER|awk -F"." '{print $1}'`
|
|
LIBNAME=`basename $1|sed -e "s/\.a$//"`
|
|
DYNLIBDIR=`dirname $STATLIB`
|
|
echo "Generating Dynamic Lib $LIBNAME.so.$DYNLIBVER. BaseVersion = $BASEVER"
|
|
mkdir /tmp/libgen$$
|
|
cd /tmp/libgen$$
|
|
ar -x $STATLIB
|
|
gcc $BUILDOPTIONS -shared -Wl,-soname,$LIBNAME.so.$BASEVER -o $DYNLIBDIR/$LIBNAME.so.$DYNLIBVER *.o
|
|
ln -s $LIBNAME.so.$DYNLIBVER $DYNLIBDIR/$LIBNAME.so.$BASEVER
|
|
ln -sf $LIBNAME.so.$DYNLIBVER $DYNLIBDIR/$LIBNAME.so
|
|
cd -
|
|
rm -rf /tmp/libgen$$
|
|
}
|
|
|
|
extractfile() {
|
|
ARCHIVE=$1
|
|
EFILE=$2
|
|
LINE=`head -n 1 $ARCHIVE`
|
|
case $EFILE in
|
|
dep)
|
|
LINE=`echo $LINE|cut -d" " -f 1-`
|
|
;;
|
|
meta)
|
|
LINE=`echo $LINE|cut -d" " -f 2-`
|
|
;;
|
|
bin.drg)
|
|
LINE=`echo $LINE|cut -d" " -f 3-`
|
|
;;
|
|
bin.cont)
|
|
LINE=`echo $LINE|cut -d" " -f 4-`
|
|
;;
|
|
bin.tar)
|
|
LINE=`echo $LINE|cut -d" " -f 5-`
|
|
;;
|
|
dev.drg)
|
|
LINE=`echo $LINE|cut -d" " -f 6-`
|
|
;;
|
|
dev.cont)
|
|
LINE=`echo $LINE|cut -d" " -f 7-`
|
|
;;
|
|
dev.tar)
|
|
LINE=`echo $LINE|cut -d" " -f 8-`
|
|
;;
|
|
man.drg)
|
|
LINE=`echo $LINE|cut -d" " -f 9-`
|
|
;;
|
|
man.cont)
|
|
LINE=`echo $LINE|cut -d" " -f 10-`
|
|
;;
|
|
man.tar)
|
|
LINE=`echo $LINE|cut -d" " -f 11-`
|
|
;;
|
|
esac
|
|
BEGSIZE=0
|
|
for i in $LINE; do
|
|
(( BEGSIZE = $BEGSIZE + $i ))
|
|
done
|
|
SIZE=`echo $LINE|cut -d" " -f1`
|
|
if [ "$SIZE" -gt "0" ]; then
|
|
tail -c $BEGSIZE $ARCHIVE | head -c `echo $LINE | cut -d" " -f1`|bzcat
|
|
fi
|
|
}
|
|
|