#!/bin/bash # Copyright (C) 2010 Matías A. Fonzo, # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -e CWD=$(pwd) TMP=${TMP:-/tmp/sources} OUT=${OUT:-/tmp/packages} V=2.4.5 ARCH=${ARCH:-i486} B=1 PKG=${TMP}/package-ppp rm -rf $PKG mkdir -p $PKG $OUT echo "Uncompressing the tarball..." rm -rf ${TMP}/ppp-${V} tar xvf ${CWD}/ppp-${V}.tar.gz -C $TMP cd ${TMP}/ppp-${V} # Set sane ownerships and permissions: chown -R 0:0 . find . \ \( -perm 2777 -o \ -perm 777 -o \ -perm 775 -o \ -perm 711 -o \ -perm 555 -o \ -perm 511 \ \) -exec chmod 755 {} + \ -o \ \( -perm 666 -o \ -perm 664 -o \ -perm 600 -o \ -perm 444 -o \ -perm 440 -o \ -perm 400 \ \) -exec chmod 644 {} + # Enable PPP packet filtering (requires libpcap): sed -i 's%#FILTER=y%FILER=y%' \ pppd/Makefile.linux # Enable IPv6 support in pppd: sed -i 's%#HAVE_INET6=y%HAVE_INET6=y%' \ pppd/Makefile.linux # Compile without debug information: sed -i 's%COPTS = -O2 -pipe -Wall -g%COPTS = -O2 -pipe -Wall%' \ pppd/Makefile.linux ./configure \ --prefix=/usr \ --mandir=/usr/man \ --build=${ARCH}-dragora-linux-gnu make make install INSTROOT=$PKG # Increments a little the security: chmod 750 ${PKG}/usr/sbin/* # Fix permissions: ( cd $PKG find . -perm 555 -exec chmod 755 '{}' + find . -perm 444 -exec chmod 644 '{}' + ) chmod 755 ${PKG}/usr/lib/pppd/${V}/* # Strip binaries & libraries: ( cd $PKG find . -type f | xargs file | awk '/ELF/ && /executable/ || /shared object/' | \ cut -f 1 -d : | xargs strip -s 2> /dev/null ) # Include scripts: mkdir -p ${PKG}/etc/ppp/peers mkdir -p ${PKG}/usr/sbin install -m 750 scripts/pon ${PKG}/usr/sbin install -m 750 scripts/poff ${PKG}/usr/sbin install -m 750 scripts/plog ${PKG}/usr/sbin # Add configuration files: mkdir -p ${PKG}/etc/ppp for file in etc.ppp/* ; do cat $file > ${PKG}/etc/ppp/${file##*/}.new done chmod 600 ${PKG}/etc/ppp/*-secrets* # Move and compress man-pages: if [[ -d ${PKG}/usr/share/man ]]; then ( cd ${PKG}/usr mv share/man/ . rmdir --ignore-fail-on-non-empty share/ ) fi gzip -9N ${PKG}/usr/man/man?/* # Includes the man-page for pon: mkdir -p ${PKG}/usr/man/man1 gzip -9Nc < scripts/pon.1 > ${PKG}/usr/man/man1/pon.1.gz # Add the documentation: mkdir -p ${PKG}/usr/doc/ppp-${V} cp -a \ FAQ PLUGINS README README.linux SETUP \ ${PKG}/usr/doc/ppp-${V} # Copy the description files: mkdir -p ${PKG}/description cp ${CWD}/description/* ${PKG}/description # Make the post-install script: mkdir -p ${PKG}/install cat << "EOF" > ${PKG}/install/post-install # Handle config files: config() { local new old new="$1" old=${1%.new} if [ ! -r $old ]; then mv $new $old elif [ "$(md5sum $old | cut -f 1 -d ' ')" = "$(md5sum $new | cut -f 1 -d ' ')" ]; then rm $new else echo "You have a new config file \"${new}\" at your consideration." fi } for file in etc/ppp/*.new ; do config $file done EOF cd $PKG makepkg -l ${OUT}/ppp-${V}-${ARCH}-${B}.tlz