vabs / var / vabs / VL-ISO-STD / src / VL-ISO-STD.SlackBuild

#!/usr/bin/bash
# This script assumes it will be launched within "/NAME/VERSION/src" dir.
# With all sources in "src" Your Vector Linux .txz package, slack-desc,
# and slack-required will be found in "VERSION" dir. The extraction and
# build will be in a temp dir created in "NAME" dir, and then removed on exit.
# Comment out second to last line to keep this dir intact.
#
# This Template was compiled from the contributions of many users of the Vector
# Linux forum at http://forum.vectorlinux.com and from tidbits collected 
# from all over the internet. 
#
# Generated by sbbuilder-0.4.14.1, written by Rodrigo Bistolfi 
# (rbistolfi) and Raimon Grau Cuscó (Kidd) for VectorLinux.
#
# Please put your name below if you add some original scripting lines.
# AUTHORS = 

NAME="VL-ISO"            #Enter package Name!
VERSION=${VERSION:-"7.1"}      #Enter package Version!
VER=$(echo $VERSION|sed 's/-/_/') #this fixes - in version
VL_PACKAGER=${VL_PACKAGER:-"Uelsk8s"}   #Enter your Name!
LINK=${LINK:-"http://ftp-osl.osuosl.org/pub/vectorlinux/vec7/VL-SOURCE/$NAME.tar.xz http://ftp-osl.osuosl.org/pub/vectorlinux/vec7/VL-SOURCE/pyinit.lz"}  #Enter URL for package here!}

#SYSTEM VARIABLES
#----------------------------------------------------------------------------
BUILDNUM=${BUILDNUM:-"A8"}
VL_VERSION="STD"
PREV32ISO=${PREV32ISO:-"VL-7.1-STD-A7.iso"} #enter last iso, only if you want a delta generated.
PREV64ISO=${PREV64ISO:-"VL64-7.1-STD-A7.iso"} #enter last iso, if you want a delta generated.
CD32NAME="VL-${VERSION}-STD-$BUILDNUM.iso"
CD64NAME="VL64-${VERSION}-STD-$BUILDNUM.iso"
ARCH=${ARCH:-"$(uname -m)"}
CONFIG_OPTIONS=${CONFIG_OPTIONS:-""}
LDFLAG_OPTIONS=${LDFLAG_OPTIONS:-""}
ADDRB=${ADDRB:-""} #Add deps that need to be added to the slack-required file here
EXRB=${EXRB:-""} #Add deps that need to be excluded from the slack-required file here
MAKEDEPENDS=${MAKEDEPENDS:-"cdrkit bootsplash cpio"} #Add deps needed TO BUILD this package here.
#----------------------------------------------------------------------------

# DO NOT EXECUTE if NORUN is set to 1
if [ "$NORUN" != "1" ]; then
ifconfig
#SETUP PACKAGING ENVIRONMENT
#--------------------------------------------
CWD=$(pwd)
cd ../
RELEASEDIR=$(pwd)
cd $CWD
mkdir -p $RELEASEDIR/tmp
TMP=$RELEASEDIR/tmp
PKG=$TMP/package-$NAME
#--------------------------------------------

