#!/bin/bash ########################################################## #VBuild - Package build script for use on VectorLinux 5.8# ########################################################## #Eugene Suter # #You are free to modify this scrip under the terms of the# #GNU General Public License. # ########################################################## TMP=/tmp CWD=`pwd` NAME=lm_sensors VERSION=2.10.3 ARCH=i586 RELEASE=6vl58 SYSCONF=/etc PREFIX=/usr BUILD_DIR=${TMP}/${NAME}-package REBUILD_DIR=${BUILD_DIR}/rebuild TARBALL_NAME=${NAME}-${VERSION}.tar.* #Chose between tgz, tlz org tbz package formats here. PKG_FORMAT=.tlz PKG_DEST=${TMP}/finished-packages PKG_NAME=${NAME}-${VERSION}-${ARCH}-${RELEASE}${PKG_FORMAT} CLEANUP=Y VL_PACKAGER=easuter #Check if user has super user privilages: if [ ${UID} != 0 ]; then echoc "You need to be root to run this script." red exit fi #We will be needinf reauiredbuilder for dependency tracking #so if its not installed, abort: if [ ! -f /usr/bin/requiredbuilder ]; then echoc "Requiredbuilder is not installed, the package won't be built." red exit fi #Make sure the packages have their own directory: if [ ! -d ${PKG_DEST} ]; then mkdir -p ${PKG_DEST} fi #Clean out the build space first and then make the #necessary directories, extract the sources and enter the #package source tree: rm -rf ${BUILD_DIR} mkdir -p ${BUILD_DIR} mkdir -p ${REBUILD_DIR} cd ${BUILD_DIR} cp ${CWD}/${TARBALL_NAME} ./ tar xvf ${BUILD_DIR}/${TARBALL_NAME} cd ${NAME}-${VERSION} if [ $ARCH = "i586" ]; then export CFLAGS="-O2 -mtune=i686 -march=i586" fi if [ $ARCH = "i486" ]; then export CFLAGS="-O2 -mtune=i686 -march=i486" fi if [ $ARCH = "i386" ]; then export CFLAGS="-O2 -mtune=i686 -march=i386" fi export CXXFLAGS="$CFLAGS" #Give root ownership of the files: chown -R root.root ./ #lm_sensors doesn't use a standard "configure,make,make install", #not to mention the Makefile doesn' "catch" the PREFIX if you add #it as a compile time option so its best to use a modified Makefile for #everything to work smoothly: rm Makefile cp ${CWD}/Makefile_prefix-usr ./Makefile make user #Build the sources and exit if it fails. if ( ! make user ); then echoc "Make failed!" red exit fi make DESTDIR=${REBUILD_DIR} user_install cd ${REBUILD_DIR} mkdir ./install cp ${CWD}/slack-desc ./install #Add the init scripts: mkdir ./etc/rc.d cp ${CWD}/fancontrol.init ./etc/rc.d/rc.fancontrol cp ${CWD}/lm_sensors.vl_init ./etc/rc.d/rc.lm_sensors chown root.root ./etc/rc.d/rc.* chmod +x ./etc/rc.d/rc.* cat >> ./install/slack-desc << EOF #---------------------------------------- BUILDDATE: `date` PACKAGER: $VL_PACKAGER HOST: `uname -srm` DISTRO: `cat /etc/vector-version` CFLAGS: $CFLAGS CONFIGURE: `awk "/\.\/configure\ /" config.log` EOF requiredbuilder -v -y ./ makepkg -l y -c n ${PKG_NAME} cp ${PKG_NAME} ${PKG_DEST} #Do some spring-cleaning (or not): if [ $CLEANUP = "Y" ]; then rm -rf $BUILD_DIR fi #EOF