#!/bin/bash # Copyright (C) 2010-2011 Matias 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=0.9.0 ARCH=${ARCH:-x86_64} B=1 # Flags for the compiler: DCFLAGS=${DCFLAGS:=-O2 -mtune=generic} # Parallel jobs for the compiler: JOBS=${JOBS:=-j4} PKG=${TMP}/package-lirc rm -rf $PKG mkdir -p $PKG $OUT echo "Uncompressing the tarball..." rm -rf ${TMP}/lirc-${V} lzip -cd ${CWD}/lirc-${V}.tar.lz | tar -xvf - -C $TMP cd ${TMP}/lirc-${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 {} + CFLAGS="$DCFLAGS" \ ./configure \ --prefix=/usr \ --libdir=/usr/lib64 \ --sysconfdir=/etc \ --mandir=/usr/man \ --datadir=/usr/share \ --localstatedir=/var \ --disable-static \ --with-driver=userspace \ --enable-sandboxed \ --with-syslog \ --build=${ARCH}-dragora-linux-gnu make $JOBS make install DESTDIR=$PKG # Increments a little the "security": find ${PKG}/usr/sbin -type f | xargs chmod -v 0750 install -d ${PKG}/var/run/lirc # Strip binaries & libraries: ( cd $PKG find . -type f | xargs file | awk '/ELF/ && /executable/ || /shared object/' | \ cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null ) # Add files from contrib/: install -m 644 contrib/lircd.conf \ -D ${PKG}/etc/lircd.conf.new install -m 644 contrib/lircmd.conf \ -D ${PKG}/etc/lircmd.conf.new # This is for udev: install -m 644 ${CWD}/lirc.rules \ -D ${PKG}/lib/udev/rules.d/91-lirc.rules # Include the configuration files under usr/share: mkdir -p ${PKG}/usr/share/lirc cp -a remotes/ ${PKG}/usr/share/lirc ( cd ${PKG}/usr/share ; chown -R 0:0 lirc/ ) # Compress and link manpages (if needed: ( cd ${PKG}/usr/man find . -type f -exec gzip -9N '{}' + find . -type l | while read file ; do ln -sf $(readlink $file).gz ${file}.gz rm $file done ) # Add the daemons for runit: install -m 755 ${CWD}/runit.d/lircd/run \ -D ${PKG}/etc/sv/lircd/run.new install -m 755 ${CWD}/runit.d/lircmd/run \ -D ${PKG}/etc/sv/lircmd/run.new mkdir -p ${PKG}/etc/runit/runsvdir/default ( cd ${PKG}/etc/runit/runsvdir/default ln -sf /etc/sv/lircd . ln -sf /etc/sv/lircmd . ) # Add the post-install script: mkdir -p ${PKG}/install zcat ${CWD}/post-install.gz > ${PKG}/install/post-install # Add the documentation: mkdir -p ${PKG}/usr/doc/lirc-${V} cp -a \ ANNOUNCE AUTHORS COPYING NEWS README TODO \ ${PKG}/usr/doc/lirc-${V} # Copy the description files: mkdir -p ${PKG}/description cp ${CWD}/description/* ${PKG}/description cd $PKG makepkg -l ${OUT}/lirc-${V}-${ARCH}-${B}.tlz