for i in x86 x86_64;do
 mkdir -p $TMP
 rm -r /home/ftp/pub/veclinux/packages/*
 ARCH=$i
 cp $CWD/slapt-getrc /etc/slapt-get/slapt-getrc
 sed -i "s/ARCH/$i/" /etc/slapt-get/slapt-getrc

#CFLAGS SETUP
#--------------------------------------------
if [[ "$ARCH" = "x86" ]]; then
  ARCH=i586
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  CONFIGURE_TRIPLET="i586-vector-linux"
  LIBDIRSUFFIX=""
  THEME=std-7-Boot
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fpic"
  CONFIGURE_TRIPLET="x86_64-vlocity-linux"
  LIBDIRSUFFIX="64"
  THEME=std-71
elif [ "$ARCH" = "powerpc" ]; then
  SLKCFLAGS="-O2"
  CONFIGURE_TRIPLET="powerpc-vlocity-linux"
  LIBDIRSUFFIX=""
  THEME=std-71
fi

export CFLAGS="$SLKCFLAGS $CFLAG_OPTIONS"
export CXXFLAGS=$CFLAGS
export LDFLAGS="$LDFLAGS $LDFLAG_OPTIONS"
CDLABEL="VL${LIBDIRSUFFIX}-$VERSION"
CDNAME="$CDLABEL-$VL_VERSION-$BUILDNUM.iso"
REL="${LIBDIRSUFFIX}$VERSION $VL_VERSION $BUILDNUM"
#--------------------------------------------

if [ $UID != 0 ]; then
   echo "You are not authorized to run this script. Please login as root"
   exit 1
fi

#GET THE SOURCE
#--------------------------------------------
for SRC in $(echo $LINK);do
if [ ! -f $CWD/$(basename $SRC) ]
then
        wget --no-check-certificate -c $SRC
fi
done
#--------------------------------------------

rm -rf $PKG
cd $TMP
rm -rf $NAME-$VERSION

#EXTRACT SOURCES
#-----------------------------------------------------
echo "Extracting source..."
mkdir -p $NAME-$VERSION || exit 1
cd $TMP/$NAME-$VERSION || exit 1
tar xvf $CWD/$NAME.tar.xz || exit 1
#-----------------------------------------------------

#SET PERMISSIONS
#-----------------------------------------
echo "Setting permissions..."
chown -R root:root .
find . -perm 664 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 2777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 2755 -exec chmod 755 {} \;
find . -perm 774 -exec chmod 644 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 600 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 400 -exec chmod 644 {} \;
find . -perm 440 -exec chmod 644 {} \;
find . -perm 511 -exec chmod 755 {} \;
find . -perm 711 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
#-----------------------------------------

#CONFIGURE & MAKE
#----------------------------------------------------------------------

DISTRO=$(echo $CONFIGURE_TRIPLET|cut -d'-' -f2)
echo $DISTRO

echo "Configuring source..."
mkdir -p ISO/packages/xconf/
#get the pkgs. we have a list in $CWD/pkgs. slapt-get from repo?
slapt-get --update
for i in $(cat $CWD/pkgs);do
  dir=$(echo $i|cut -d'/' -f1)
  pkg=$(echo $i|cut -d'/' -f2)
  slapt-get --install --reinstall --download-only --no-dep $pkg
  #mv the pkgs.
  mv /home/ftp/pub/veclinux/packages/$pkg*t?z ISO/packages/$dir/ || exit 1
done

#mv the kernel from the kernel-pkg to the iso.
cd ISO/packages/
mkdir PKG
cd PKG
kern="$(ls ../a/kernel-[0-9]*txz)"
echo "Using $kern"
explodepkg $kern || exit 1
mv -v boot/vmlinuz* ../../isolinux/kernel/sata || exit 1
sed -i '/^if/d' install/doinst.sh
sed -i '/^fi/d' install/doinst.sh
makepkg -l y -c n $kern
cd ../ && rm -r PKG
kern_ver=$(echo $kern|cut -d'-' -f2)

#Create PACKAGES.TXT in the iso.
./makeinfo-slack all
./makeinfo-slapt all
cd $TMP/$NAME-$VERSION

#copy the veclinux folder to the ISO.
cp -r $CWD/veclinux ISO

#set the version
sed -i "s/VERSION/$REL/g" ISO/veclinux/VINSTALL.INI
sed -i "s/KERNEL/$kern_ver/g" ISO/veclinux/VINSTALL.INI
sed -i "s/DATE/$(date +%b-%d-%Y)/g" ISO/veclinux/VINSTALL.INI
sed -i "s/RELID/$(date +%m%d%Y)/g" ISO/veclinux/VINSTALL.INI

#Make initrd with modules that match kernel
installpkg ISO/packages/a/kernel-modules-$kern_ver*txz
mkdir -v $TMP/INITRD && cd $TMP/INITRD
lzcat $CWD/pyinit.lz|cpio -id 
rm -r lib/modules/*
cp -v $CWD/modules .
sh modules $kern_ver
cp -r $CWD/$THEME /etc/bootsplash/themes/
echo "Creating $THEME splash file"
splash -s -f /etc/bootsplash/themes/$THEME/config/bootsplash-800x600.cfg >../bootsplash
echo "Creating initrd"
find . | cpio -o -H newc >../init-sm 
cd ..
echo "Appending bootsplash to initrd"
echo bootsplash | cpio -o -H newc >> init-sm
echo "Compressing initrd"
xz -F lzma init-sm 
mv -v init-sm.lzma $TMP/$NAME-$VERSION/ISO/isolinux/init.lz 
echo "initrd created"
cd $TMP/$NAME-$VERSION

#copy the ISO splash and message
cp -v $CWD/$DISTRO/* ISO/isolinux/

#create the iso.
echo "Creating NEW ISO $CDNAME"
mkisofs -o "$RELEASEDIR/$CDNAME" -v -J -R -D -A "$CDLABEL" -V "$CDLABEL" \
-no-emul-boot -boot-info-table -boot-load-size 4 \
-b isolinux/isolinux.bin -c isolinux/isolinux.boot ISO

cd $RELEASEDIR
md5sum $CDNAME >$CDNAME.md5sum.txt
#######################################################################
#Miscellenious tweaks and things outside a normal ./configure go here #
#######################################################################

cd $CWD
echo "Cleaning up temp files..." && rm -rf $TMP
done
if [ $PREV32ISO ];then
  echo "Generating Delta from $PREV32ISO"
  cd $RELEASEDIR
  wget 10.0.2.2/pkg/untested/veclinux-7.1/iso/$PREV32ISO
  wget 10.0.2.2/pkg/untested/veclinux-7.1/iso/$PREV32ISO.md5sum.txt
  if md5sum -c $PREV32ISO.md5sum.txt;then
    echo "Generating Delta ${PREV32ISO%iso}to$BUILDNUM.delta"
    xdelta delta $PREV32ISO $CD32NAME ${PREV32ISO%.iso}to$BUILDNUM.delta
  fi
  rm $PREV32ISO*
fi
if [ $PREV64ISO ];then
  echo "Generating Delta from $PREV64ISO"
  cd $RELEASEDIR
  wget 10.0.2.2/pkg/untested/veclinux-7.1/iso/$PREV64ISO
  wget 10.0.2.2/pkg/untested/veclinux-7.1/iso/$PREV64ISO.md5sum.txt
  if md5sum -c $PREV64ISO.md5sum.txt;then
    echo "Generating Delta ${PREV64ISO%iso}to$BUILDNUM.delta"
    xdelta delta $PREV64ISO $CD64NAME ${PREV64ISO%.iso}to$BUILDNUM.delta
  fi
  rm $PREV64ISO*
fi
ls
echo "Package Complete"
fi
#--------------------------------------------------------------

# vim: set tabstop=4 shiftwidth=4 foldmethod=marker : ##
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.