1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2005-2016 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 | PKGNAM=procps-ng |
---|
24 | VERSION=${VERSION:-3.3.11} |
---|
25 | PSMISCVER=${PSMISCVER:-22.21} |
---|
26 | PROCINFONGVER=${PROCINFONGVER:-2.0.304} |
---|
27 | PROCINFOVER=${PROCINFOVER:-18} |
---|
28 | BUILD=${BUILD:-1} |
---|
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 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
39 | |
---|
40 | CWD=$(pwd) |
---|
41 | TMP=${TMP:-/tmp} |
---|
42 | PKG=$TMP/package-$PKGNAM |
---|
43 | |
---|
44 | if [ "$ARCH" = "i586" ]; then |
---|
45 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
46 | LIBDIRSUFFIX="" |
---|
47 | elif [ "$ARCH" = "i686" ]; then |
---|
48 | SLKCFLAGS="-O2 -march=i686 -mtune=i686" |
---|
49 | LIBDIRSUFFIX="" |
---|
50 | elif [ "$ARCH" = "x86_64" ]; then |
---|
51 | SLKCFLAGS="-O2 -fPIC" |
---|
52 | LIBDIRSUFFIX="64" |
---|
53 | else |
---|
54 | SLKCFLAGS="-O2" |
---|
55 | LIBDIRSUFFIX="" |
---|
56 | fi |
---|
57 | |
---|
58 | rm -rf $PKG |
---|
59 | mkdir -p $TMP $PKG |
---|
60 | cd $TMP |
---|
61 | rm -rf $PKGNAM-$VERSION |
---|
62 | tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1 |
---|
63 | cd $PKGNAM-$VERSION || exit 1 |
---|
64 | tar xvf $CWD/psmisc-$PSMISCVER.tar.xz || exit 1 |
---|
65 | tar xvf $CWD/procinfo-ng-$PROCINFONGVER.tar.xz || exit 1 |
---|
66 | tar xvf $CWD/procinfo-$PROCINFOVER.tar.xz || exit 1 |
---|
67 | chown -R root:root . |
---|
68 | |
---|
69 | find -L . \ |
---|
70 | \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ |
---|
71 | -o -perm 511 \) -exec chmod 755 {} \; -o \ |
---|
72 | \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ |
---|
73 | -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; |
---|
74 | |
---|
75 | CFLAGS="$SLKCFLAGS" \ |
---|
76 | CXXFLAGS="$SLKCFLAGS" \ |
---|
77 | ./configure \ |
---|
78 | --prefix=/ \ |
---|
79 | --bindir=/bin \ |
---|
80 | --sbindir=/sbin \ |
---|
81 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
82 | --includedir=/usr/include \ |
---|
83 | --sysconfdir=/etc \ |
---|
84 | --localstatedir=/var \ |
---|
85 | --mandir=/usr/man \ |
---|
86 | --datarootdir=/usr/share \ |
---|
87 | --docdir=/usr/doc/$PKGNAM-$VERSION \ |
---|
88 | --enable-static=no \ |
---|
89 | --disable-silent-rules \ |
---|
90 | --disable-rpath \ |
---|
91 | --enable-watch8bit \ |
---|
92 | --enable-skill \ |
---|
93 | --enable-sigwinch \ |
---|
94 | --enable-w-from \ |
---|
95 | --disable-kill \ |
---|
96 | --without-systemd \ |
---|
97 | --disable-modern-top \ |
---|
98 | --build=$ARCH-slackware-linux || exit 1 |
---|
99 | |
---|
100 | make $NUMJOBS || exit 1 |
---|
101 | make install DESTDIR=$PKG || exit 1 |
---|
102 | |
---|
103 | # Move the shared library to $PKG/lib${LIBDIRSUFFIX}: |
---|
104 | mkdir -p $PKG/lib${LIBDIRSUFFIX} |
---|
105 | ( cd $PKG/usr/lib${LIBDIRSUFFIX} |
---|
106 | for file in lib*.so.?.* ; do |
---|
107 | mv $file ../../lib${LIBDIRSUFFIX} |
---|
108 | ln -sf ../../lib${LIBDIRSUFFIX}/$file . |
---|
109 | done |
---|
110 | cp -a lib*.so.? ../../lib${LIBDIRSUFFIX} |
---|
111 | ) |
---|
112 | |
---|
113 | # Remove .la file(s): |
---|
114 | rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la |
---|
115 | |
---|
116 | # It seems that upstream has shuffled the location of many tools with the |
---|
117 | # 3.3.11 release. To me, this just doesn't make sense to break any existing |
---|
118 | # scripts that might be using an absolute path, or to move tools that might |
---|
119 | # be needed before /usr is mounted into /usr. So, we will make sure that |
---|
120 | # everything is moved back to where the Slackware locations have always been. |
---|
121 | # These tools belong in /bin: |
---|
122 | mkdir -p $PKG/bin |
---|
123 | for file in free killall ps ; do |
---|
124 | find $PKG -name $file -exec mv "{}" $PKG/bin \; |
---|
125 | done |
---|
126 | # These tools belong in /sbin: |
---|
127 | mkdir -p $PKG/sbin |
---|
128 | for file in pidof sysctl ; do |
---|
129 | find $PKG -name $file -exec mv "{}" $PKG/sbin \; |
---|
130 | done |
---|
131 | mkdir -p $PKG/usr/bin |
---|
132 | # These tools belong in /usr/bin: |
---|
133 | for file in fuser lsdev peekfd pgrep pkill pmap procinfo prtstat pstree pwdx skill slabtop snice socklist tload top uptime vmstat w watch ; do |
---|
134 | find $PKG -name $file -exec mv "{}" $PKG/usr/bin \; |
---|
135 | done |
---|
136 | # These symlinks belong in /bin: |
---|
137 | rm -f $PKG/bin/pidof |
---|
138 | ln -sf /sbin/pidof $PKG/bin/pidof |
---|
139 | # These symlinks belong in /usr/bin: |
---|
140 | rm -f $PKG/usr/bin/free $PKG/usr/bin/pidof $PKG/usr/bin/ps |
---|
141 | ln -sf /bin/free $PKG/usr/bin/free |
---|
142 | ln -sf /sbin/pidof $PKG/usr/bin/pidof |
---|
143 | ln -sf /bin/ps $PKG/usr/bin/ps |
---|
144 | |
---|
145 | # Create /etc/sysctl.d: |
---|
146 | mkdir -p $PKG/etc/sysctl.d |
---|
147 | |
---|
148 | cd psmisc-$PSMISCVER || exit 1 |
---|
149 | |
---|
150 | # Fix fuser -s: |
---|
151 | zcat $CWD/psmisc.3638cc55b4d08851faba46635d737b24d016665b.diff.gz | patch -p1 --verbose || exit 1 |
---|
152 | |
---|
153 | CFLAGS="$SLKCFLAGS" \ |
---|
154 | CXXFLAGS="$SLKCFLAGS" \ |
---|
155 | ./configure \ |
---|
156 | --prefix=/usr \ |
---|
157 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
158 | --sysconfdir=/etc \ |
---|
159 | --localstatedir=/var \ |
---|
160 | --mandir=/usr/man \ |
---|
161 | --docdir=/usr/doc/psmisc-$PSMISCVER \ |
---|
162 | --disable-silent-rules \ |
---|
163 | --disable-rpath \ |
---|
164 | --build=$ARCH-slackware-linux || exit 1 |
---|
165 | |
---|
166 | make $NUMJOBS || exit 1 |
---|
167 | make install DESTDIR=$PKG || exit 1 |
---|
168 | |
---|
169 | # Move "killall" to the traditional location: |
---|
170 | mv $PKG/usr/bin/killall $PKG/bin |
---|
171 | ln -s /bin/killall $PKG/usr/bin/killall |
---|
172 | |
---|
173 | mkdir -p $PKG/usr/doc/psmisc-$PSMISCVER |
---|
174 | cp -a ChangeLog COPYING* NEWS README* $PKG/usr/doc/psmisc-$PSMISCVER |
---|
175 | |
---|
176 | # If there's a ChangeLog, installing at least part of the recent history |
---|
177 | # is useful, but don't let it get totally out of control: |
---|
178 | if [ -r ChangeLog ]; then |
---|
179 | DOCSDIR=$PKG/usr/doc/psmisc-$PSMISCVER |
---|
180 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
181 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
182 | fi |
---|
183 | |
---|
184 | cd ../procinfo-ng-$PROCINFONGVER || exit 1 |
---|
185 | CFLAGS="$SLKCFLAGS" \ |
---|
186 | CXXFLAGS="$SLKCFLAGS" \ |
---|
187 | ./configure \ |
---|
188 | --prefix=/usr \ |
---|
189 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
190 | --sysconfdir=/etc \ |
---|
191 | --localstatedir=/var \ |
---|
192 | --mandir=/usr/man \ |
---|
193 | --docdir=/usr/doc/procinfo-ng-$PROCINFONGVER \ |
---|
194 | --enable-maintainer-mode \ |
---|
195 | --build=$ARCH-slackware-linux || exit 1 |
---|
196 | |
---|
197 | make $NUMJOBS || exit 1 |
---|
198 | make install DESTDIR=$PKG || exit 1 |
---|
199 | |
---|
200 | mkdir -p $PKG/usr/doc/procinfo-ng-$PROCINFONGVER |
---|
201 | cp -a GPL-2.txt LGPL-2.1.txt LICENSE.txt $PKG/usr/doc/procinfo-ng-$PROCINFONGVER |
---|
202 | |
---|
203 | # Now install a couple of scripts from the original procinfo package. |
---|
204 | cd ../procinfo-$PROCINFOVER || exit 1 |
---|
205 | install -m 0755 lsdev.pl $PKG/usr/bin/lsdev |
---|
206 | install -m 0755 socklist.pl $PKG/usr/bin/socklist |
---|
207 | install -m 0644 lsdev.8 socklist.8 $PKG/usr/man/man8 |
---|
208 | |
---|
209 | # Strip binaries: |
---|
210 | ( cd $PKG |
---|
211 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
212 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
213 | ) |
---|
214 | |
---|
215 | # Compress and link manpages, if any: |
---|
216 | if [ -d $PKG/usr/man ]; then |
---|
217 | ( cd $PKG/usr/man |
---|
218 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
219 | ( cd $manpagedir |
---|
220 | for eachpage in $( find . -type l -maxdepth 1 | grep -v '\.gz$') ; do |
---|
221 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
222 | rm $eachpage |
---|
223 | done |
---|
224 | gzip -9 *.? |
---|
225 | ) |
---|
226 | done |
---|
227 | ) |
---|
228 | fi |
---|
229 | |
---|
230 | # Back to the procps-ng main source directory... |
---|
231 | cd .. |
---|
232 | |
---|
233 | mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION |
---|
234 | cp -a \ |
---|
235 | AUTHORS ChangeLog COPYING* NEWS \ |
---|
236 | $PKG/usr/doc/$PKGNAM-$VERSION |
---|
237 | |
---|
238 | # If there's a ChangeLog, installing at least part of the recent history |
---|
239 | # is useful, but don't let it get totally out of control: |
---|
240 | if [ -r ChangeLog ]; then |
---|
241 | DOCSDIR=$PKG/usr/doc/$PKGNAM-$VERSION |
---|
242 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
243 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
244 | fi |
---|
245 | |
---|
246 | mkdir -p $PKG/install |
---|
247 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
248 | |
---|
249 | cd $PKG |
---|
250 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz |
---|
251 | |
---|