WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: A simple build script for TC  (Read 3937 times)

Offline Kingdomcome

  • Sr. Member
  • ****
  • Posts: 286
A simple build script for TC
« on: October 26, 2009, 08:27:38 PM »
This is the blank ash script that I use as a base for building my extensions. Fill in the variables at the top and add comments to the info file at the bottom.  It expects to find a copyright notice name "COPYING" in the root of the extracted source. Most variables are self explanatory, others will be explained better soon.  If you wish to have a post-install script, menu entry or icon simply uncomment the appropriate sections and fill in. I typically manually download the source and the compiletc extension to determine necessary deps, builddeps and configure flags, then reboot base norestore and run the script as root.

Code: [Select]
#!/bin/sh

[ `id -u` = 0 ] || { echo "must be root"; exit 1; }

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

TODAY=`date +%Y/%m/%d`
MIRROR=""
PACKAGE=""
SEP=""
VERSION=""
EXT=""
DESCRIPTION="        (TESTING)"
AUTHORS=""
HOMEPAGE=""
LICENSE=""
ME=""
DEPS=""
BUILDDEPS=""
FLAGS="--prefix=/usr/local"
DOCS=""

TCUSER=`cat /etc/sysconfig/tcuser`
SRC="${PACKAGE}${SEP}${VERSION}.tar.gz"
THISDIR=`pwd`
PKGDIR="${THISDIR}/${PACKAGE}"
SRCDIR="${PKGDIR}/${PACKAGE}${SEP}${VERSION}"

environment(){
   for each in compiletc.tcz squashfs-tools-4.0.tcz ${DEPS} ${BUILDDEPS}; do
      sudo -u ${TCUSER} tce-load -w -i ${each}
   done
   [ -d "${PKGDIR}" ] && rm -rf ${PKGDIR}
   mkdir -p ${PKGDIR}/tmp
   cd ${PKGDIR} && wget ${MIRROR}${SRC}
   tar xzf ${SRC}
}

buildit(){
   cd ${SRCDIR}
   ./configure ${FLAGS}
   make
   touch /tmp/mark
   make DESTDIR=${PKGDIR}/tmp install
}

workit(){
   if [ "`ls -A ${PKGDIR}/tmp`" ]; then
      rm /tmp/mark
   else
      cd /
      find usr/ -newer /tmp/mark -not -type d > /tmp/${PACKAGE}.list
      tar czO -T /tmp/${PACKAGE}.list | tar xzf - -C ${PKGDIR}/tmp
      rm /tmp/${PACKAGE}.list
   fi

   cd ${PKGDIR}/tmp
   rm -rf ${DOCS}

   mkdir -p usr/local/share/doc/License
   cp ${SRCDIR}/COPYING usr/local/share/doc/License/${PACKAGE}.txt

   find usr/ | xargs file | grep "executable" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
   find usr/ | xargs file | grep "shared object" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip -g 2> /dev/null

#   mkdir -pm 775 usr/local/tce.installed
#cat <<EOF> usr/local/tce.install/${PACKAGE}
##!/bin/sh

#EOF
#   chmod 775 usr/local/tce.installed/${PACKAGE}

#   mkdir -pm 775 usr/local/tce.menu
#cat <<EOF> usr/local/tce.menu/${PACKAGE}
#<JWM>
#  <Program label=" "></Program>
#</JWM>
#EOF
#   chmod 644 usr/local/tce.menu/${PACKAGE}

#   mkdir -pm 775 usr/local/tce.icons
#cat <<EOF> usr/local/tce.icons/${PACKAGE}
#i:
#t:
#c:
#EOF
#   chmod 644 usr/local/tce.icons/*

#dont clobber tc setup
#   chown -R root:staff usr/local/tce.*

#package specific stuff

}

packageit(){
   cd ${PKGDIR}/tmp
   for dir in `ls -A`; do
      find ${dir} -not -type d | sort >> ../${PACKAGE}.${EXT}.list
   done

   mksquashfs . ../${PACKAGE}.${EXT}

   cd ${PKGDIR}
   md5sum ${PACKAGE}.${EXT} > ${PACKAGE}.${EXT}.md5.txt

   [ -f "${PACKAGE}.${EXT}.dep" ] && rm -f ${PACKAGE}.${EXT}.dep
   for each in ${DEPS}; do echo ${each} >> ${PACKAGE}.${EXT}.dep; done

   size=`du -h ${PACKAGE}.${EXT} | cut -f 1`

cat <<EOF> ${PACKAGE}.${EXT}.info
Title: ${PACKAGE}.${EXT}
Description: ${DESCRIPTION}
Version: ${VERSION}
Author: ${AUTHORS}
Original-site: ${HOMEPAGE}
Copying-policy: ${LICENSE}
Size: ${size}
Extension_by: ${ME}
Comments:


This extension is PPI compatible
Change-log: ----
Current: ${TODAY} First Version
EOF
}

#here we go

environment
buildit
workit
packageit

This first post and attachment will always be edited to be current.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: A simple build script for TC
« Reply #1 on: October 27, 2009, 02:32:37 AM »
I was thinking a cute addition might be specific ./configure options :  

# Add to buildit()  

./configure --help

echo ""
echo "enter additional ./config options (eg. "--option1 --option2" )"
read OPTIONS

./configure ${FLAGS} ${OPTIONS}
« Last Edit: October 27, 2009, 02:39:10 AM by jpeters »

Offline Kingdomcome

  • Sr. Member
  • ****
  • Posts: 286
Re: A simple build script for TC
« Reply #2 on: October 27, 2009, 09:12:58 AM »
As I said in my first post, I manually download the app source and run ./configure --help to determine which flags to use so that I can add them to the FLAGS variable.  This script is designed more to be a final product than a testbed.  Do all your testing and figuring out by hand, then just fill in the variables and info section.  Then the script could be included in the extension submission and anyone could download it and run it from a "base norestore" boot and end up with a working extension.  Having the script read configure flags would not 1) run unattended or complete automatically, or 2) allow someone else to follow your work in case you are not available later on.

K.I.S.S. - you gotta do the work to find the source and fill in the variables for it, why not just unpack it, see whats inside, and at least run ./configure --help before even starting to fill in the script.