#!/bin/sh # ###################################################### ## Build script for Core 13.x # ## # ## See .info for details # ###################################################### ###################################################### # Configure extension creation parameters # ###################################################### # Variables EXTNAM=logrotate VERSION="3.19.0" SRCNAM=$EXTNAM-$VERSION.tar.xz WRKDIR=$EXTNAM-$VERSION BASEDIR=/tmp/$EXTNAM SRCDIR=/tmp/$EXTNAM/source TMPDIR=/tmp/$EXTNAM/package DESTDIR=/tmp/$EXTNAM/build TODAY=`date +%Y/%m/%d` DESCRIPTION="logrotate utility, automatic rotation compression removal and mailing of logs" DOCDESCRIPTION="Documentation part of automatic rotation compression removal and mailing of logs" DEVDESCRIPTION="Development files part of automatic rotation compression removal and mailing of logs" AUTHORS="Erik Troan, Preston Brown, and Jan Kaluza" HOMEPAGE="http://github.com/logrotate/logrotate" LICENSE="GPLv2" ME="rhermsen" TAGS="logrotate rotation compression" DOCTAGS="man pages logrotate rotation compression" DEVTAGS="development logrotate rotation compression" ###################################################### # Prepare extension creation # ###################################################### tce-load -wi ca-certificates.tcz echo "ca_directory = /usr/local/etc/ssl/certs" > ~/.wgetrc # Compile tools: tce-load -wi compiletc.tcz tce-load -wi squashfs-tools.tcz tce-load -wi autoconf.tcz tce-load -wi automake.tcz #tce-load -wi libtool.tcz #tce-load -wi libltdl.tcz #tce-load -wi pkg-config.tcz #tce-load -wi intltool.tcz #tce-load -wi libtool-dev.tcz # Configure dependancy tce-load -wi popt-dev.tcz tce-load -wi acl-dev.tcz # Other # tce-load -wi ipv6-netfilter-KERNEL.tcz # Remove dirs and files left from previous creation rm -r -f $SRCDIR 2>/dev/null rm -r -f $WRKDIR 2>/dev/null rm -r -f $DESTDIR 2>/dev/null sudo rm -r -f $TMPDIR 2>/dev/null sudo rm -r -f $TMPDIR-doc 2>/dev/null sudo rm -r -f $TMPDIR-dev 2>/dev/null ###################################################### # Compile extension # ###################################################### # Export variables needed for compilation export CFLAGS="-Os -pipe -march=i486 -mtune=i686" #export CXXFLAGS="-Os -pipe -fno-exceptions -fno-rtti -march=i486 -mtune=i686" export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe" export LDFLAGS="-Wl,-O1" export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig # Download source in SRCDIR mkdir -p $SRCDIR cd $SRCDIR wget https://github.com/$EXTNAM/$EXTNAM/releases/download/$VERSION/$SRCNAM # Unpack source in current directory tar -xJf $SRCNAM cd $WRKDIR # Configure it autoreconf -fiv ./configure --prefix=/usr/local \ --sysconfdir=/usr/local/etc/$EXTNAM \ --localstatedir=/var/$EXTNAM # --with-user=tc \ # --with-group=staff # Compile make mkdir -p $DESTDIR make DESTDIR=$DESTDIR install # Install in base temp dir mkdir -p $TMPDIR/usr/local/sbin mkdir -p $TMPDIR/usr/local/share/doc/${EXTNAM}/ mv $DESTDIR/usr/local/sbin/* $TMPDIR/usr/local/sbin cp /${SRCDIR}/${EXTNAM}-${VERSION}/COPYING $TMPDIR/usr/local/share/doc/${EXTNAM}/ ################################################### # Create info file # ################################################### cat < /tmp/$EXTNAM/${EXTNAM}.tcz.info Title: ${EXTNAM}.tcz Description: ${DESCRIPTION} Version: ${VERSION} Author: ${AUTHORS} Original-site: ${HOMEPAGE} Copying-policy: ${LICENSE} Size: ${size} Extension_by: ${ME} Tags: ${TAGS} Comments: The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files. Logrotate allows for the automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file hourly, daily, weekly, monthly or when the log file gets to a certain size. After configuration, logrotate should be run on a schedule e.g. using crontab which can be setup to run daily, or even hourly if faster rotation is required. Install ${EXTNAM}-doc.tcz for configuration examples. Change-log: ${TODAY} First version, $VERSION Current: ${TODAY} First version, $VERSION EOF ################################################### # Create .dep file # ################################################### cat < /tmp/${EXTNAM}/${EXTNAM}.tcz.dep popt.tcz acl.tcz EOF ################################################### # Create install script file # ################################################### mkdir -p $TMPDIR/usr/local/tce.installed cat < $TMPDIR/usr/local/tce.installed/${EXTNAM} [ ! -d /usr/local/etc/logrotate/logrotate.d ] && mkdir -p /usr/local/etc/logrotate/logrotate.d EOF # Delete compilation work directory cd .. #rm -r -f $WRKDIR # 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/man/man5 mkdir -p $TMPDIR-doc/usr/local/share/man/man8 mkdir -p $TMPDIR-doc/usr/local/share/$EXTNAM/examples/logrotate.d mv $DESTDIR/usr/local/share/man/man5/* $TMPDIR-doc/usr/local/share/man/man5 mv $DESTDIR/usr/local/share/man/man8/* $TMPDIR-doc/usr/local/share/man/man8 mv /${SRCDIR}/${EXTNAM}-${VERSION}/examples/* $TMPDIR-doc/usr/local/share/$EXTNAM/examples/ sed -i 's/\/etc\/logrotate/\/usr\/local\/etc\/logrotate\/logrotate/g' $TMPDIR-doc/usr/local/share/$EXTNAM/examples/logrotate.c* sed -i 's/\/usr\/sbin\/logrotate/\/usr\/local\/sbin\/logrotate/g' $TMPDIR-doc/usr/local/share/$EXTNAM/examples/logrotate.c* sed -i 's/\/etc\/logrotate/\/usr\/local\/etc\/logrotate\/logrotate/g' $TMPDIR-doc/usr/local/share/$EXTNAM/examples/logrotate.s* sed -i 's/\/usr\/sbin\/logrotate/\/usr\/local\/sbin\/logrotate/g' $TMPDIR-doc/usr/local/share/$EXTNAM/examples/logrotate.s* cat < $TMPDIR-doc/usr/local/share/$EXTNAM/examples/logrotate.d/frr su tc staff compress /var/log/vtysh.log #/var/log/zebra.log #/var/log/bgpd.log #/var/log/ospfd.log #/var/log/isisd.log { missingok daily copytruncate rotate 7 notifempty } EOF ################################################### # Create info file # ################################################### cat < /tmp/${EXTNAM}/${EXTNAM}-doc.tcz.info Title: ${EXTNAM}-doc.tcz Description: ${DOCDESCRIPTION} Version: ${VERSION} Author: ${AUTHORS} Original-site: ${HOMEPAGE} Copying-policy: ${LICENSE} Size: ${size} Extension_by: ${ME} Tags: ${DOCTAGS} Comments: The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files. Logrotate allows for the automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file hourly, daily, weekly, monthly or when the log file gets to a certain size. Change-log: ${TODAY} First version, $VERSION Current: ${TODAY} First version, $VERSION EOF ################################################### # Create base extension in temp dir # ################################################### cd $TMPDIR find $TMPDIR -perm 777 -exec chmod 755 {} \; find $TMPDIR -perm 555 -exec chmod 755 {} \; find $TMPDIR -perm 444 -exec chmod 644 {} \; find $TMPDIR -perm 666 -exec chmod 644 {} \; find $TMPDIR -perm 664 -exec chmod 644 {} \; sudo chown -R root:root $TMPDIR #sudo chown -R tc:staff $TMPDIR/usr/local/etc/$EXTNAM sudo chown -R root:staff $TMPDIR/usr/local/tce.installed sudo chmod -R 775 $TMPDIR/usr/local/tce.installed cd .. mksquashfs $TMPDIR $EXTNAM.tcz cd $TMPDIR sudo sh -c "find usr -not -type d > $EXTNAM.tcz.list" sudo mv ../$EXTNAM.tcz* . #sudo mv /tmp/${EXTNAM}/${EXTNAM}.tcz.info . # Create md5 file sudo sh -c "md5sum $EXTNAM.tcz > $EXTNAM.tcz.md5.txt" # Cleanup temp directory sudo rm -r -f usr ################################################### # Create doc extension in temp dir # ################################################### cd $TMPDIR-doc find $TMPDIR-doc -perm 777 -exec chmod 755 {} \; find $TMPDIR-doc -perm 555 -exec chmod 755 {} \; find $TMPDIR-doc -perm 444 -exec chmod 644 {} \; find $TMPDIR-doc -perm 666 -exec chmod 644 {} \; find $TMPDIR-doc -perm 664 -exec chmod 644 {} \; sudo chown -R root:root $TMPDIR-doc cd .. mksquashfs $TMPDIR-doc $EXTNAM-doc.tcz cd $TMPDIR-doc sudo sh -c "find usr -not -type d > $EXTNAM-doc.tcz.list" sudo mv ../$EXTNAM-doc.tcz* . #sudo mv /tmp/${EXTNAM}/${EXTNAM}-doc.tcz.info . # Create md5 file sudo sh -c "md5sum $EXTNAM-doc.tcz > $EXTNAM-doc.tcz.md5.txt" # Cleanup temp directory sudo rm -r -f usr