| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # Copyright 2008, 2009, 2010, 2011, 2012 Patrick J. Volkerding, Sebeka, Minnesota, USA |
|---|
| 4 | # All rights reserved. |
|---|
| 5 | # |
|---|
| 6 | # Redistribution and use of this script, with or without modification, is |
|---|
| 7 | # permitted provided that the following conditions are met: |
|---|
| 8 | # |
|---|
| 9 | # 1. Redistributions of this script must retain the above copyright |
|---|
| 10 | # notice, this list of conditions and the following disclaimer. |
|---|
| 11 | # |
|---|
| 12 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|---|
| 13 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|---|
| 14 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|---|
| 15 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|---|
| 16 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|---|
| 17 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|---|
| 18 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|---|
| 19 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|---|
| 20 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|---|
| 21 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 22 | |
|---|
| 23 | # CUPS build script by volkerdi@slackware.com. |
|---|
| 24 | |
|---|
| 25 | VERSION=1.5.4 |
|---|
| 26 | BUILD=${BUILD:-3} |
|---|
| 27 | |
|---|
| 28 | # Automatically determine the architecture we're building on: |
|---|
| 29 | if [ -z "$ARCH" ]; then |
|---|
| 30 | case "$( uname -m )" in |
|---|
| 31 | i?86) export ARCH=i486 ;; |
|---|
| 32 | arm*) export ARCH=arm ;; |
|---|
| 33 | # Unless $ARCH is already set, use uname -m for all other archs: |
|---|
| 34 | *) export ARCH=$( uname -m ) ;; |
|---|
| 35 | esac |
|---|
| 36 | fi |
|---|
| 37 | |
|---|
| 38 | if [ "$ARCH" = "x86_64" ]; then |
|---|
| 39 | LIBDIRSUFFIX="64" |
|---|
| 40 | else |
|---|
| 41 | LIBDIRSUFFIX="" |
|---|
| 42 | fi |
|---|
| 43 | |
|---|
| 44 | NUMJOBS=${NUMJOBS:-" -j7 "} |
|---|
| 45 | |
|---|
| 46 | CWD=$(pwd) |
|---|
| 47 | TMP=${TMP:-/tmp} |
|---|
| 48 | PKG=$TMP/package-cups |
|---|
| 49 | |
|---|
| 50 | rm -rf $PKG |
|---|
| 51 | mkdir -p $TMP $PKG |
|---|
| 52 | |
|---|
| 53 | cd $TMP |
|---|
| 54 | rm -rf cups-$VERSION |
|---|
| 55 | tar xvf $CWD/cups-$VERSION-source.tar.?z* || exit 1 |
|---|
| 56 | cd cups-$VERSION || exit 1 |
|---|
| 57 | |
|---|
| 58 | # Fix for CUPS 1.5.4. Don't reload the obsolete usblp module, as this |
|---|
| 59 | # can cause partial printing with certain printers. |
|---|
| 60 | zcat $CWD/cups-1.5.4-usb-quirks.diff.gz | patch -p1 --verbose || exit 1 |
|---|
| 61 | |
|---|
| 62 | sed -i.orig -e 's#$exec_prefix/lib/cups#$libdir/cups#g' configure |
|---|
| 63 | ./configure \ |
|---|
| 64 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
|---|
| 65 | --enable-ssl \ |
|---|
| 66 | --enable-openssl=yes \ |
|---|
| 67 | --enable-gnutls=no \ |
|---|
| 68 | --enable-cdsassl=no \ |
|---|
| 69 | --docdir=/usr/doc \ |
|---|
| 70 | --without-php \ |
|---|
| 71 | --disable-pam \ |
|---|
| 72 | --build=$ARCH-slackware-linux |
|---|
| 73 | |
|---|
| 74 | make $NUMJOBS || exit 1 |
|---|
| 75 | mkdir -p $PKG/etc/cups |
|---|
| 76 | mkdir -p $PKG/var/spool |
|---|
| 77 | make BUILDROOT=$PKG install || exit 1 |
|---|
| 78 | |
|---|
| 79 | # Blacklist the usblp module just to make sure that it doesn't cause |
|---|
| 80 | # any problems: |
|---|
| 81 | mkdir -p $PKG/lib/modprobe.d |
|---|
| 82 | cp -a $CWD/cups-blacklist-usblp.conf $PKG/lib/modprobe.d |
|---|
| 83 | chown root:root $PKG/lib/modprobe.d/cups-blacklist-usblp.conf |
|---|
| 84 | chmod 644 $PKG/lib/modprobe.d/cups-blacklist-usblp.conf |
|---|
| 85 | |
|---|
| 86 | # Hey, what's with the gigantic test files? Bloat is bad. |
|---|
| 87 | rm -f $PKG/usr/share/cups/ipptool/*.{pdf,ps,jpg} |
|---|
| 88 | |
|---|
| 89 | # I've added so many things like /etc/init.d/ to Slackware that CUPS |
|---|
| 90 | # is now installing init scripts to the Red Hat locations. We'll move |
|---|
| 91 | # them to the usual locations: |
|---|
| 92 | mkdir -p $PKG/etc/rc.d |
|---|
| 93 | # Handle this as a config file, and non-executable in a default install: |
|---|
| 94 | mv $PKG/etc/init.d/cups $PKG/etc/rc.d/rc.cups.new |
|---|
| 95 | chmod 644 $PKG/etc/rc.d/rc.cups.new |
|---|
| 96 | # Clear out the additions: |
|---|
| 97 | rm -rf $PKG/etc/init.d $PKG/etc/rc{0,2,3,5}.d |
|---|
| 98 | |
|---|
| 99 | # I'm not sure if overwriting this blindly could have ill effects, |
|---|
| 100 | # but it never hurts to play it safe. According to the dbus-daemon |
|---|
| 101 | # manpage, only files ending in .conf will be used, so there won't |
|---|
| 102 | # be any unintended doubling up. |
|---|
| 103 | mv $PKG/etc/dbus-1/system.d/cups.conf $PKG/etc/dbus-1/system.d/cups.conf.new |
|---|
| 104 | |
|---|
| 105 | # For full CUPS SMB support, you'll need to install the cups-samba |
|---|
| 106 | # package from the source in this directory. There's no easy way |
|---|
| 107 | # to add that to a package build, and the requests aren't pouring in, |
|---|
| 108 | # so you'll have to install it yourself. It's easy to do. |
|---|
| 109 | |
|---|
| 110 | # However, this will get you the most useful SMB support for free. |
|---|
| 111 | # Thanks to Boris Kurktchiev for the tip. :-) |
|---|
| 112 | ( cd $PKG/usr/lib${LIBDIRSUFFIX}/cups/backend |
|---|
| 113 | if [ ! -e smb ]; then |
|---|
| 114 | ln -sf /usr/bin/smbspool smb |
|---|
| 115 | fi |
|---|
| 116 | ) |
|---|
| 117 | |
|---|
| 118 | mkdir -p $PKG/install |
|---|
| 119 | cat $CWD/slack-desc > $PKG/install/slack-desc |
|---|
| 120 | |
|---|
| 121 | # Remove preformatted manpages and move the manpages to /usr/man: |
|---|
| 122 | ( cd $PKG/usr/share/man |
|---|
| 123 | find . -type d -name "cat*" | xargs rm -rf |
|---|
| 124 | cd .. |
|---|
| 125 | mv man .. |
|---|
| 126 | ) |
|---|
| 127 | |
|---|
| 128 | # Adjust/expand docs: |
|---|
| 129 | ( mkdir -p $PKG/usr/doc |
|---|
| 130 | mv $PKG/usr/share/doc/cups $PKG/usr/doc/cups-$VERSION |
|---|
| 131 | rmdir $PKG/usr/share/doc |
|---|
| 132 | cd $PKG/usr/doc |
|---|
| 133 | ln -sf cups-$VERSION cups ) |
|---|
| 134 | |
|---|
| 135 | # If there's a ChangeLog, installing at least part of the recent history |
|---|
| 136 | # is useful, but don't let it get totally out of control: |
|---|
| 137 | if [ -r CHANGES.txt ]; then |
|---|
| 138 | DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION) |
|---|
| 139 | cat CHANGES.txt | head -n 1000 > $DOCSDIR/CHANGES.txt |
|---|
| 140 | touch -r CHANGES.txt $DOCSDIR/CHANGES.txt |
|---|
| 141 | fi |
|---|
| 142 | |
|---|
| 143 | # I'm sorry, but PDF files are almost as bloated and annoying as |
|---|
| 144 | # MS Word documents. We'll retain the HTML files in /usr/doc. |
|---|
| 145 | ( cd $PKG/usr/doc |
|---|
| 146 | find . -name "*.pdf" -exec rm -f {} \; ) |
|---|
| 147 | |
|---|
| 148 | # Apply no-clobber fix to conffiles: |
|---|
| 149 | ( cd $PKG/etc/cups |
|---|
| 150 | for file in * ; do |
|---|
| 151 | if [ -f $file ]; then |
|---|
| 152 | mv $file $file.new |
|---|
| 153 | fi |
|---|
| 154 | done ) |
|---|
| 155 | |
|---|
| 156 | # Strip stuff: |
|---|
| 157 | find $PKG | xargs file | grep -e "executable" -e "shared object" \ |
|---|
| 158 | | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
|---|
| 159 | |
|---|
| 160 | # Use symlinks to certain binaries so that CUPS and LPRng can coexist: |
|---|
| 161 | SUFFIX=cups |
|---|
| 162 | for file in \ |
|---|
| 163 | usr/bin/cancel \ |
|---|
| 164 | usr/bin/lp \ |
|---|
| 165 | usr/bin/lpq \ |
|---|
| 166 | usr/bin/lpr \ |
|---|
| 167 | usr/bin/lprm \ |
|---|
| 168 | usr/bin/lpstat \ |
|---|
| 169 | usr/sbin/lpc ; do |
|---|
| 170 | ( cd $PKG |
|---|
| 171 | mv ${file} ${file}-${SUFFIX} |
|---|
| 172 | ( cd `dirname ${file}` ; ln -sf `basename ${file}`-${SUFFIX} `basename ${file}` ) |
|---|
| 173 | ) |
|---|
| 174 | done |
|---|
| 175 | # Now fix the associated man pages: |
|---|
| 176 | mv $PKG/usr/man/man1/cancel.1.gz $PKG/usr/man/man1/cancel-${SUFFIX}.1.gz |
|---|
| 177 | mv $PKG/usr/man/man1/lp.1.gz $PKG/usr/man/man1/lp-${SUFFIX}.1.gz |
|---|
| 178 | mv $PKG/usr/man/man1/lpq.1.gz $PKG/usr/man/man1/lpq-${SUFFIX}.1.gz |
|---|
| 179 | mv $PKG/usr/man/man1/lpr.1.gz $PKG/usr/man/man1/lpr-${SUFFIX}.1.gz |
|---|
| 180 | mv $PKG/usr/man/man1/lprm.1.gz $PKG/usr/man/man1/lprm-${SUFFIX}.1.gz |
|---|
| 181 | mv $PKG/usr/man/man1/lpstat.1.gz $PKG/usr/man/man1/lpstat-${SUFFIX}.1.gz |
|---|
| 182 | mv $PKG/usr/man/man8/lpc.8.gz $PKG/usr/man/man8/lpc-${SUFFIX}.8.gz |
|---|
| 183 | ( cd $PKG/usr/man/man1 |
|---|
| 184 | ln -sf cancel-${SUFFIX}.1.gz cancel.1.gz |
|---|
| 185 | ln -sf lp-${SUFFIX}.1.gz lp.1.gz |
|---|
| 186 | ln -sf lpq-${SUFFIX}.1.gz lpq.1.gz |
|---|
| 187 | ln -sf lpr-${SUFFIX}.1.gz lpr.1.gz |
|---|
| 188 | ln -sf lprm-${SUFFIX}.1.gz lprm.1.gz |
|---|
| 189 | ln -sf lpstat-${SUFFIX}.1.gz lpstat.1.gz |
|---|
| 190 | ) |
|---|
| 191 | ( cd $PKG/usr/man/man8 |
|---|
| 192 | ln -sf lpc-${SUFFIX}.8.gz lpc.8.gz |
|---|
| 193 | ) |
|---|
| 194 | |
|---|
| 195 | # Add the doinst.sh that installs the .new conffiles: |
|---|
| 196 | zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
|---|
| 197 | |
|---|
| 198 | # Build the package: |
|---|
| 199 | cd $PKG |
|---|
| 200 | /sbin/makepkg -l y -c n $TMP/cups-$VERSION-$ARCH-$BUILD.txz |
|---|
| 201 | |
|---|