WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Xscreensaver - build scripts  (Read 2963 times)

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Xscreensaver - build scripts
« on: December 22, 2009, 05:59:04 PM »
In case you want to do your own build of Xscreensaver (v 5.10 in repo), these are the scripts I've used. Xscreensaver does -not- support DESTDIR, so expect the extra steps of touch/find/tar/tar ... then reboot for safety.

If you just want to add some savers to your own 'base' version, don't do a complete rebuild. Use unsquashfs/mksquashfs as in the 'split-xscreensaver.sh' script below for help.

Many thanks to bmarkus for posting his own extension building script for libidn (http://forum.tinycorelinux.net/index.php?topic=3038.0). That's a great starting point for anyone doing similar work.

EDIT: scripts in this post are from ~ TC 2.7. Updated for 3.0 down below (log in to download).

build-xscreensaver.sh
Code: [Select]
#!/bin/sh

##########################
#
# build-xscreensaver.sh
# script originally written by bmarkus (9/2009)
# edited to build xscreensaver 5.10 (dentonlt, 12/2009)
#
# tested on TC 2.7
#
##########################

#########################
# useful variables
#########################
SOURCEFILE="xscreensaver-5.10.tar.gz"
TCEDIR=`cat /opt/.tce_dir`/optional
TMPDIR=/tmp/pkg
WRKDIR=`basename "$SOURCEFILE" .tar.gz`
EXTNAM="$WRKDIR"
EXTTYPE="" #append l or m if needed
CLEANUP=1

#######################
# Extensions required for build
#########################
REQUIRED_EXTENSIONS="compiletc
gtk2-dev
libglade-dev
libglade
bc-1.06.94
Xorg-7.4-dev
squashfs-tools-4.0
"

##############
# FUNCTIONS
##############

loadextension () {

FILE="$1"

[ -f "$TCEDIR"/"$FILE".tcz ] && tce-load -i "$TCEDIR"/"$FILE".tcz && FILE="$NULL"
[ -f "$TCEDIR"/"$FILE".tczl ] && tce-load -i "$TCEDIR"/"$FILE".tczl && FILE="$NULL"
[ -f "$TCEDIR"/"$FILE".tczm ] && tce-load -i "$TCEDIR"/"$FILE".tczm && FILE="$NULL"

if [ "$FILE" != "$NULL" ]; then
echo "Error finding "$FILE" extension. Check /opt/.tce_dir and your mounts. Exiting."
exit 1
fi
}



#################
# MAIN TYPE STUFF
#################

# find source file
###############

# check for source file
#####################
[ ! -f "$SOURCEFILE" ] && echo "Run build in the same directory as source file ("$SOURCEFILE" not found)." && exit 1

# check for base
######################
if [ "`grep base /proc/cmdline`" == "$NULL" ]; then
read -p "You should probably run with kernel arg base. Sure you want to continue? " ANS
[ "$ANS" != "y" ] && [ "$ANS" != "Y" ] && echo "Bailing out." && exit 1
fi

# check whether to clean up afterward
#####################
read -p "Do you want me to clean up things as I finish? " ANS
[ "$ANS" == "n" ] || [ "$ANS" == "N" ] && CLEANUP=0


# check for required extensions
###################
for EXT in `echo $REQUIRED_EXTENSIONS`
do
if [ ! -f "/usr/local/tce.installed/"$EXT"" ]; then
echo "Extension "$EXT" is required. Trying to install."
loadextension "$EXT"
fi
done

# clean & remake temp/pkg directory
###################################
[ "$CLEANUP" == "1" ] && rm -rf $TMPDIR
mkdir $TMPDIR


# do the build! (this section as written out by bmarkus)
# see his posting online at the tinycore forum
#####################################

# Export variables needed for compilation

export CFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig

# Unpack source in current directory

tar -xf $SOURCEFILE

# Configure it

cd $WRKDIR
./configure --prefix=/usr/local PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig

read -p "Pausing after configure. Press q to bail, or anything else to run make. " ANS
[ "$ANS" == "q" ] || [ "$ANS" == "Q" ] && echo "Bailing out - you need to clean up the mess!" && exit 1

# Compile

make

read -p "Pausing after make. Press q to bail, or anything else to run make install. " ANS
[ "$ANS" == "q" ] || [ "$ANS" == "Q" ] && echo "Bailing out - you need to clean up the mess!" && exit 1

# Install in base temp dir
TIMESTAMP="/tmp/mark$$"
touch "$TIMESTAMP"
make install DESTDIR=$TMPDIR

read -p "Before I squash up the extension files ... did DESTDIR work? Assume no if you're not sure. (y/n) " ANS

if [ "$ANS" == "n" ] || [ "$ANS" == "N" ]; then
read -p "Hmm. Do you want me to try and sudo make install? " SUIT
if [ "$SUIT" == "y" ] || [ "$SUIT" == "Y" ]; then
sudo make install
fi
echo "I'll try to find and gather all the new files to the temp directory."
find /usr/local -not -type d -newer "$TIMESTAMP" > /tmp/filelist
tar -T /tmp/filelist -czvf /tmp/pkg.tar.gz
tar -C "$TMPDIR"/ -xzf /tmp/pkg.tar.gz
[ "$CLEANUP" == "1" ] && rm -r -f "$TIMESTAMP"
[ "$CLEANUP" == "1" ] && rm -r -f /tmp/filelist
[ "$CLEANUP" == "1" ] && rm -r -f /tmp/pkg.tar.gz
fi # end DESTDIR failed

#PROCEED AS NORMAL ...

# Delete compilation work directory

cd ..
[ "$CLEANUP" == "1" ] && rm -r -f $WRKDIR

# Remove unneeded dirs and files

# Adjust directory access rigths

find $TMPDIR/ -type d | xargs chmod -v 755;

# Strip executables

find $TMPDIR | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded

# Move files to doc extension

mkdir -p $TMPDIR-doc/usr/local/share
[ -d "$TMPDIR/usr/local/share/man" ] && mv $TMPDIR/usr/local/share/man $TMPDIR-doc/usr/local/share
[ -d "$TMPDIR/usr/local/share/info" ] && mv $TMPDIR/usr/local/share/info $TMPDIR-doc/usr/local/share
[ -d "$TMPDIR/usr/local/share/emacs" ] && mv $TMPDIR/usr/local/share/emacs $TMPDIR-doc/usr/local/share

# Move files to dev extension

mkdir -p $TMPDIR-dev/usr/local/lib
[ -d "$TMPDIR/usr/local/include" ] && mv $TMPDIR/usr/local/include $TMPDIR-dev/usr/local
[ -e "$TMPDIR/usr/local/lib/*.a" ] && mv $TMPDIR/usr/local/lib/*.a $TMPDIR-dev/usr/local/lib
[ -e "$TMPDIR/usr/local/lib/*.la" ] && mv $TMPDIR/usr/local/lib/*.la $TMPDIR-dev/usr/local/lib
[ -d "$TMPDIR/usr/local/lib/pkgconfig" ] && mv $TMPDIR/usr/local/lib/pkgconfig $TMPDIR-dev/usr/local/lib

# Move files to locale extension

mkdir -p $TMPDIR-locale/usr/local/share
mv $TMPDIR/usr/local/share/locale $TMPDIR-locale/usr/local/share

###################################################
# Create base extension in temp dir               #
###################################################

cd $TMPDIR
cd ..
mksquashfs $TMPDIR "$EXTNAM".tcz$EXTYPE
cd $TMPDIR
find usr -not -type d > "$EXTNAM".tcz$EXTYPE.list
mv ../"$EXTNAM".tcz$EXTYPE .

# Create md5 file

md5sum "$EXTNAM".tcz$EXTYPE > "$EXTNAM".tcz$EXTYPE.md5.txt

# Cleanup temp directory

[ "$CLEANUP" == "1" ] && rm -r -f usr  

###################################################
# Create doc extension in temp dir                #
###################################################

cd $TMPDIR-doc
cd ..
mksquashfs $TMPDIR-doc $EXTNAM-doc.tcz
cd $TMPDIR-doc
find usr -not -type d > $EXTNAM-doc.tcz.list
mv ../$EXTNAM-doc.tcz .

# Create md5 file

md5sum $EXTNAM-doc.tcz > $EXTNAM-doc.tcz.md5.txt

# Cleanup temp directory

[ "$CLEANUP" == "1" ] && rm -r -f usr  

###################################################
# Create dev extension in temp dir                #
###################################################

cd $TMPDIR-dev
cd ..
mksquashfs $TMPDIR-dev $EXTNAM-dev.tcz
cd $TMPDIR-dev
find usr -not -type d > $EXTNAM-dev.tcz.list
mv ../$EXTNAM-dev.tcz .

# Create md5 file

md5sum $EXTNAM-dev.tcz > $EXTNAM-dev.tcz.md5.txt

# Cleanup temp directory

[ "$CLEANUP" == "1" ] && rm -r -f usr  

###################################################
# Create locale extension in temp dir             #
###################################################

cd $TMPDIR-locale
cd ..
mksquashfs $TMPDIR-locale $EXTNAM-locale.tcz
cd $TMPDIR-locale
find usr -not -type d > $EXTNAM-locale.tcz.list
mv ../$EXTNAM-locale.tcz .

# Create md5 file

md5sum $EXTNAM-locale.tcz > $EXTNAM-locale.tcz.md5.txt

# Cleanup temp directory

[ "$CLEANUP" == "1" ] && rm -r -f usr


split-xscreensaver.sh
Code: [Select]
#!/bin/sh

################
#
# split-xscreensaver.sh
# take xscreensaver-5.10.tcz and create -extra and -base extensions
# dentonlt 12/2009
#
##################

TCEDIR=`cat /opt/.tce_dir`
ORIGINAL="xscreensaver-5.10.tcz"
BASEFILES="bumps
cloudlife
fireworkx
metaballs
rocks
speedmine
strange
substrate
xmatrix
xrayswarm
"

# find source extension
########################
[ ! -f "xscreensaver-5.10.tcz" ] && echo "I can't find "$ORIGINAL" to chop." && exit 1

# check for squash
##################

if [ ! -f "/usr/local/tce.installed/squashfs-tools-4.0" ]; then
echo "Need squash fs tools. Installing."

FILE="squashfs-tools-4.0.tcz"
[ -f "$TCEDIR"/"$FILE".tcz ] && tce-load -i "$TCEDIR"/"$FILE".tcz && FILE="$NULL"

[ "$FILE" != "$NULL" ] && echo "Error loading "$FILE". Bailing out." && exit 1
fi

# unpack original to temp dir
############################

unsquashfs "$ORIGINAL"

# create 'extra' folder structure
###############################

mkdir extra
mkdir extra/usr
mkdir extra/usr/local
mkdir extra/usr/local/libexec
mkdir extra/usr/local/libexec/xscreensaver
mkdir extra/usr/local/share
mkdir extra/usr/local/share/xscreensaver
mkdir extra/usr/local/share/xscreensaver/config

# move things into the 'extra' structure
#################################

echo "Splitting."

CONFIGDIR="usr/local/share/xscreensaver/config"
BINDIR="usr/local/libexec/xscreensaver"

for FILE in `echo "$BASEFILES"`
do
if [ -f "squashfs-root/"$CONFIGDIR"/"$FILE".xml" ]; then
mv squashfs-root/"$CONFIGDIR"/* extra/"$CONFIGDIR"
mv extra/"$CONFIGDIR"/"$FILE".xml squashfs-root/"$CONFIGDIR"/"$FILE".xml
fi
if [ -f "squashfs-root/"$BINDIR"/"$FILE"" ]; then
mv squashfs-root/"$BINDIR"/* extra/"$BINDIR"
mv extra/"$BINDIR"/"$FILE" squashfs-root/"$BINDIR"/"$FILE"
fi
done

# create file lists
###########################

find squashfs-root/ -not -type d > xscreensaver-5.10-base.tcz.list
find extra/ -not -type d > xscreensaver-5.10-extra.tcz.list

# create tcz files
###########################

mksquashfs squashfs-root xscreensaver-5.10-base.tcz
mksquashfs extra xscreensaver-5.10-extra.tcz

# create md5 sums
##########################
md5sum xscreensaver-5.10-base.tcz > xscreensaver-5.10-base.tcz.md5.txt
md5sum xscreensaver-5.10-extra.tcz > xscreensaver-5.10-extra.tcz.md5.txt

# cleanup
############################
rm -rf extra
rm -rf squashfs-root
« Last Edit: July 30, 2010, 10:40:45 PM by dentonlt »

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 9730
Re: Xscreensaver - build scripts
« Reply #1 on: March 15, 2010, 09:23:39 AM »
Looking at the Slackbuild of Xscreensaver it uses

make install_prefix=$PKG install

to install into $PKG instead of destdir.

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Xscreensaver - build scripts
« Reply #2 on: July 30, 2010, 10:42:09 PM »
Updated build scripts for Xscreensaver.

Uses same Xscreensaver version (5.10) but updated to Xorg 7.5 and dependencies for TC 3.0.

Also updated the 'split' script for simplicity, filenames.

Log in to download.