1 | #!/bin/bash |
---|
2 | |
---|
3 | # Copyright 2008, 2009, 2010, 2011, 2016, 2018 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 | cd $(dirname $0) ; CWD=$(pwd) |
---|
24 | |
---|
25 | PKGNAM=git |
---|
26 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | cut -d - -f 2 | rev | cut -f 3- -d . | rev)} |
---|
27 | BUILD=${BUILD:-1} |
---|
28 | |
---|
29 | NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "} |
---|
30 | |
---|
31 | # Automatically determine the architecture we're building on: |
---|
32 | if [ -z "$ARCH" ]; then |
---|
33 | case "$( uname -m )" in |
---|
34 | i?86) export ARCH=i586 ;; |
---|
35 | arm*) export ARCH=arm ;; |
---|
36 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
37 | *) export ARCH=$( uname -m ) ;; |
---|
38 | esac |
---|
39 | fi |
---|
40 | |
---|
41 | # If the variable PRINT_PACKAGE_NAME is set, then this script will report what |
---|
42 | # the name of the created package would be, and then exit. This information |
---|
43 | # could be useful to other scripts. |
---|
44 | if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then |
---|
45 | echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" |
---|
46 | exit 0 |
---|
47 | fi |
---|
48 | |
---|
49 | eval $(perl '-V:installvendorlib') |
---|
50 | PERLDIR=$installvendorlib/$ARCH-linux-thread-multi/auto |
---|
51 | |
---|
52 | if ls /var/log/packages/git-* 1> /dev/null 2> /dev/null ; then |
---|
53 | echo "The git package needs to be removed before building to ensure that" |
---|
54 | echo "the perl modules are included in the new package." |
---|
55 | echo |
---|
56 | echo "Removing the git package in 15 seconds, and then continuing with the build." |
---|
57 | sleep 15 |
---|
58 | removepkg git |
---|
59 | fi |
---|
60 | |
---|
61 | if [ "$ARCH" = "i586" ]; then |
---|
62 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
63 | elif [ "$ARCH" = "s390" ]; then |
---|
64 | SLKCFLAGS="-O2" |
---|
65 | elif [ "$ARCH" = "x86_64" ]; then |
---|
66 | SLKCFLAGS="-O2 -fPIC" |
---|
67 | else |
---|
68 | SLKCFLAGS="-O2" |
---|
69 | fi |
---|
70 | |
---|
71 | TMP=${TMP:-/tmp} |
---|
72 | PKG=$TMP/package-git |
---|
73 | |
---|
74 | rm -rf $PKG |
---|
75 | mkdir -p $TMP $PKG |
---|
76 | |
---|
77 | cd $TMP |
---|
78 | rm -rf git-$VERSION |
---|
79 | tar xvf $CWD/git-$VERSION.tar.?z* || exit 1 |
---|
80 | cd git-$VERSION || exit 1 |
---|
81 | |
---|
82 | chown -R root:root . |
---|
83 | find . \ |
---|
84 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
85 | -exec chmod 755 {} \; -o \ |
---|
86 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
87 | -exec chmod 644 {} \; |
---|
88 | |
---|
89 | mkdir -p $PKG/usr/doc/git-$VERSION |
---|
90 | cp -a \ |
---|
91 | COPYING* INSTALL \ |
---|
92 | Documentation \ |
---|
93 | contrib \ |
---|
94 | $PKG/usr/doc/git-$VERSION |
---|
95 | #( cd $PKG/usr/doc/git-$VERSION/Documentation ; rm *.1 *.3 *.7 ) |
---|
96 | ( cd $PKG/usr/doc/git-$VERSION && find . -name ".git*" -exec rm -r "{}" \; ) |
---|
97 | |
---|
98 | make $NUMJOBS \ |
---|
99 | prefix=/usr \ |
---|
100 | mandir=/usr/man \ |
---|
101 | CFLAGS="$SLKCFLAGS" \ |
---|
102 | INSTALLDIRS=vendor \ |
---|
103 | ASCIIDOC8=YesPlease \ |
---|
104 | all doc || exit 1 |
---|
105 | |
---|
106 | make \ |
---|
107 | prefix=/usr \ |
---|
108 | mandir=/usr/man \ |
---|
109 | "CFLAGS=$SLKCFLAGS" \ |
---|
110 | INSTALLDIRS=vendor \ |
---|
111 | ASCIIDOC8=YesPlease \ |
---|
112 | install \ |
---|
113 | install-doc \ |
---|
114 | DESTDIR=$PKG || exit 1 |
---|
115 | |
---|
116 | #mv $PKG/usr/share/man/man3 $PKG/usr/man |
---|
117 | rm -rf $PKG/usr/share/man |
---|
118 | |
---|
119 | # Don't stomp on perl's file: |
---|
120 | rm -f $PKG/usr/lib*/perl5/perllocal.pod |
---|
121 | |
---|
122 | # Compress and if needed symlink the man pages: |
---|
123 | if [ -d $PKG/usr/man ]; then |
---|
124 | ( cd $PKG/usr/man |
---|
125 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
126 | ( cd $manpagedir |
---|
127 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
128 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
129 | rm $eachpage |
---|
130 | done |
---|
131 | gzip -9 *.? || true |
---|
132 | |
---|
133 | ) |
---|
134 | done |
---|
135 | ) |
---|
136 | fi |
---|
137 | |
---|
138 | find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
139 | | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
140 | |
---|
141 | # Since Stuart Winter hates hard links. ;-) |
---|
142 | # |
---|
143 | # Switch a hard link with a soft link: |
---|
144 | ( cd $PKG/usr/bin |
---|
145 | find . -links +1 -not -name git | while read gitfile ; do |
---|
146 | if [ git -ef $gitfile ]; then |
---|
147 | rm -vf $gitfile |
---|
148 | ln -vfs git $gitfile |
---|
149 | fi |
---|
150 | done |
---|
151 | ) |
---|
152 | |
---|
153 | # This removes our DESTDIR from the packlist filenames, to keep perl's |
---|
154 | # internal inventories consistent and correct. |
---|
155 | find $PKG -name .packlist | while read plist ; do |
---|
156 | sed -e "s%/share/man%/man%g" \ |
---|
157 | -e "s%$PKG%%g" \ |
---|
158 | -e "s%\.2$%\.2\.gz%g" \ |
---|
159 | -e "s%\.3pm$%\.3pm\.gz%g" \ |
---|
160 | -e "s%\.4$%\.4\.gz%g" \ |
---|
161 | -e "s%\.5$%\.5\.gz%g" \ |
---|
162 | -e "s%\.6$%\.6\.gz%g" \ |
---|
163 | -e "s%\.8$%\.8\.gz%g" \ |
---|
164 | ${plist} > ${plist}.new |
---|
165 | mv -f ${plist}.new ${plist} |
---|
166 | done |
---|
167 | |
---|
168 | # This is junk: |
---|
169 | #eval $(perl '-V:privlib') |
---|
170 | #(# cd $PKG$(dirname $privlib) && rm -rf 5.* ) |
---|
171 | |
---|
172 | mkdir -p $PKG/install |
---|
173 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
174 | |
---|
175 | cd $PKG |
---|
176 | /sbin/makepkg -l y -c n $TMP/git-$VERSION-$ARCH-$BUILD.txz |
---|
177 | |
---|