1 | #!/bin/sh |
---|
2 | |
---|
3 | # Slackware build script for kmod |
---|
4 | |
---|
5 | # Copyright 2011-2016 Robby Workman, Tuscaloosa, Alabama, USA |
---|
6 | # Copyright 2013-2016 Patrick J. Volkerding, Sebeka, MN, USA |
---|
7 | # All rights reserved. |
---|
8 | # |
---|
9 | # Redistribution and use of this script, with or without modification, is |
---|
10 | # permitted provided that the following conditions are met: |
---|
11 | # |
---|
12 | # 1. Redistributions of this script must retain the above copyright |
---|
13 | # notice, this list of conditions and the following disclaimer. |
---|
14 | # |
---|
15 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED |
---|
16 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
17 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
18 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
19 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
20 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
21 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
22 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
23 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
24 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
25 | |
---|
26 | PKGNAM=kmod |
---|
27 | VERSION=${VERSION:-24} |
---|
28 | BUILD=${BUILD:-2} |
---|
29 | |
---|
30 | if [ -z "$ARCH" ]; then |
---|
31 | case "$( uname -m )" in |
---|
32 | i?86) ARCH=i586 ;; |
---|
33 | arm*) ARCH=arm ;; |
---|
34 | *) ARCH=$( uname -m ) ;; |
---|
35 | esac |
---|
36 | fi |
---|
37 | |
---|
38 | CWD=$(pwd) |
---|
39 | TMP=${TMP:-/tmp} |
---|
40 | PKG=$TMP/package-$PKGNAM |
---|
41 | |
---|
42 | if [ "$ARCH" = "i586" ]; then |
---|
43 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
44 | LIBDIRSUFFIX="" |
---|
45 | elif [ "$ARCH" = "i686" ]; then |
---|
46 | SLKCFLAGS="-O2 -march=i686 -mtune=i686" |
---|
47 | LIBDIRSUFFIX="" |
---|
48 | elif [ "$ARCH" = "x86_64" ]; then |
---|
49 | SLKCFLAGS="-O2 -fPIC" |
---|
50 | LIBDIRSUFFIX="64" |
---|
51 | else |
---|
52 | SLKCFLAGS="-O2" |
---|
53 | LIBDIRSUFFIX="" |
---|
54 | fi |
---|
55 | |
---|
56 | rm -rf $PKG |
---|
57 | mkdir -p $TMP $PKG $OUTPUT |
---|
58 | cd $TMP |
---|
59 | rm -rf $PKGNAM-$VERSION |
---|
60 | tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1 |
---|
61 | cd $PKGNAM-$VERSION || exit 1 |
---|
62 | chown -R root:root . |
---|
63 | find . \ |
---|
64 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
65 | -exec chmod 755 {} \; -o \ |
---|
66 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
67 | -exec chmod 644 {} \; |
---|
68 | |
---|
69 | # Fix paths in manual pages |
---|
70 | sed -i "s,/usr/lib,/lib,g" man/* |
---|
71 | |
---|
72 | CFLAGS="$SLKCFLAGS" \ |
---|
73 | CXXFLAGS="$SLKCFLAGS" \ |
---|
74 | ./configure \ |
---|
75 | --prefix=/usr \ |
---|
76 | --libdir=/lib${LIBDIRSUFFIX} \ |
---|
77 | --bindir=/sbin \ |
---|
78 | --sbindir=/sbin \ |
---|
79 | --sysconfdir=/etc \ |
---|
80 | --localstatedir=/var \ |
---|
81 | --mandir=/usr/man \ |
---|
82 | --docdir=/usr/doc/$PKGNAM-$VERSION \ |
---|
83 | --disable-xz \ |
---|
84 | --disable-zlib \ |
---|
85 | --disable-python \ |
---|
86 | --build=$ARCH-slackware-linux || exit 1 |
---|
87 | |
---|
88 | make || exit 1 |
---|
89 | make install DESTDIR=$PKG || exit 1 |
---|
90 | |
---|
91 | # "make clean" deletes too much, so we have to start fresh :( |
---|
92 | |
---|
93 | cd $TMP |
---|
94 | rm -rf $PKGNAM-$VERSION |
---|
95 | tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1 |
---|
96 | cd $PKGNAM-$VERSION || exit 1 |
---|
97 | chown -R root:root . |
---|
98 | find . \ |
---|
99 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
100 | -exec chmod 755 {} \; -o \ |
---|
101 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
102 | -exec chmod 644 {} \; |
---|
103 | |
---|
104 | # Fix paths in manual pages |
---|
105 | sed -i "s,/usr/lib,/lib,g" man/* |
---|
106 | |
---|
107 | # Build python3 bindings for libkmod |
---|
108 | CFLAGS="$SLKCFLAGS" \ |
---|
109 | CXXFLAGS="$SLKCFLAGS" \ |
---|
110 | PYTHON=python3 \ |
---|
111 | ./configure \ |
---|
112 | --prefix=/usr \ |
---|
113 | --libdir=/lib${LIBDIRSUFFIX} \ |
---|
114 | --bindir=/sbin \ |
---|
115 | --sbindir=/sbin \ |
---|
116 | --sysconfdir=/etc \ |
---|
117 | --localstatedir=/var \ |
---|
118 | --mandir=/usr/man \ |
---|
119 | --docdir=/usr/doc/$PKGNAM-$VERSION \ |
---|
120 | --disable-xz \ |
---|
121 | --disable-zlib \ |
---|
122 | --disable-python \ |
---|
123 | --build=$ARCH-slackware-linux || exit 1 |
---|
124 | |
---|
125 | make \ |
---|
126 | install-pkgpyexecLTLIBRARIES \ |
---|
127 | install-dist_pkgpyexecPYTHON \ |
---|
128 | DESTDIR=$PKG || exit 1 |
---|
129 | |
---|
130 | # Strip binaries: |
---|
131 | ( cd $PKG |
---|
132 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
133 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
134 | ) |
---|
135 | |
---|
136 | # Compress and link manpages, if any: |
---|
137 | if [ -d $PKG/usr/man ]; then |
---|
138 | ( cd $PKG/usr/man |
---|
139 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
140 | ( cd $manpagedir |
---|
141 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
142 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
143 | rm $eachpage |
---|
144 | done |
---|
145 | gzip -9 *.? |
---|
146 | ) |
---|
147 | done |
---|
148 | ) |
---|
149 | fi |
---|
150 | |
---|
151 | # Create symlinks for the usual module-init-tools stuff: |
---|
152 | ( cd $PKG/sbin |
---|
153 | for file in depmod insmod lsmod modinfo modprobe rmmod ; do |
---|
154 | ln -sf kmod $file |
---|
155 | done |
---|
156 | ) |
---|
157 | |
---|
158 | # Link lsmod into /bin |
---|
159 | mkdir -p $PKG/bin |
---|
160 | ( cd $PKG/bin ; ln -sf /sbin/lsmod . ) |
---|
161 | |
---|
162 | mkdir -p $PKG/etc/modprobe.d |
---|
163 | mkdir -p $PKG/usr/lib${LIBDIRSUFFIX} |
---|
164 | mv $PKG/lib${LIBDIRSUFFIX}/pkgconfig $PKG/usr/lib${LIBDIRSUFFIX} |
---|
165 | rm -f $PKG/lib${LIBDIRSUFFIX}/{*.so,*.la} |
---|
166 | ( cd $PKG/usr/lib${LIBDIRSUFFIX} |
---|
167 | ln -sf ../../lib${LIBDIRSUFFIX}/libkmod.so.? libkmod.so |
---|
168 | ) |
---|
169 | |
---|
170 | mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION |
---|
171 | cp -a \ |
---|
172 | COPYING* NEWS README* TODO \ |
---|
173 | $PKG/usr/doc/$PKGNAM-$VERSION |
---|
174 | |
---|
175 | # If there's a ChangeLog, installing at least part of the recent history |
---|
176 | # is useful, but don't let it get totally out of control: |
---|
177 | if [ -r ChangeLog ]; then |
---|
178 | DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION) |
---|
179 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
180 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
181 | fi |
---|
182 | |
---|
183 | mkdir -p $PKG/install |
---|
184 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
185 | |
---|
186 | cd $PKG |
---|
187 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz |
---|