1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 Patrick J. Volkerding, Sebeka, MN, 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 | # http://downloads.sourceforge.net/project/blackboxwm/blackboxwm/Blackbox%200.70.1/blackbox-0.70.1.tar.bz2 |
---|
24 | # http://downloads.sourceforge.net/project/bbkeys/bbkeys/0.9.1/bbkeys-0.9.1.tar.gz |
---|
25 | |
---|
26 | PKGNAM=blackbox |
---|
27 | VERSION=${VERSION:-0.70.1} |
---|
28 | BBKEYSVER=${BBKEYSVER:-0.9.1} |
---|
29 | BUILD=${BUILD:-7} |
---|
30 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
31 | |
---|
32 | # Automatically determine the architecture we're building on: |
---|
33 | if [ -z "$ARCH" ]; then |
---|
34 | case "$( uname -m )" in |
---|
35 | i?86) export ARCH=i486 ;; |
---|
36 | arm*) export ARCH=arm ;; |
---|
37 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
38 | *) export ARCH=$( uname -m ) ;; |
---|
39 | esac |
---|
40 | fi |
---|
41 | |
---|
42 | # Determine the CFLAGS for the known architectures: |
---|
43 | case $ARCH in |
---|
44 | i486) export SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
45 | export LIBDIRSUFFIX="" |
---|
46 | export ARCHQUADLET="" ;; |
---|
47 | i686) export SLKCFLAGS="-O2 -march=i686 -mtune=i686" |
---|
48 | export LIBDIRSUFFIX="" |
---|
49 | export ARCHQUADLET="" ;; |
---|
50 | x86_64) export SLKCFLAGS="-O2 -fPIC" |
---|
51 | export LIBDIRSUFFIX="64" |
---|
52 | export ARCHQUADLET="" ;; |
---|
53 | s390) export SLKCFLAGS="-O2" |
---|
54 | export LIBDIRSUFFIX="" |
---|
55 | export ARCHQUADLET="" ;; |
---|
56 | arm) export SLKCFLAGS="-O2 -march=armv4t" |
---|
57 | export LIBDIRSUFFIX="" |
---|
58 | export ARCHQUADLET="-gnueabi" ;; |
---|
59 | *) export SLKCFLAGS="-O2" |
---|
60 | export LIBDIRSUFFIX="" |
---|
61 | export ARCHQUADLET="" ;; |
---|
62 | esac |
---|
63 | |
---|
64 | |
---|
65 | CWD=$(pwd) |
---|
66 | TMP=${TMP:-/tmp} |
---|
67 | PKG=$TMP/package-${PKGNAM} |
---|
68 | rm -rf $PKG |
---|
69 | mkdir -p $TMP $PKG |
---|
70 | |
---|
71 | cd $TMP |
---|
72 | rm -rf ${PKGNAM}-${VERSION} |
---|
73 | tar xvf $CWD/${PKGNAM}-$VERSION.tar.xz || exit 1 |
---|
74 | cd ${PKGNAM}-$VERSION || exit 1 |
---|
75 | |
---|
76 | # Make sure ownerships and permissions are sane: |
---|
77 | chown -R root:root . |
---|
78 | find . \ |
---|
79 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
80 | -exec chmod 755 {} \; -o \ |
---|
81 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
82 | -exec chmod 644 {} \; |
---|
83 | |
---|
84 | # Build fix for gcc-4: |
---|
85 | zcat $CWD/blackbox-0.70.1-gcc-4.3.patch.gz | patch --verbose -p1 || exit 1 |
---|
86 | |
---|
87 | # Build fix for libX11-1.5+ |
---|
88 | zcat $CWD/textpropertytostring-unconditional.diff.gz | patch --verbose -p1 || exit 1 |
---|
89 | |
---|
90 | # Configure: |
---|
91 | CFLAGS="$SLKCFLAGS" \ |
---|
92 | CPPFLAGS="-I/usr/include/freetype2 " \ |
---|
93 | ./configure \ |
---|
94 | --prefix=/usr \ |
---|
95 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
96 | --enable-shape \ |
---|
97 | --enable-slit \ |
---|
98 | --enable-interlace \ |
---|
99 | --enable-nls \ |
---|
100 | --enable-shared=yes \ |
---|
101 | --enable-static=no \ |
---|
102 | --enable-timed-cache \ |
---|
103 | --infodir=/usr/info \ |
---|
104 | --mandir=/usr/man \ |
---|
105 | --build=$ARCH-slackware-linux$ARCHQUADLET || exit 1 |
---|
106 | |
---|
107 | # Build: |
---|
108 | make $NUMJOBS || make || exit 1 |
---|
109 | |
---|
110 | # Install onto filesystem - needed for bbkeys to find libbt: |
---|
111 | make install || exit 1 |
---|
112 | |
---|
113 | # Install into package: |
---|
114 | make install DESTDIR=$PKG || exit 1 |
---|
115 | mkdir -p $PKG/etc/X11/xinit |
---|
116 | zcat $CWD/xinitrc.blackbox.gz > $PKG/etc/X11/xinit/xinitrc.blackbox |
---|
117 | chmod 755 $PKG/etc/X11/xinit/xinitrc.blackbox |
---|
118 | zcat $CWD/startblackbox.gz > $PKG/usr/bin/startblackbox |
---|
119 | chmod 755 $PKG/usr/bin/startblackbox |
---|
120 | |
---|
121 | # Add a documentation directory: |
---|
122 | mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
123 | cp -a \ |
---|
124 | AUTHORS INSTALL LICENSE README* TODO \ |
---|
125 | $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
126 | |
---|
127 | # If there's a ChangeLog, installing at least part of the recent history |
---|
128 | # is useful, but don't let it get totally out of control: |
---|
129 | if [ -r ChangeLog ]; then |
---|
130 | DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION) |
---|
131 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
132 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
133 | fi |
---|
134 | |
---|
135 | ###################################### |
---|
136 | # Compile bbkeys program for blackbox: |
---|
137 | cd $TMP |
---|
138 | rm -rf bbkeys-${BBKEYSVER} |
---|
139 | tar xvf $CWD/bbkeys-${BBKEYSVER}.tar.xz |
---|
140 | cd bbkeys-${BBKEYSVER} || exit 1 |
---|
141 | |
---|
142 | # Make sure ownerships and permissions are sane: |
---|
143 | chown -R root:root . |
---|
144 | find . \ |
---|
145 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
146 | -exec chmod 755 {} \; -o \ |
---|
147 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
148 | -exec chmod 644 {} \; |
---|
149 | |
---|
150 | # Configure: |
---|
151 | CFLAGS="$SLKCFLAGS" \ |
---|
152 | CPPFLAGS="-I/usr/include/bt" \ |
---|
153 | ./configure \ |
---|
154 | --prefix=/usr \ |
---|
155 | --infodir=/usr/info \ |
---|
156 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
157 | --mandir=/usr/man \ |
---|
158 | --docdir=/usr/doc/bbkeys-$BBKEYSVER \ |
---|
159 | --build=$ARCH-slackware-linux$ARCHQUADLET || exit 1 |
---|
160 | |
---|
161 | # --docdir isn't honoured: |
---|
162 | sed -i 's?^docdir.*=.*?docdir = /usr/doc/bbkeys-'"$BBKEYSVER"'?g' Makefile |
---|
163 | |
---|
164 | # If there's a ChangeLog, installing at least part of the recent history |
---|
165 | # is useful, but don't let it get totally out of control: |
---|
166 | |
---|
167 | # Build and install into package: |
---|
168 | make $NUMJOBS || make || exit 1 |
---|
169 | make install DESTDIR=$PKG || exit 1 |
---|
170 | |
---|
171 | # Strip binaries: |
---|
172 | find $PKG | xargs file | grep -e "executable" -e "shared object" \ |
---|
173 | | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
174 | |
---|
175 | # Compress and link manpages, if any: |
---|
176 | if [ -d $PKG/usr/man ]; then |
---|
177 | ( cd $PKG/usr/man |
---|
178 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
179 | ( cd $manpagedir |
---|
180 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
181 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
182 | rm $eachpage |
---|
183 | done |
---|
184 | gzip -9 *.? |
---|
185 | ) |
---|
186 | done |
---|
187 | ) |
---|
188 | fi |
---|
189 | |
---|
190 | # Set doc permissions: |
---|
191 | find $PKG/usr/doc -type f -print0 | xargs -0 chmod 644 |
---|
192 | find $PKG/usr/doc -type d -print0 | xargs -0 chmod 755 |
---|
193 | |
---|
194 | mkdir -p $PKG/install |
---|
195 | install -vpm644 $CWD/slack-desc $PKG/install/ |
---|
196 | |
---|
197 | cd $PKG |
---|
198 | /sbin/makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz |
---|