#!/bin/sh [ `id -u` != 0 ] && { echo "fail"; 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 ### these variables are used to name the extension, populate info file, ### and download source. examples given if the source is located at: ### http://what.ever.com/pub/linux/package-1.2.1.tar.gz ### ie: "http://what.ever.com/pub/linux/ mirror="http://www.thekelleys.org.uk/dnsmasq/" ### ie: "package" basename="dnsmasq" ### ie: "-" sep="-" ### ie: "1.2.1" version="2.49" description="DnsMasq (TESTING)" author="Simon Kelley" license="GPL" homepage="http://www.thekelleys.org.uk/dnsmasq/doc.html" extensionby="Kingdomcome" comments="A lightweight DNS server with optional integrated DHCP server\n\t\t\tCreate a config file /usr/local/etc/dnsmasq.conf\n\t\t\tExample config file located at /usr/local/etc/dnsmasq.conf.example" ### comment this variable out if the extension is not PPI compatible ppicompat="\n\n\t\t\tThis extension is PPI compatible" date=`date +%Y/%m/%d` ### specify tc{e,z}, tc{e,z}l, tc{e,z}m, or tc{e,z}lm here tce="tce" tcz="tcz" ####### Any variables below that are not needed should be commented out ### list the extensions separated by a space that this extension depends on #eval ${tce}deps="" #eval ${tcz}deps="" ### this list includes all the possible extensions needed for compiling ### this list could possibly be sorted better for easier commenting out ### of unneeded groups of compiling components compiledeps="compiletc.tce advcomp.tce squashfs-tools-4.0.tce" ### list the extensions that will be necessary during build ### including runtime deps and *-devs #builddeps="" ### list any files that will need to remain writable in the tcz[l,m] #writeables="" ### if the package includes a configure script list necessary flags here ### ie: "-prefix=/usr/local/" #flags="" ### otherwise insert a full sed command to edit the Makefile. ### ie: 'sed -i -e s_/usr_bin/_/usr/local/bin/_ -e s_/usr/sbin/_/usr/local/sbin/_ Makefile' editMake='sed -i 's_\"/etc/dnsmasq.conf\"_\"/usr/local/etc/dnsmasq.conf\"_' src/config.h' ### list relative paths to any help or man files ### ie: "usr/local/man usr/local/share/man" docs="usr/local/share/man" ### write post install script here if necessary using inline formatting #postinstall='#!/bin/sh\n\n' ## prepare environment for i in ${compiledeps} ${builddeps}; do su - tc -c "tce-wget ${i}"; done [ -d $basename ] || mkdir ${basename} cd ${basename}/ && rm -rf ./* pwd=`pwd` mkdir -p tmp/package #download and extract source wget ${mirror}${basename}${sep}${version}.tar.gz && tar xzf ${basename}${sep}${version}.tar.gz cd ${basename}${sep}${version}/ ## build, locate and strip package if [ "${flags}" ]; then ./configure ${flags} else ${editMake} || exit 1 fi #make touch /tmp/mark sleep 2 make install [ -d /usr/local/etc/ ] || mkdir -p /usr/local/etc/ cp dnsmasq.conf.example /usr/local/etc/ sleep 3 if [ "$(ls -A ${pwd}/tmp/package/)" ]; then rm /tmp/mark fi if [ -e /tmp/mark ]; then cd / find usr/ -newer /tmp/mark | xargs file | grep "executable" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find usr/ -newer /tmp/mark | xargs file | grep "shared object" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip -g 2> /dev/null else cd ${pwd}/tmp/package/ 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 fi ## remove docs and create post-install script rm -rf ${docs} if [ "${postinstall}" ]; then mkdir usr/local/tce.installed/ echo -e "${postinstall}" > usr/local/tce.installed/${basename} chmod 755 usr/local/tce.installed/${basename} fi ## create tce if [ -e /tmp/mark ]; then find usr/ -newer /tmp/mark -not -type d > ${pwd}/${basename}.${tce}.list else for dirs in `ls -A`; do find ${dirs} -not -type d > ${pwd}/${basename}.${tce}.list done fi tar czvf ${pwd}/${basename}.${tce} --numeric-owner -T ${pwd}/${basename}.${tce}.list advdef -z4 ${pwd}/${basename}.${tce} ## create tcz if [ -e /tmp/mark ]; then cd ${pwd}/tmp/package && tar xzf ${pwd}/${basename}.${tce} fi if [ "${writables}" ]; then for files in ${writeables}; do find usr/ -not -type d -name ${files} >> ../rwfiles.list; done tar czvf user.tar.gz --numeric-owner -T ../rwfiles.list && advdef -z4 user.tar.gz for files in `cat ../rwfiles.list`; do rm -f ${files}; done rm -f ../rwfiles.list fi mksquashfs ./ ${pwd}/${basename}.${tcz} cp ${pwd}/${basename}.${tce}.list ${pwd}/${basename}.${tcz}.list ## md5, dep, and info files cd ${pwd} for ext in ${tce} ${tcz}; do md5sum ${basename}.${ext} > ${basename}.${ext}.md5.txt eval deps=\${${ext}deps} if [ "${deps}" ]; then for files in ${deps}; do echo ${files} >> ${basename}.${ext}.dep; done fi eval ${tce}comments="'${comments}${ppicompat}'" eval ${tcz}comments="'${comments}'" eval thecomments=\${${ext}comments} echo -e "Title:\t\t\t${basename}.${ext}\nDescription:\t\t${description}\nVersion:\t\t${version}\nAuthor:\t\t\t${author}" > ${basename}.${ext}.info echo -en "Original-site:\t\t${homepage}\nCopying-policy:\t\t${license}\nSize:\t\t\t" >> ${basename}.${ext}.info du -sh ${basename}.${ext} | cut -f 1 >> ${basename}.${ext}.info echo -e "Extension_by:\t\t${extensionby}\nComments:\t\t${thecomments}\nChange-log:\t\t----\nCurrent:\t\t${date} First Version" >> ${basename}.${ext}.info done ## clean up package files rm -rf ${pwd}/${basename}${sep}${version}/ ${pwd}/${basename}${sep}${version}.tar.gz rm -rf ${pwd}/tmp/ /tmp/mark && echo "Everything is in ${basename}/" exit 0