1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2008, 2009, 2010, 2013, 2015 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 | |
---|
24 | VERSION=${VERSION:-$(echo xfsdump-*.tar.gz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
25 | BUILD=${BUILD:-1} |
---|
26 | |
---|
27 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
28 | |
---|
29 | # Automatically determine the architecture we're building on: |
---|
30 | if [ -z "$ARCH" ]; then |
---|
31 | case "$( uname -m )" in |
---|
32 | i?86) export ARCH=i586 ;; |
---|
33 | arm*) export ARCH=arm ;; |
---|
34 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
35 | *) export ARCH=$( uname -m ) ;; |
---|
36 | esac |
---|
37 | fi |
---|
38 | |
---|
39 | CWD=$(pwd) |
---|
40 | TMP=${TMP:-/tmp} |
---|
41 | PKG=$TMP/package-xfsdump |
---|
42 | |
---|
43 | rm -rf $PKG |
---|
44 | mkdir -p $TMP $PKG |
---|
45 | |
---|
46 | cd $TMP |
---|
47 | rm -rf xfsdump-$(echo $VERSION | cut -f 1 -d '-') |
---|
48 | tar xvf $CWD/xfsdump-$VERSION.tar.gz || exit 1 |
---|
49 | cd xfsdump-$(echo $VERSION | cut -f 1 -d '-') || exit 1 |
---|
50 | |
---|
51 | chown -R root:root . |
---|
52 | find . \ |
---|
53 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
54 | -exec chmod 755 {} \; -o \ |
---|
55 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
56 | -exec chmod 644 {} \; |
---|
57 | |
---|
58 | # Make sure you have the same version of autoconf as the |
---|
59 | # developers did... ;-) |
---|
60 | #autoreconf -vif |
---|
61 | |
---|
62 | ./configure \ |
---|
63 | --prefix=/usr \ |
---|
64 | --sbindir=/usr/sbin \ |
---|
65 | --bindir=/usr/sbin \ |
---|
66 | --enable-gettext=yes \ |
---|
67 | --mandir=/usr/man \ |
---|
68 | --datadir=/usr/share \ |
---|
69 | --build=$ARCH-slackware-linux || exit 1 |
---|
70 | |
---|
71 | make $NUMJOBS || make || exit 1 |
---|
72 | make install DESTDIR=$PKG || exit 1 |
---|
73 | |
---|
74 | ( cd $PKG/usr/sbin |
---|
75 | rm -f xfsdump xfsrestore |
---|
76 | ln -sf /sbin/xfsdump xfsdump |
---|
77 | ln -sf /sbin/xfsrestore xfsrestore |
---|
78 | ) |
---|
79 | |
---|
80 | # Strip libraries: |
---|
81 | find $PKG | xargs file | grep -e "executable" -e "shared object" \ |
---|
82 | | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
83 | |
---|
84 | # Compress and if needed symlink the man pages: |
---|
85 | if [ -d $PKG/usr/man ]; then |
---|
86 | ( cd $PKG/usr/man |
---|
87 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
88 | ( cd $manpagedir |
---|
89 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
90 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
91 | rm $eachpage |
---|
92 | done |
---|
93 | gzip -9 *.? |
---|
94 | ) |
---|
95 | done |
---|
96 | ) |
---|
97 | fi |
---|
98 | |
---|
99 | mv $PKG/usr/share/doc $PKG/usr |
---|
100 | ( cd $PKG/usr/doc ; mv xfsdump xfsdump-$VERSION ) |
---|
101 | cp -a \ |
---|
102 | README doc/COPYING \ |
---|
103 | $PKG/usr/doc/xfsdump-$VERSION |
---|
104 | mkdir -p $PKG/usr/doc/xfsdump-$VERSION/html |
---|
105 | ( cd doc |
---|
106 | cp -a *.gif *.html $PKG/usr/doc/xfsdump-$VERSION/html |
---|
107 | ) |
---|
108 | |
---|
109 | rm -f $PKG/usr/doc/xfsdump-$VERSION/CHANGES.gz |
---|
110 | |
---|
111 | # If there's a ChangeLog, installing at least part of the recent history |
---|
112 | # is useful, but don't let it get totally out of control: |
---|
113 | if [ -r doc/CHANGES ]; then |
---|
114 | DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION) |
---|
115 | cat doc/CHANGES | head -n 1000 > $DOCSDIR/CHANGES |
---|
116 | touch -r doc/CHANGES $DOCSDIR/CHANGES |
---|
117 | fi |
---|
118 | |
---|
119 | mkdir -p $PKG/install |
---|
120 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
121 | |
---|
122 | cd $PKG |
---|
123 | /sbin/makepkg -l y -c n $TMP/xfsdump-$(echo $VERSION | tr - _ )-$ARCH-$BUILD.txz |
---|
124 | |
---|