[c5c522c] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | # Copyright 2008, 2009, 2010, 2012, 2013, 2015, 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 | # Modified 2012 by Eric Hameleers <alien at slackware.com> for ARM port. |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | VERSION=${VERSION:-$(echo samba-*.tar.gz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
| 27 | BUILD=${BUILD:-3} |
---|
| 28 | |
---|
| 29 | if [ -e $CWD/machine.conf ]; then |
---|
| 30 | . $CWD/machine.conf ] |
---|
| 31 | elif [ -e /etc/slackbuild/machine.conf ]; then |
---|
| 32 | . /etc/slackbuild/machine.conf ] |
---|
| 33 | else |
---|
| 34 | # Automatically determine the architecture we're building on: |
---|
| 35 | if [ -z "$ARCH" ]; then |
---|
| 36 | case "$( uname -m )" in |
---|
| 37 | i?86) export ARCH=i586 ;; |
---|
| 38 | arm*) export ARCH=arm ;; |
---|
| 39 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 40 | *) export ARCH=$( uname -m ) ;; |
---|
| 41 | esac |
---|
| 42 | fi |
---|
| 43 | # Set CFLAGS/CXXFLAGS and LIBDIRSUFFIX: |
---|
| 44 | if [ "$ARCH" = "i586" ]; then |
---|
| 45 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
| 46 | LIBDIRSUFFIX="" |
---|
| 47 | elif [ "$ARCH" = "s390" ]; then |
---|
| 48 | SLKCFLAGS="-O2" |
---|
| 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 | fi |
---|
| 58 | |
---|
| 59 | case "$ARCH" in |
---|
| 60 | arm*) TARGET=$ARCH-slackware-linux-gnueabi ;; |
---|
| 61 | *) TARGET=$ARCH-slackware-linux ;; |
---|
| 62 | esac |
---|
| 63 | |
---|
| 64 | CWD=$(pwd) |
---|
| 65 | TMP=${TMP:-/tmp} |
---|
| 66 | PKG=$TMP/package-samba |
---|
| 67 | rm -rf $PKG |
---|
| 68 | mkdir -p $TMP $PKG |
---|
| 69 | |
---|
| 70 | if [ -r /usr/lib${LIBDIRSUFFIX}/libtalloc.so.? -a ! -r /var/log/packages/talloc* ]; then |
---|
| 71 | echo "The Samba package needs to be removed before building to ensure that" |
---|
| 72 | echo "talloc (and possibly other bundled libraries) are included in the build." |
---|
| 73 | echo |
---|
| 74 | echo "Removing the Samba package in 15 seconds, and then continuing with the build." |
---|
| 75 | sleep 15 |
---|
| 76 | removepkg samba |
---|
| 77 | fi |
---|
| 78 | |
---|
| 79 | cd $TMP |
---|
| 80 | rm -rf samba-$VERSION |
---|
| 81 | tar xvf $CWD/samba-$VERSION.tar.gz || exit 1 |
---|
| 82 | cd samba-$VERSION || exit 1 |
---|
| 83 | |
---|
| 84 | # Patch to install talloc/tevent/tdb libraries and includes: |
---|
| 85 | zcat $CWD/samba.install.talloc.tevent.tdb.diff.gz | patch -p1 --verbose || exit 1 |
---|
| 86 | |
---|
| 87 | if [ ! -d source3/lib/cmdline ]; then |
---|
| 88 | ( cd source3/lib |
---|
| 89 | mkdir cmdline |
---|
| 90 | cd cmdline |
---|
| 91 | ln -sf ../../../source3/include/popt_common.h . ) |
---|
| 92 | fi |
---|
| 93 | |
---|
| 94 | chown -R root:root . |
---|
| 95 | find . \ |
---|
| 96 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
| 97 | -exec chmod 755 {} \; -o \ |
---|
| 98 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
| 99 | -exec chmod 644 {} \; |
---|
| 100 | |
---|
| 101 | # Some of these options could be auto-detected, but declaring them |
---|
| 102 | # here doesn't hurt and helps document what features we're trying to |
---|
| 103 | # build in. |
---|
| 104 | # |
---|
| 105 | # LDFLAGS are needed to avoid problems with missing symbols. |
---|
| 106 | LDFLAGS="-Wl,--no-as-needed" \ |
---|
| 107 | CFLAGS="$SLKCFLAGS" \ |
---|
| 108 | ./configure \ |
---|
| 109 | --enable-fhs \ |
---|
| 110 | --prefix=/usr \ |
---|
| 111 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
| 112 | --includedir=/usr/include \ |
---|
| 113 | --bindir=/usr/bin \ |
---|
| 114 | --sbindir=/usr/sbin \ |
---|
| 115 | --mandir=/usr/man \ |
---|
| 116 | --sysconfdir=/etc \ |
---|
| 117 | --with-configdir=/etc/samba \ |
---|
| 118 | --with-piddir=/var/run \ |
---|
| 119 | --with-privatedir=/var/lib/samba/private \ |
---|
| 120 | --with-privatelibdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
| 121 | --with-modulesdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
| 122 | --with-lockdir=/var/cache/samba \ |
---|
| 123 | --with-logfilebase=/var/log/samba \ |
---|
| 124 | --localstatedir=/var \ |
---|
| 125 | --enable-cups \ |
---|
| 126 | --with-acl-support \ |
---|
| 127 | --with-automount \ |
---|
| 128 | --with-quotas \ |
---|
| 129 | --with-syslog \ |
---|
| 130 | --with-utmp \ |
---|
| 131 | --with-winbind \ |
---|
| 132 | --with-ldap \ |
---|
| 133 | --with-ads \ |
---|
| 134 | --without-pam \ |
---|
| 135 | --build=$TARGET |
---|
| 136 | # Gives errors: |
---|
| 137 | #--builtin-libraries=replace,ccan \ |
---|
| 138 | #--bundled-libraries=heimdal \ |
---|
| 139 | |
---|
| 140 | # -j options don't seem to work... [Yes they do! At least try to use -j below...] |
---|
| 141 | JOBS=1 |
---|
| 142 | MAXJOBS=20 |
---|
| 143 | export JOBS MAXJOBS |
---|
| 144 | make -j $MAXJOBS || make || exit 1 |
---|
| 145 | |
---|
| 146 | mkdir -p \ |
---|
| 147 | $PKG/usr/doc/samba-$VERSION \ |
---|
| 148 | $PKG/var/spool/samba \ |
---|
| 149 | $PKG/var/log/samba \ |
---|
| 150 | $PKG/var/lib/samba/private \ |
---|
| 151 | $PKG/var/cache/samba |
---|
| 152 | chmod 700 $PKG/var/lib/samba/private |
---|
| 153 | chmod 1777 $PKG/var/spool/samba |
---|
| 154 | |
---|
| 155 | make install DESTDIR=$PKG || exit 1 |
---|
| 156 | |
---|
| 157 | # Install the smbprint script: |
---|
| 158 | install -m0744 packaging/printing/smbprint $PKG/usr/bin/smbprint |
---|
| 159 | |
---|
| 160 | # Add a sample config file: |
---|
| 161 | cat $CWD/smb.conf.default > $PKG/etc/samba/smb.conf-sample |
---|
| 162 | |
---|
| 163 | # Setup a default lmhosts file: |
---|
| 164 | echo "127.0.0.1 localhost" > $PKG/etc/samba/lmhosts.new |
---|
| 165 | |
---|
| 166 | if [ ! -r $PKG/usr/bin/smbget ]; then |
---|
| 167 | rm -f $PKG/usr/share/man/man1/smbget.1 |
---|
| 168 | fi |
---|
| 169 | |
---|
| 170 | # We'll add rc.samba to the init directory, but chmod 644 so that it doesn't |
---|
| 171 | # start by default: |
---|
| 172 | mkdir -p $PKG/etc/rc.d |
---|
| 173 | cat $CWD/rc.samba > $PKG/etc/rc.d/rc.samba.new |
---|
| 174 | chmod 644 $PKG/etc/rc.d/rc.samba.new |
---|
| 175 | |
---|
| 176 | #mv $PKG/usr/share/man $PKG/usr |
---|
| 177 | #gzip -9 $PKG/usr/man/man?/*.? |
---|
| 178 | |
---|
| 179 | find $PKG | xargs file | grep -e "executable" -e "shared object" \ |
---|
| 180 | | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 181 | |
---|
| 182 | # PAM related stuff we don't use: |
---|
| 183 | #rm -r $PKG/usr/share/locale |
---|
| 184 | rm -f $PKG/usr/man/man8/pam* |
---|
| 185 | |
---|
| 186 | cp -a \ |
---|
| 187 | COPYING* PFIF.txt README* \ |
---|
| 188 | Roadmap WHATSNEW.txt docs examples \ |
---|
| 189 | $PKG/usr/doc/samba-$VERSION |
---|
| 190 | # These are installed elsewhere: |
---|
| 191 | rm -rf $PKG/usr/doc/samba-$VERSION/docs/htmldocs \ |
---|
| 192 | $PKG/usr/doc/samba-$VERSION/docs/manpages |
---|
| 193 | # Empty now? |
---|
| 194 | rmdir $PKG/usr/doc/samba-$VERSION/docs 2> /dev/null |
---|
| 195 | # I'm sorry, but when all this info is included in HTML, adding 7MB worth of |
---|
| 196 | # PDF files just to have extra artwork is more fluff than I'll agree to. |
---|
| 197 | rm -f $PKG/usr/doc/samba-$VERSION/docs/*.pdf |
---|
| 198 | # Also redundant also: |
---|
| 199 | rm -rf $PKG/usr/doc/samba-$VERSION/docs/docbook |
---|
| 200 | |
---|
| 201 | mkdir -p $PKG/install |
---|
| 202 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 203 | zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
| 204 | |
---|
| 205 | cat << EOF |
---|
| 206 | |
---|
| 207 | *** Be sure the package contains: |
---|
| 208 | |
---|
| 209 | drwxr-xr-x 2 root root 4096 May 3 15:46 /var/cache/samba/ |
---|
| 210 | drwx------ 2 root root 1024 Mar 12 13:21 /var/lib/samba/private |
---|
| 211 | drwxr-xr-x 2 root root 48 Aug 29 13:06 /var/log/samba/ |
---|
| 212 | drwxrwxrwt 2 root root 1024 Mar 12 13:21 /var/spool/samba/ |
---|
| 213 | |
---|
| 214 | EOF |
---|
| 215 | |
---|
| 216 | cd $PKG |
---|
| 217 | /sbin/makepkg -l y -c n $TMP/samba-$VERSION-$ARCH-$BUILD.txz |
---|
| 218 | |
---|