WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Build script to create extension  (Read 7818 times)

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Build script to create extension
« on: September 16, 2009, 01:27:31 PM »
This is my actual build script used to create libidn extension. While extensions may require modification of the script it can be a good startup.

According to the new rules it creates .tcz only using quashfs. There are four extensions created:

1) base - this contains files needed to use the program
2) dev - additional files required to compile other programs depending on this
3) doc - doc files
4) locale - language files

Of course depending on the program certain extensions are not necessary to create, except base.


Quote

#!/bin/sh
#
######################################################
# libidn                                             #
#                                                    #
# Build script for TinyCore 2.x                      #
#                                                    #
# See .info for details                              #
#                                                    #
# September 16, 2009                                 #
######################################################

######################################################
# Configure extension creation parameters            #
######################################################

SRCNAM=libidn-1.15.tar.gz
WRKDIR=libidn-1.15
EXTNAM=libidn
TMPDIR=/tmp/libidn
EXTYPE="l"

######################################################
# Prepare extension creation                         #
######################################################

# Remove dirs and files left from previous creation

rm -r -f $WRKDIR

rm -r -f $TMPDIR
rm -r -f $TMPDIR-doc
rm -r -f $TMPDIR-dev
rm -r -f $TMPDIR-locale

# Crete temporary directory

mkdir -p $TMPDIR

######################################################
# Compile extension                                  #
######################################################

# 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 $SRCNAM

# Configure it

cd $WRKDIR
./configure --prefix=/usr/local

# Compile

make

# Install in base temp dir

make install DESTDIR=$TMPDIR

# Delete compilation work directory

cd ..
rm -r -f $WRKDIR

# Remove unneded 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
mv $TMPDIR/usr/local/share/man $TMPDIR-doc/usr/local/share
mv $TMPDIR/usr/local/share/info $TMPDIR-doc/usr/local/share
mv $TMPDIR/usr/local/share/emacs $TMPDIR-doc/usr/local/share

# Move files to dev extension

mkdir -p $TMPDIR-dev/usr/local/lib
mv $TMPDIR/usr/local/include $TMPDIR-dev/usr/local
mv $TMPDIR/usr/local/lib/*.a $TMPDIR-dev/usr/local/lib
mv $TMPDIR/usr/local/lib/*.la $TMPDIR-dev/usr/local/lib
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

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

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

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

rm -r -f usr

EDIT: .filelist changed to .list upon advice of JW
« Last Edit: September 16, 2009, 03:13:16 PM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline MikeLockmoore

  • Hero Member
  • *****
  • Posts: 525
  • Good software needn't be big!
Re: Build script to create extension
« Reply #1 on: September 16, 2009, 10:17:46 PM »
Looks like a nice generalized approach.  I think I'll use this as a template in the future.
--
Mike L.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Build script to create extension
« Reply #2 on: September 17, 2009, 09:24:31 PM »
In general, I've found installing to temp destinations problematic. 

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: Build script to create extension
« Reply #3 on: September 17, 2009, 10:11:34 PM »
In general, I've found installing to temp destinations problematic. 
Could you be more specific?
big pc man

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Build script to create extension
« Reply #4 on: September 18, 2009, 12:41:31 AM »
In general, I've found installing to temp destinations problematic. 
Could you be more specific?

Links in the extension can end up pointing to the temp destination. Using touch /tmp/mark before installing, and finding with -newer /tmp/mark ensures all the links will be where you want them.
« Last Edit: September 18, 2009, 12:43:43 AM by jpeters »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Build script to create extension
« Reply #5 on: September 18, 2009, 01:20:39 AM »
To be precise the problem is not /tmp but installing to any location different than final. True, but this is just a minority of sources. Anyhow, you must check the result always and adjust the scipt to the given case.

All of my posted extensions were compiled with a kind of this script, never used mark.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Build script to create extension
« Reply #6 on: September 18, 2009, 05:39:02 AM »
To be precise the problem is not /tmp but installing to any location different than final. T

"temp" meaning "temporary" ...not the /tmp directory  :)   

Offline Kingdomcome

  • Sr. Member
  • ****
  • Posts: 286
Re: Build script to create extension
« Reply #7 on: September 18, 2009, 07:58:55 AM »
many packages obey the "DESTDIR=" flag passed on the "make install" line which makes installing to a temp location for packaging purposes very easy as noted in the wiki.  for the packages that do not, the "touch /tmp/mark" method has worked well for me.