1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2013 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 | |
---|
24 | PKGNAM=help2man |
---|
25 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
26 | BUILD=${BUILD:-1} |
---|
27 | |
---|
28 | # Automatically determine the architecture we're building on: |
---|
29 | if [ -z "$ARCH" ]; then |
---|
30 | case "$(uname -m)" in |
---|
31 | i?86) ARCH=i486 ;; |
---|
32 | arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7lh ;; |
---|
33 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
34 | *) ARCH=$(uname -m) ;; |
---|
35 | esac |
---|
36 | export ARCH |
---|
37 | fi |
---|
38 | |
---|
39 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
40 | |
---|
41 | if [ "$ARCH" = "i386" ]; then |
---|
42 | SLKCFLAGS="-O2 -march=i386 -mcpu=i686" |
---|
43 | LIBDIRSUFFIX="" |
---|
44 | elif [ "$ARCH" = "i486" ]; then |
---|
45 | SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
46 | LIBDIRSUFFIX="" |
---|
47 | elif [ "$ARCH" = "i586" ]; then |
---|
48 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
49 | LIBDIRSUFFIX="" |
---|
50 | elif [ "$ARCH" = "i686" ]; then |
---|
51 | SLKCFLAGS="-O2 -march=i686" |
---|
52 | LIBDIRSUFFIX="" |
---|
53 | elif [ "$ARCH" = "s390" ]; then |
---|
54 | SLKCFLAGS="-O2" |
---|
55 | LIBDIRSUFFIX="" |
---|
56 | elif [ "$ARCH" = "x86_64" ]; then |
---|
57 | SLKCFLAGS="-O2 -fPIC" |
---|
58 | LIBDIRSUFFIX="64" |
---|
59 | elif [ "$ARCH" = "armv7hl" ]; then |
---|
60 | SLKCFLAGS="-O3 -march=armv7-a -mfpu=vfpv3-d16" |
---|
61 | LIBDIRSUFFIX="" |
---|
62 | else |
---|
63 | SLKCFLAGS="-O2" |
---|
64 | LIBDIRSUFFIX="" |
---|
65 | fi |
---|
66 | |
---|
67 | CWD=$(pwd) |
---|
68 | TMP=${TMP:-/tmp} |
---|
69 | PKG=$TMP/package-$PKGNAM |
---|
70 | |
---|
71 | rm -rf $PKG |
---|
72 | mkdir -p $TMP $PKG |
---|
73 | |
---|
74 | cd $TMP |
---|
75 | rm -rf $PKGNAM-$VERSION |
---|
76 | tar xvf $CWD/$PKGNAM-$VERSION.tar.?z* || exit 1 |
---|
77 | cd $PKGNAM-$VERSION |
---|
78 | |
---|
79 | chown -R root:root . |
---|
80 | find . \ |
---|
81 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
82 | -exec chmod 755 {} \; -o \ |
---|
83 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
84 | -exec chmod 644 {} \; |
---|
85 | |
---|
86 | # Configure: |
---|
87 | CFLAGS="$SLKCFLAGS" \ |
---|
88 | ./configure \ |
---|
89 | --prefix=/usr \ |
---|
90 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
91 | --sysconfdir=/etc \ |
---|
92 | --infodir=/usr/info \ |
---|
93 | --mandir=/usr/man \ |
---|
94 | --localstatedir=/var \ |
---|
95 | --build=$ARCH-slackware-linux |
---|
96 | |
---|
97 | # Build and install: |
---|
98 | make $NUMJOBS || make || exit 1 |
---|
99 | make install DESTDIR=$PKG || exit 1 |
---|
100 | |
---|
101 | # Strip binaries: |
---|
102 | ( cd $PKG |
---|
103 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
104 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
105 | ) |
---|
106 | |
---|
107 | # Add a documentation directory: |
---|
108 | mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
109 | cp -a \ |
---|
110 | COPYING* INSTALL NEWS README* THANKS \ |
---|
111 | $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
112 | |
---|
113 | # Compress and if needed symlink the man pages: |
---|
114 | if [ -d $PKG/usr/man ]; then |
---|
115 | ( cd $PKG/usr/man |
---|
116 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
117 | ( cd $manpagedir |
---|
118 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
119 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
120 | rm $eachpage |
---|
121 | done |
---|
122 | gzip -9 *.? |
---|
123 | ) |
---|
124 | done |
---|
125 | ) |
---|
126 | fi |
---|
127 | |
---|
128 | # Compress info files, if any: |
---|
129 | if [ -d $PKG/usr/info ]; then |
---|
130 | ( cd $PKG/usr/info |
---|
131 | rm -f dir |
---|
132 | gzip -9 * |
---|
133 | ) |
---|
134 | fi |
---|
135 | |
---|
136 | # If there's a ChangeLog, installing at least part of the recent history |
---|
137 | # is useful, but don't let it get totally out of control: |
---|
138 | if [ -r debian/changelog ]; then |
---|
139 | DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION) |
---|
140 | cat debian/changelog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
141 | touch -r debian/changelog $DOCSDIR/ChangeLog |
---|
142 | fi |
---|
143 | |
---|
144 | mkdir -p $PKG/install |
---|
145 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
146 | |
---|
147 | cd $PKG |
---|
148 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz |
---|
149 | |
---|
150 | |
---|
151 | ############ make syn3 packages |
---|
152 | cd $CWD |
---|
153 | for PKG in /tmp/package-*; do |
---|
154 | NAME=`echo $PKG| sed 's/.*package-//'| sed 's/-/_/'` |
---|
155 | |
---|
156 | #seperate dev-package |
---|
157 | syn3_move_dev $PKG $PKG""_dev |
---|
158 | syn3_makepkg $PKG""_dev $NAME""_dev $VERSION $ARCH || exit 1 |
---|
159 | |
---|
160 | #make main package |
---|
161 | syn3_makepkg $PKG $NAME $VERSION $ARCH || exit 1 |
---|
162 | done |
---|