![kueller](/assets/img/avatar_default.png)
git-svn-id: svn://svn.compuextreme.de/Viitor/V962/ViitorMake@4886 504e572c-2e33-0410-9681-be2bf7408885
793 lines
21 KiB
Bash
Executable File
793 lines
21 KiB
Bash
Executable File
#!/bin/bash
|
|
#set -x
|
|
#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: Erzeugung von ViitorLinux installabel packages aus
|
|
# den Sourcen heraus
|
|
# Script wird durch externe Module gesteuert.
|
|
#
|
|
#Aufrufparameter:
|
|
# -c<Filename> :PKG Cluster erzeugen - Filename enthält eine liste von
|
|
# Modulnamen, welche alle pkgs eines Software Clusters
|
|
# Erzeugen
|
|
# -m<Modulename>:PKG Erzeugen - Modulename bezeichnet ein genpkg module
|
|
# über welches die PKG Erzeugung gesteuert wird
|
|
# -s<Filename> :System Erzeugen. Filename enthält die Namen von Clustern
|
|
# Welche zusammengenommen das komplette Viitor System ausmachen
|
|
# -f :Forciere die Erzeugung des Packages - auch wenn dieses bereits
|
|
# vorhanden ist
|
|
# -i :Installation des Packetes forcieren. Abfragen bei bereits
|
|
# installierten package werden unterdrückt
|
|
#
|
|
#Letzte Änderung von: $Author$
|
|
#Datum der letzten Änderung: $Date$
|
|
#Version der Datei: $Revision$
|
|
#
|
|
|
|
if [ ! -f $HOME/.ViitorMake ]; then
|
|
echo "Please run Scripts/initViitorMake"
|
|
echo "From ViitorMake Root Direktory"
|
|
echo "This will create a File $HOME/.ViitorMake"
|
|
echo "with necessary information for running"
|
|
echo "ViitorMake Scripts"
|
|
exit 10
|
|
fi
|
|
|
|
source $HOME/.ViitorMake
|
|
|
|
if [ -f defsys ]; then
|
|
source defsys
|
|
elif [ -f $VMAKEDIR/defsys ]; then
|
|
source $VMAKEDIR/defsys
|
|
else
|
|
echo "defsys not found"
|
|
exit 10
|
|
fi
|
|
|
|
NUMCPU=`grep cpu[0-9] /proc/stat|wc -l|sed -e "s/ //g"`
|
|
(( NUMCPU = $NUMCPU * 2 ))
|
|
export NUMCPU
|
|
|
|
if echo $TARGET|grep -q 64; then
|
|
MK64BIT=true
|
|
else
|
|
MK64BIT=false
|
|
fi
|
|
|
|
if [ -f functions/functions ]; then
|
|
source functions/functions
|
|
elif [ -f $VMAKEDIR/functions/functions ]; then
|
|
source $VMAKEDIR/functions/functions
|
|
else
|
|
echo "Error: Function Library not found!"
|
|
exit 10
|
|
fi
|
|
|
|
|
|
Interrupt_script() {
|
|
echo "Somthing want to stop your runnint $0 script"
|
|
echo "should i really stop executation of $0?"
|
|
read ANSWER
|
|
if [ "$ANSWER" == "y" ]; then
|
|
echo "Should i run CleanUp bevor end of script ?"
|
|
echo "This will delete all used resources of this scipt"
|
|
read ANSWER
|
|
if [ "$ANSWER" == "y" ]; then
|
|
CleanUp
|
|
fi
|
|
exit 1
|
|
else
|
|
return
|
|
fi
|
|
}
|
|
|
|
trap 'Interrupt_script' 1
|
|
trap 'Interrupt_script' 2
|
|
trap 'Interrupt_script' 3
|
|
trap 'Interrupt_script' 9
|
|
trap 'Interrupt_script' 15
|
|
trap 'Interrupt_script' 19
|
|
trap 'Interrupt_script' 31
|
|
|
|
EchoHelp() {
|
|
echo "$0 -c<Filename>|m<Modulename>|-s<Filename> [-fi]
|
|
|
|
-b Verwende <TMPPATH> für tmpdateien (ansonsten /tmp/genpkg\$\$
|
|
-c Generate PKG Cluster defined in <Filename>
|
|
-m Generate PKG as defined in Module <Modulename>
|
|
-s Generate System from clusters defined in <Filename>
|
|
-d Debug aktivieren. genpkg hält nach jeder Erstellung eines
|
|
Packetes an und wartet auf einen Tastendruck.
|
|
-f Force Generating of Modules
|
|
-i Force Installation of generated packages
|
|
-h Show this help"
|
|
}
|
|
|
|
pkggen() {
|
|
MODULENAME=$1
|
|
MODULEPATH=`dirname $1`
|
|
|
|
unset SRCDIR MKPKG DSTPKGNAME
|
|
PKGSTARTDIR=`pwd`
|
|
MODULEPATH=$PKGSTARTDIR/$MODULEPATH
|
|
|
|
#MKPKG wird BINAER augewertet
|
|
#Bedeutung der Stellen
|
|
#0000001 -> Package wird in jedem fall neu Erzeugt. Abfrage auf bereits
|
|
#(1) vorhandenes Package wird unterdrückt
|
|
#0000010 -> Package wird in jedem fall neu Installiert. Abfragen werden
|
|
#(2) unterdrückt
|
|
#0000100 -> Source packet wird nicht von pkggen funktion entpackt.
|
|
#(4) das Module muss sich darum kümmern (premk() funktion)
|
|
#0001000 -> Binärdaten werden nicht als Packet gepackt -> darum kümmert
|
|
#(8) sich das Module (postmk() Funktion)
|
|
#0010000 -> Kein installationsversuch des neu erstellten Packetes
|
|
#(16) seitens pkggen
|
|
#0100000 -> Bei Installation MÜSSEN die Abhängigkeiten erfüllt sein
|
|
#(32) (FORCE <PKGNAME> in *.deb file)
|
|
#1000000 -> Nach packeterzeugung wird der sourcetree nicht aufgeräumt
|
|
|
|
|
|
PROGNAME=`basename $1`
|
|
TMPROOT=$STORETMPROOT/$PROGNAME$$
|
|
CLEANUP_FLAGS=0
|
|
MKPKG=0
|
|
ADDONPROJEKT=""
|
|
source $1
|
|
if [ "$FORCEINSTALL" == "1" ]; then
|
|
(( MKPKG = $MKPKG | 2 ))
|
|
fi
|
|
if [ "$FORCEMAKE" == "1" ]; then
|
|
(( MKPKG = $MKPKG | 1 ))
|
|
fi
|
|
if [ "$NoRewriteName" == "true" ]; then
|
|
PKGNAME=`ArchiveName $LFSSOURCE/$SRCPATH/$PROGNAME$PATTERN*.t* 1`
|
|
else
|
|
PKGNAME=`ArchiveName $LFSSOURCE/$SRCPATH/$PROGNAME$PATTERN*.t*`
|
|
fi
|
|
DEVPKGNAME=`echo $PKGNAME|sed -e "s/\.tbz$/\.dev\.tbz/"`
|
|
MANPKGNAME=`echo $PKGNAME|sed -e "s/\.tbz$/\.man\.tbz/"`
|
|
|
|
(( CHECKFLAG = $MKPKG & 5 ))
|
|
if [ "$CHECKFLAG" == "0" ]; then
|
|
if [ -f $DISTTARGET/$SRCPATH/$PKGNAME ]; then
|
|
echo "The Package $PKGNAME"
|
|
echo "Exist already in $DISTTARGET/$SRCPATH -"
|
|
echo "should i remake it ? [y/N] "
|
|
read ANSWER
|
|
if [ "$ANSWER" != "y" ]; then
|
|
echo "Stopping Make of $PKGNAME"
|
|
return 10
|
|
fi
|
|
fi
|
|
fi
|
|
(( CHECKFLAG = $MKPKG & 4 ))
|
|
if [ "$CHECKFLAG" == "0" ]; then
|
|
cd $MAKEDIR
|
|
CheckError "Could not change working Dir to $MAKEDIR"
|
|
PROGPATH=$LFSSOURCE/$SRCPATH/$PROGNAME
|
|
if ! ls $PROGPATH$PATTERN*.t* >/dev/null 2>&1; then
|
|
echo "Sourcefile $PROGPATH does not exist"
|
|
CleanUp
|
|
exit 0
|
|
fi
|
|
for i in $PROGPATH$PATTERN*.t*; do
|
|
UnPack $MAKEDIR $i
|
|
CheckError "Unpack of $i failed"
|
|
(( CHECKFLAG = $MKPKG & 64 ))
|
|
if [ "$CHECKFLAG" == "0" ]; then
|
|
(( CLEANUP_FLAGS = $CLEANUP_FLAGS | 1 ))
|
|
fi
|
|
done
|
|
if [ ! "$SRCDIR" ]; then
|
|
SRCDIR=$PROGNAME
|
|
fi
|
|
cd $SRCDIR*
|
|
CheckError "Could not change Working Dir to $SRCDIR*"
|
|
(( CHECKFLAGS = $MKPKG & 128 ))
|
|
if [ "$CHECKFLAGS" == "0" ]; then
|
|
echo "Checkin for patch"
|
|
if ls $PROGPATH$PATTERN*.patch.* >/dev/null 2>&1; then
|
|
for i in $PROGPATH$PATTERN*.patch.*; do
|
|
echo "Applaying Patch $i"
|
|
SrcPatch $MAKEDIR/$SRCDIR* $i
|
|
done
|
|
fi
|
|
fi
|
|
fi
|
|
if [ ! -d $TMPROOT ]; then
|
|
mkdir -p $TMPROOT
|
|
fi
|
|
(( CLEANUP_FLAGS = $CLEANUP_FLAGS | 2 ))
|
|
if [ -f /etc/profile ]; then
|
|
source /etc/profile
|
|
fi
|
|
if [ "$OPT" ]; then
|
|
(( C_FLAG = $OPT & 16 ))
|
|
fi
|
|
if [ "$C_FLAG" == 0 ] && [ -f ~/.bash_profile ]; then
|
|
CDIR=`pwd`
|
|
source ~/.bash_profile
|
|
cd $CDIR
|
|
fi
|
|
if [ -f $MODULEPATH/.init ]; then
|
|
source $MODULEPATH/.init
|
|
fi
|
|
/sbin/ldconfig
|
|
premk
|
|
CheckError "Somthing bad happens on premk()"
|
|
sync
|
|
if [ $MK64BIT == "true" ]; then
|
|
if set|grep -q ^mk32; then
|
|
SetConfig 32
|
|
mk32
|
|
sync
|
|
SetConfig 0
|
|
CheckError "Somthing bad happens on mk64()"
|
|
fi
|
|
fi
|
|
if [ "$MK64BIT" == "true" ]; then
|
|
SetConfig 64
|
|
else
|
|
SetConfig 32
|
|
fi
|
|
mk
|
|
sync
|
|
SetConfig 0
|
|
CheckError "Somthing bad happens on mk()"
|
|
AKTDIR=`pwd`
|
|
cd $TMPROOT
|
|
CheckError "Coudn\`t change to TMPROOT $TMPROOT"
|
|
if [ ! "$DSTPKGNAME" ]; then
|
|
DSTPKGNAME=`echo $PKGNAME|sed -e "s/\.tbz$//"`
|
|
fi
|
|
if [ -d /var/install/$DSTPKGNAME ]; then
|
|
mv /var/install/$DSTPKGNAME /tmp
|
|
fi
|
|
GenDependics $TMPROOT >/tmp/deps$$
|
|
(( CHECKFLAGS = $MKPKG & 32 ))
|
|
mkdir -p $TMPROOT/../$$
|
|
for i in `cat /tmp/deps$$`; do
|
|
if [ "$CHECKFLAGS" == 0 ]; then
|
|
echo "WARN $i" >>$TMPROOT/../$$/dep
|
|
else
|
|
echo "FORCE $i" >>$TMPROOT/../$$/dep
|
|
fi
|
|
done
|
|
if [ -f $TMPROOT/../$$/dep ]; then
|
|
bzip2 -9 $TMPROOT/../$$/dep
|
|
mv $TMPROOT/../$$/dep.bz2 $TMPROOT/../$$/dep
|
|
fi
|
|
cd -
|
|
if [ -d /tmp/$DSTPKGNAME ]; then
|
|
mv /tmp/$DSTPKGNAME /var/install
|
|
fi
|
|
rm /tmp/deps$$
|
|
cd $AKTDIR
|
|
StripPkg $TMPROOT
|
|
postmk
|
|
sync
|
|
CheckError "Somthing bad happens om postmk()"
|
|
if [ -d $TMPROOT/usr/man ]; then
|
|
mkdir -p $TMPROOT/usr/share
|
|
mv $TMPROOT/usr/man $TMPROOT/usr/share
|
|
fi
|
|
if [ -d $TMPROOT/usr/info ]; then
|
|
mkdir -p $TMPROOT/usr/share
|
|
mv $TMPROOT/usr/info $TMPROOT/usr/share
|
|
fi
|
|
if [ -d $TMPROOT/usr/doc ]; then
|
|
mkdir -p $TMPROOT/usr/share
|
|
mv $TMPROOT/usr/doc $TMPROOT/usr/share
|
|
fi
|
|
(( CHECKFLAGS = $MKPKG & 8 ))
|
|
if [ "$CHECKFLAGS" == "0" ]; then
|
|
cd $TMPROOT
|
|
MANTMPROOT=$TMPROOT.man
|
|
DEVTMPROOT=$TMPROOT.dev
|
|
for i in `find . -name "man" -type d`; do
|
|
if ls -d $i/man[0-9] 2>&1 >/dev/null; then
|
|
DIR=`dirname $i`
|
|
mkdir -p $MANTMPROOT/$DIR
|
|
mv $i $MANTMPROOT/$DIR
|
|
fi
|
|
done
|
|
for i in `find . -name "info" -type d`; do
|
|
if [ -f $i/dir ]; then
|
|
DIR=`dirname $i`
|
|
mkdir -p $MANTMPROOT/$DIR
|
|
mv $i $MANTMPROOT/$DIR
|
|
fi
|
|
done
|
|
for i in `find . -type d -name "doc"`; do
|
|
if [ ! -d $MANTMPROOT/usr/share/doc ]; then
|
|
mkdir -p $MANTMPROOT/usr/share/doc
|
|
fi
|
|
cd $i
|
|
tar -cf - .|tar -C $MANTMPROOT/usr/share/doc -xf -
|
|
cd -
|
|
rm -r $i
|
|
done
|
|
for i in `find . -name "*.[ah]"`; do
|
|
DIR=`dirname $i`
|
|
mkdir -p $DEVTMPROOT/$DIR
|
|
mv $i $DEVTMPROOT/$DIR
|
|
done
|
|
for i in `find . -name "*.hxx"`; do
|
|
DIR=`dirname $i`
|
|
mkdir -p $DEVTMPROOT/$DIR
|
|
mv $i $DEVTMPROOT/$DIR
|
|
done
|
|
for i in `find . -name "*.hpp"`; do
|
|
DIR=`dirname $i`
|
|
mkdir -p $DEVTMPROOT/$DIR
|
|
mv $i $DEVTMPROOT/$DIR
|
|
done
|
|
for i in `find . -name "*.la"`; do
|
|
DIR=`dirname $i`
|
|
mkdir -p $DEVTMPROOT/$DIR
|
|
mv $i $DEVTMPROOT/$DIR
|
|
done
|
|
sync
|
|
InitDispatch
|
|
if [ ! `find . -type f|wc -l` == "0" ]; then
|
|
DispatchCMD "cd $TMPROOT" \
|
|
"MakeMgtFiles bin" \
|
|
"tar -jcvf $TMPROOT/../$$/bin.tar ." \
|
|
sync
|
|
fi
|
|
if [ -d $MANTMPROOT ]; then
|
|
DispatchCMD "cd $MANTMPROOT" \
|
|
"MakeMgtFiles man" \
|
|
"tar -jcvf $TMPROOT/../$$/man.tar ." \
|
|
sync
|
|
fi
|
|
if [ -d $DEVTMPROOT ]; then
|
|
DispatchCMD "cd $DEVTMPROOT" \
|
|
"MakeMgtFiles dev" \
|
|
"tar -jcvf $TMPROOT/../$$/dev.tar ." \
|
|
sync
|
|
fi
|
|
EndDispatch
|
|
sync
|
|
cd $TMPROOT/../$$
|
|
for i in bin.frg bin.drg bin.md5 man.frg man.drg man.md5 dev.frg dev.drg dev.md5; do
|
|
if [ -f $i ]; then
|
|
cd $TMPROOT/../$$
|
|
bzip2 $i
|
|
mv $i.bz2 $i
|
|
fi
|
|
done
|
|
METAFILE=$TMPROOT/../$$/meta
|
|
if [ "$SHORTNAME" ]; then
|
|
echo "ModuleName: $SHORTNAME" >$METAFILE
|
|
else
|
|
echo "ModuleName: `basename $MODULENAME`" >$METAFILE
|
|
fi
|
|
echo "BuildDate: `date +%Y%m%d`" >>$METAFILE
|
|
echo -n "Module Version:" >>$METAFILE
|
|
if [ -f /usr/bin/svn ]; then
|
|
cd $MODULEPATH
|
|
svn info `basename $MODULENAME`|\
|
|
grep "Revision" |\
|
|
awk '{print $2}' >>$METAFILE
|
|
cd - 2>&1 >/dev/null
|
|
else
|
|
grep "#Version der Datei: \$Revision" \
|
|
$MODULEPATH/`basename $MODULENAME` |\
|
|
awk '{print $5}' >>$METAFILE
|
|
fi
|
|
if [ "$ADDONPROJEKT" ]; then
|
|
echo "AddOnProj: $ADDONPROJEKT" >>$METAFILE
|
|
echo "AddOnVersion: $ADDONVERSION" >>$METAFILE
|
|
export ADDONPROJEKT=""
|
|
fi
|
|
echo -n "Quellen:" >>$METAFILE
|
|
grep -e "#Quelle der Source Archive:" $MODULEPATH/`basename $MODULENAME`|\
|
|
cut -d":" -f 2- >>$METAFILE
|
|
echo "Description:" >>$METAFILE
|
|
GREPFILE=$MODULEPATH/`basename $MODULENAME`
|
|
STARTLINE=`egrep -n "^#Kurzbeschreibung" $GREPFILE|cut -d ":" -f 1`
|
|
ENDLINE=`egrep -n "^#Letzte Änderung von:" $GREPFILE|cut -d ":" -f 1`
|
|
(( NumLines = $ENDLINE - $STARTLINE ))
|
|
(( ENDLINE -- ))
|
|
head -n $ENDLINE $MODULEPATH/`basename $MODULENAME`|\
|
|
tail -n $NumLines |\
|
|
sed -e "s/^#//" \
|
|
-e "s/Kurzbeschreibung://" \
|
|
-e "/^$/d" >>$METAFILE
|
|
bzip2 -9 $METAFILE
|
|
mv $METAFILE.bz2 $METAFILE
|
|
ARCHCONTENTS="bin.drg bin.frg bin.md5 bin.tar dev.drg dev.frg dev.md5 dev.tar man.drg man.frg man.md5 man.tar"
|
|
cd $TMPROOT/../$$
|
|
if [ -f dep ]; then
|
|
LINE="`wc -c dep|awk '{print $1}'` "
|
|
else
|
|
LINE="0 "
|
|
fi
|
|
if [ -f meta ]; then
|
|
LINE=$LINE"`wc -c meta|awk '{print $1}'` "
|
|
else
|
|
LINE=$LINE"0 "
|
|
fi
|
|
for i in $ARCHCONTENTS; do
|
|
if [ -f $i ]; then
|
|
LINE=$LINE"`wc -c $i|awk '{print $1}'` "
|
|
else
|
|
LINE=$LINE"0 "
|
|
fi
|
|
done
|
|
echo $LINE >$DISTTARGET/$SRCPATH/$PKGNAME
|
|
if [ -f dep ]; then
|
|
cat dep >>$DISTTARGET/$SRCPATH/$PKGNAME
|
|
fi
|
|
if [ -f meta ]; then
|
|
cat meta >>$DISTTARGET/$SRCPATH/$PKGNAME
|
|
fi
|
|
for i in $ARCHCONTENTS; do
|
|
if [ -f $i ]; then
|
|
cat $i >>$DISTTARGET/$SRCPATH/$PKGNAME
|
|
fi
|
|
done
|
|
cd ..
|
|
rm -r $TMPROOT/../$$
|
|
fi
|
|
(( CHECKFLAGS = $MKPKG & 16 ))
|
|
if [ "$CHECKFLAGS" == "0" ]; then
|
|
if [ -d /var/install ]; then
|
|
mkdir -p /var/install
|
|
CheckError "Creation of /var/install failed"
|
|
fi
|
|
if [ -f /sbin/installpkg ]; then
|
|
(( CHECKFLAGS = $MKPKG & 256 ))
|
|
if [ "$CHECKFLAGS" == "0" ]; then
|
|
INSTALLOPTS="-o"
|
|
fi
|
|
(( CHECKFLAGS = $MKPKG & 2 ))
|
|
if [ "$CHECKFLAGS" == "0" ]; then
|
|
INSTALLOPTS=$INSTALLOPTS" -i"
|
|
else
|
|
INSTALLOPTS=$INSTALLOPTS" -fi"
|
|
fi
|
|
installpkg -o $INSTALLOPTS $DISTTARGET/$SRCPATH/$PKGNAME
|
|
CheckError "Installation of $PKGNAME failed"
|
|
else
|
|
echo "installing $DISTTARGET/$SRCPATH/$PKGNAME"
|
|
cd /
|
|
for k in bin.tar dev.tar man.tar; do
|
|
case $k in
|
|
bin.tar)
|
|
SIZE=`head -n 1 $DISTTARGET/$SRCPATH/$PKGNAME|awk '{print $6}'`
|
|
;;
|
|
dev.tar)
|
|
SIZE=`head -n 1 $DISTTARGET/$SRCPATH/$PKGNAME|awk '{print $10}'`
|
|
;;
|
|
man.tar)
|
|
SIZE=`head -n 1 $DISTTARGET/$SRCPATH/$PKGNAME|awk '{print $14}'`
|
|
;;
|
|
esac
|
|
if [ "$SIZE" -gt "0" ]; then
|
|
extractfile $DISTTARGET/$SRCPATH/$PKGNAME $k|tar -xvf -
|
|
fi
|
|
done
|
|
PKGNAME=`echo $PKGNAME|sed -e "s/\.vpg//"`
|
|
if [ ! -d /var/install/$PKGNAME ]; then
|
|
mkdir -p /var/install/$PKGNAME/{dev,bin,man}
|
|
fi
|
|
extractfile $DISTTARGET/$SRCPATH/$PKGNAME.vpg meta|\
|
|
grep -A 10 -e "^Description:" |\
|
|
grep -v -e "^Description:" \
|
|
>>$ROOT/var/install/$PKGNAME/description
|
|
extractfile $DISTTARGET/$SRCPATH/$PKGNAME.vpg meta|\
|
|
grep ModuleName |\
|
|
awk '{print $2}' \
|
|
>$ROOT/var/install/$PKGNAME/shortname
|
|
if [ "`wc -c $ROOT/var/install/$PKGNAME/description|awk '{print $1}'`" == "0" ]; then
|
|
rm $ROOT/var/install/$PKGNAME/description
|
|
fi
|
|
if [ "`wc -c $ROOT/var/install/$PKGNAME/shortname|awk '{print $1}'`" == "0" ]; then
|
|
rm $ROOT/var/install/$PKGNAME/shortname
|
|
fi
|
|
if [ -f $ROOT/var/install/$PKGNAME/shortname ]; then
|
|
SHNAME=`cat $ROOT/var/install/$PKGNAME/shortname`
|
|
else
|
|
SHNAME=$PKGNAME
|
|
fi
|
|
for k in bin dev man; do
|
|
extractfile $DISTTARGET/$SRCPATH/$PKGNAME.vpg $k.frg >/tmp/$k.frg$$
|
|
extractfile $DISTTARGET/$SRCPATH/$PKGNAME.vpg $k.md5 >/tmp/$k.md5$$
|
|
if [ "`wc -c /tmp/$k.frg$$|awk '{print $1}'`" -gt "0" ]; then
|
|
exec 5</tmp/$k.frg$$
|
|
while read <&5 FILE TYP RIGHT OWNER GROUP; do
|
|
if [ `fgrep $FILE /tmp/$k.md5$$|wc -l` -gt 1 ]; then
|
|
MD5SUM=`grep ${FILE}$ /tmp/$k.md5$$|awk '{print $1}'`
|
|
else
|
|
MD5SUM=`fgrep ${FILE} /tmp/$k.md5$$|awk '{print $1}'`
|
|
fi
|
|
echo "PN=$SHNAME;FN=$FILE;FT=$TYP;FR=$RIGHT;FO=$OWNER;FG=$GROUP;FS=$MD5SUM;PK=$PKGNAME" >>/var/install/contents
|
|
done
|
|
exec 5<&-
|
|
rm /tmp/$k.frg$$
|
|
rm /tmp/$k.md5$$
|
|
extractfile $DISTTARGET/$SRCPATH/$PKGNAME.vpg $k.drg >/var/install/$PKGNAME/$k/DirRights
|
|
if [ "`wc -c /var/install/$PKGNAME/$k/DirRights|awk '{print $1}'`" == "0" ]; then
|
|
rm /var/install/$PKGNAME/$k/DirRights
|
|
fi
|
|
fi
|
|
done
|
|
if [ -f /tmp/postinstall ]; then
|
|
source /tmp/postinstall
|
|
CheckError "postinstall of $PKGNAME failed"
|
|
rm /tmp/postinstall
|
|
CheckError "Deletion of /tmp/postinstall failed"
|
|
fi
|
|
fi
|
|
fi
|
|
CleanUp
|
|
cd $PKGSTARTDIR
|
|
}
|
|
|
|
|
|
MAKE_FLAG=0
|
|
PROGDIR=`pwd`
|
|
INSTALL=0
|
|
DEINSTALL=0
|
|
NOGEN=0
|
|
PROGNAME=`basename $0`
|
|
ABSPROG=$VMAKEDIR/$PROGNAME
|
|
|
|
while getopts :b:c:m:s:fihd opt_char; do
|
|
case $opt_char in
|
|
b)
|
|
(( MAKE_FLAG = $MAKE_FLAG | 8 ))
|
|
TMPPATH=$OPTARG
|
|
;;
|
|
c)
|
|
(( MAKE_FLAG = $MAKE_FLAG | 1 ))
|
|
CFGFILE=$OPTARG
|
|
;;
|
|
d)
|
|
DEBUG=1
|
|
;;
|
|
m)
|
|
(( MAKE_FLAG = $MAKE_FLAG | 2 ))
|
|
MODULEFILE=$OPTARG
|
|
;;
|
|
s)
|
|
(( MAKE_FLAG = $MAKE_FLAG | 4 ))
|
|
CFGFILE=$OPTARG
|
|
;;
|
|
f)
|
|
FORCEMAKE=1
|
|
;;
|
|
i)
|
|
FORCEINSTALL=1
|
|
;;
|
|
\?)
|
|
echo "$OPTARG is not a valid option"
|
|
EchoHelp
|
|
;;
|
|
h)
|
|
EchoHelp
|
|
;;
|
|
esac
|
|
done
|
|
|
|
#Überprüfen der Optimierungsflags in Initialisierungscripten
|
|
if grep CFLAGS ~/.bash_profile >/dev/null 2>&1; then
|
|
sed -e "s/CFLAGS.*=.*$/CFLAGS=\"$CFLAGS\"/" ~/.bash_profile | \
|
|
sed -e "s/CXXFLAGS.*=.*$/CXXFLAGS=\"$CXXFLAGS\"/" >/tmp/.bash_profile
|
|
mv /tmp/.bash_profile ~/.bash_profile
|
|
fi
|
|
|
|
if grep CFLAGS ~/.profile >/dev/null 2>&1; then
|
|
sed -e "s/^CFLAGS.*=.*$/CFLAGS=\"$CFLAGS\"/" ~/.profile | \
|
|
sed -e "s/^CXXFLAGS.*=.*$/CXXFLAGS=\"$CXXFLAGS\"/" >/tmp/.profile
|
|
mv /tmp/.profile ~/.profile
|
|
fi
|
|
|
|
(( C_FLAG = $MAKE_FLAG & 2 ))
|
|
if [ ! "$C_FLAG" == "0" ]; then
|
|
(( C_FLAG = $MAKE_FLAG & 8 ))
|
|
if [ "$C_FLAG" == "0" ]; then
|
|
TMPPATH=/tmp/genpkg
|
|
fi
|
|
if [ ! -d "$TMPPATH" ]; then
|
|
mkdir $TMPPATH
|
|
fi
|
|
if [ "$DEBUG" == "1" ]; then
|
|
echo "Generate Module $MODULEFILE with"
|
|
echo "makeforce=$FORCEMAKE, installforce=$FORCEINSTALL und tmppath=$TMPPATH"
|
|
echo "Please press any key to continue"
|
|
read
|
|
fi
|
|
STORETMPROOT=$TMPROOT
|
|
if [ "$DEBUG" == "1" ]; then
|
|
if [ "$NOTMP" == "1" ]; then
|
|
pkggen $MODULEFILE 2>&1 |tee $TMPPATH/`basename $MODULEFILE`
|
|
else
|
|
pkggen $MODULEFILE 2>&1 |tee $TMPPATH/`basename $MODULEFILE`
|
|
fi
|
|
else
|
|
pkggen $MODULEFILE 2>&1|tee $TMPPATH/`basename $MODULEFILE`
|
|
fi
|
|
exit 0
|
|
fi
|
|
|
|
(( C_FLAG = $MAKE_FLAG & 1 ))
|
|
if [ ! "$C_FLAG" == "0" ]; then
|
|
(( C_FLAG = $MAKE_FLAG & 8 ))
|
|
if [ "$C_FLAG" == "0" ]; then
|
|
TMPPATH=/tmp/genpkg
|
|
fi
|
|
if [ ! -d "$TMPPATH" ]; then
|
|
mkdir $TMPPATH
|
|
fi
|
|
if [ ! -f /tmp/NOQUEST ]; then
|
|
touch /tmp/NOQUEST
|
|
fi
|
|
sed -e "/^#/d" $CFGFILE |\
|
|
sed -e "/^ *$/d" >$TMPPATH/genpkgcfg$$
|
|
exec 4<$TMPPATH/genpkgcfg$$
|
|
STORETMPROOT=$TMPROOT
|
|
while read <&4 OPT MODULE; do
|
|
if [ -f $TMPPATH/`basename $MODULE`.mk ]; then
|
|
continue
|
|
fi
|
|
(( C_FLAG = $OPT & 2 ))
|
|
if [ "$C_FLAG" == "0" ]; then
|
|
FORCEMAKE=0
|
|
else
|
|
FORCEMAKE=1
|
|
PKGGENOPT="$PKGGENOPT"f
|
|
fi
|
|
(( C_FLAG = $OPT & 4 ))
|
|
if [ "$C_FLAG" == "0" ]; then
|
|
FORCEINSTALL=0
|
|
else
|
|
FORCEINSTALL=1
|
|
PKGGENOPT="$PKGGENOPT"i
|
|
fi
|
|
(( C_FLAG = $OPT & 32 ))
|
|
if [ ! "$C_FLAG" == "0" ]; then
|
|
DEBUG=1
|
|
PKGGENOPT="$PKGGENOPT"d
|
|
fi
|
|
(( C_FLAG = $OPT & 64 ))
|
|
if [ ! "$C_FLAG" == "0" ]; then
|
|
DEBUG=0
|
|
fi
|
|
(( C_FLAG = $OPT & 8 ))
|
|
if [ ! "$C_FLAG" == "0" ]; then
|
|
NOGEN=1
|
|
DEINSTALL=1
|
|
fi
|
|
(( C_FLAG = $OPT & 128 ))
|
|
if [ ! "$C_FLAG" == "0" ]; then
|
|
NOGEN=1
|
|
INSTALL=1
|
|
fi
|
|
(( C_FLAG = $OPT & 256 ))
|
|
if [ ! "$C_FLAG" == "0" ]; then
|
|
MODCLUSTER=1
|
|
fi
|
|
(( C_FLAG = $OPT & 1 ))
|
|
if [ ! "$C_FLAG" == "0" ]; then
|
|
NOTMP=1
|
|
fi
|
|
if [ "$DEBUG" == "1" ]; then
|
|
if [ ! "$NOGEN" == "1" ]; then
|
|
if [ "$MODCLUSTER" == "1" ]; then
|
|
echo "Generate Cluster Module $MODULE"
|
|
echo "with genpkg option $PKGGENOPT"
|
|
else
|
|
echo "Generate Module $MODULE with"
|
|
echo "makeforce=$FORCEMAKE, installforce=$FORCEINSTALL"
|
|
fi
|
|
echo "Please press Enter to continue"
|
|
fi
|
|
if [ "$INSTALL" == "1" ]; then
|
|
echo "Installing Package from Module $MODULE"
|
|
echo "Please press Enter to continue"
|
|
fi
|
|
if [ "$DEINSTALL" == "1" ]; then
|
|
echo "Removing Package from Module $MODULE"
|
|
echo "Please press Enter to continue"
|
|
fi
|
|
read
|
|
fi
|
|
if [ -f /etc/profile ]; then
|
|
source /etc/profile
|
|
fi
|
|
(( C_FLAG = $OPT & 16 ))
|
|
if [ "$C_FLAG" == 0 ] && [ -f ~/.bash_profile ]; then
|
|
source ~/.bash_profile
|
|
fi
|
|
/sbin/ldconfig
|
|
cd $PROGDIR
|
|
if [ -f defsys ]; then
|
|
source defsys
|
|
fi
|
|
if [ -f functions/functions ]; then
|
|
source functions/functions
|
|
fi
|
|
if [ -f `dirname $MODULE`/.init ]; then
|
|
source `dirname $MODULE`/.init
|
|
fi
|
|
if [ ! "$NOGEN" == "1" ]; then
|
|
if [ "$MODCLUSTER" == "1" ]; then
|
|
PKGGENOPT="$PKGGENOPT"c
|
|
else
|
|
PKGGENOPT="$PKGGENOPT"m
|
|
fi
|
|
if [ ! "$DEBUG" == "1" ] || [ "$MODCLUSTER" == "1" ]; then
|
|
$ABSPROG -$PKGGENOPT $MODULE
|
|
elif [ "$NOTMP" = "1" ]; then
|
|
$ABSPROG -$PKGGENOPT $MODULE
|
|
NOTMP=0
|
|
else
|
|
$ABSPROG -$PKGGENOPT $MODULE 2>&1 |tee $TMPPATH/`basename $MODULE`
|
|
fi
|
|
PKGGENOPT=""
|
|
else
|
|
source $MODULE
|
|
if [ "$NoRewriteName" == "true" ]; then
|
|
PKGNAME=`ArchiveName $LFSSOURCE/$SRCPATH/$PROGNAME$PATTERN*.t* 1`
|
|
else
|
|
PKGNAME=`ArchiveName $LFSSOURCE/$SRCPATH/$PROGNAME$PATTERN*.t*`
|
|
fi
|
|
DEVPKGNAME=`echo $PKGNAME|sed -e "s/\.tbz$/\.dev\.tbz/"`
|
|
MANPKGNAME=`echo $PKGNAME|sed -e "s/\.tbz$/\.man\.tbz/"`
|
|
if [ "$DEINSTALL" == "1" ]; then
|
|
RMTMPFILE=`basename $MODULE`
|
|
RMFILE=`echo $RMTMPFILE |\
|
|
sed -e "s/src/bin/"|\
|
|
sed -e "s/source/binary/"`
|
|
installpkg -fr `basename $RMFILE`
|
|
fi
|
|
if [ "$INSTALL" == "1" ]; then
|
|
PROGNAME=`basename $MODULE`
|
|
if [ "$NoRewriteName" == "true" ]; then
|
|
PKGNAME=`ArchiveName $LFSSOURCE/$SRCPATH/$PROGNAME$PATTERN*.t* 1`
|
|
else
|
|
PKGNAME=`ArchiveName $LFSSOURCE/$SRCPATH/$PROGNAME$PATTERN*.t*`
|
|
fi
|
|
(( CHECKFLAGS = "$MKPKG" & 256 ))
|
|
if [ "$CHECKFLAGS" == "0" ]; then
|
|
INSTALLOPTS="-o"
|
|
fi
|
|
installpkg $INSTALLOPTS -i $DISTTARGET/$SRCPATH/$PKGNAME
|
|
fi
|
|
DEINSTALL=0
|
|
INSTALL=0
|
|
NOGEN=0
|
|
fi
|
|
(( C_FLAG = $OPT & 1 ))
|
|
if [ "$C_FLAG" == "0" ] && [ ! -f $TMPPATH/`basename $MODULE` ]; then
|
|
touch $TMPPATH/`basename $MODULE`.mk
|
|
NOTMP=0
|
|
fi
|
|
done
|
|
4>&-
|
|
rm $TMPPATH/genpkgcfg$$
|
|
fi
|