slackbuilds

My Slackbuilds
git clone git://git.server.ky/slackcoder/slackbuilds
Log | Files | Refs | README

cgit.SlackBuild (4392B)


      1 #!/bin/bash
      2 
      3 # Slackware build script for cgit
      4 # Copyright 2013-2020 Matteo Bernardini <ponce@slackbuilds.org>, Pisa, Italy
      5 # All rights reserved.
      6 #
      7 # Redistribution and use of this script, with or without modification, is
      8 # permitted provided that the following conditions are met:
      9 #
     10 # 1. Redistributions of this script must retain the above copyright
     11 #    notice, this list of conditions and the following disclaimer.
     12 #
     13 #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
     14 #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     15 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
     16 #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     17 #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     18 #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     19 #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     20 #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     21 #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     22 #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     23 
     24 cd $(dirname $0) ; CWD=$(pwd)
     25 
     26 PRGNAM=cgit
     27 VERSION=${VERSION:-1.2.3}
     28 BUILD=${BUILD:-1}
     29 TAG=${TAG:-_slackcoder}
     30 PKGTYPE=${PKGTYPE:-tgz}
     31 
     32 DOCROOT=${DOCROOT:-/var/www}
     33 
     34 if [ -z "$ARCH" ]; then
     35   case "$( uname -m )" in
     36     i?86) ARCH=i586 ;;
     37     arm*) ARCH=arm ;;
     38        *) ARCH=$( uname -m ) ;;
     39   esac
     40 fi
     41 
     42 # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
     43 # the name of the created package would be, and then exit. This information
     44 # could be useful to other scripts.
     45 if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
     46   echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
     47   exit 0
     48 fi
     49 
     50 TMP=${TMP:-/tmp/SBo}
     51 PKG=$TMP/package-$PRGNAM
     52 OUTPUT=${OUTPUT:-/tmp}
     53 
     54 if [ "$ARCH" = "i586" ]; then
     55   SLKCFLAGS="-O2 -march=i586 -mtune=i686"
     56   LIBDIRSUFFIX=""
     57 elif [ "$ARCH" = "i686" ]; then
     58   SLKCFLAGS="-O2 -march=i686 -mtune=i686"
     59   LIBDIRSUFFIX=""
     60 elif [ "$ARCH" = "x86_64" ]; then
     61   SLKCFLAGS="-O2 -fPIC"
     62   LIBDIRSUFFIX="64"
     63 else
     64   SLKCFLAGS="-O2"
     65   LIBDIRSUFFIX=""
     66 fi
     67 
     68 CGIT_VERSION=${CGIT_VERSION:-v$VERSION}
     69 GIT_VERSION=${GIT_VERSION:-2.26.2}
     70 
     71 DOCS="cgitrc.5.txt COPYING README $CWD/config/cgitrc.sample \
     72       $CWD/config/cgit-lighttpd.conf $CWD/config/cgit-httpd.conf \
     73       $CWD/config/email-libravatar-korg-additions.css \
     74       $CWD/config/email-gravatar-sbo-additions.css"
     75 
     76 set -e
     77 
     78 rm -rf $PKG
     79 mkdir -p $TMP $PKG $OUTPUT
     80 cd $TMP
     81 rm -rf $PRGNAM-$VERSION
     82 tar xvf $CWD/v$VERSION.tar.gz || tar xvf $CWD/$PRGNAM-$VERSION.tar.?z*
     83 cd $PRGNAM-$VERSION
     84 chown -R root:root .
     85 find -L . \
     86 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
     87  -o -perm 511 \) -exec chmod 755 {} \; -o \
     88  \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
     89  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
     90 
     91 # prepare sources
     92 sed -i Makefile \
     93     -e "s|-g -Wall -Igit|-Wall ${SLKCFLAGS} -Igit|" \
     94     -e "s|\/lib$|/lib${LIBDIRSUFFIX}|" \
     95     -e "s|(libdir)|(prefix)/share|" \
     96     -e "s|/usr/local|/usr|" || exit 1
     97 sed -e "s|@DOCROOT@|$DOCROOT|g" $CWD/config/cgit.conf > cgit.conf
     98 echo "CGIT_VERSION = $CGIT_VERSION" >> cgit.conf
     99 
    100 # extract the git tarball
    101 rm -fR git
    102 tar xvf $CWD/git-$GIT_VERSION.tar.?z*
    103 mv git-* git
    104 
    105 for p in $CWD/patch/*.patch; do
    106   echo "applying patch $p"
    107   patch -p1 <"$p"
    108 done
    109 
    110 make
    111 make install DESTDIR=$PKG
    112 
    113 find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
    114   | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
    115 
    116 # install additionals lua scripts
    117 install -m 0644 -D $CWD/config/email-libravatar-korg.lua \
    118   $PKG/usr/share/cgit/filters/email-libravatar-korg.lua
    119 install -m 0644 -D $CWD/config/email-gravatar-sbo.lua \
    120   $PKG/usr/share/cgit/filters/email-gravatar-sbo.lua
    121 
    122 mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
    123 install -m0644 -oroot $DOCS $PKG/usr/doc/$PRGNAM-$VERSION
    124 sed -i "s|@DOCROOT@|$DOCROOT|g" $PKG/usr/doc/$PRGNAM-$VERSION/*
    125 cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
    126 
    127 # prepare the cache dir: default permissions are for the apache user and group
    128 mkdir -p $PKG/var/cache/cgit
    129 chown 80:80 $PKG/var/cache/cgit
    130 chmod 775 $PKG/var/cache/cgit
    131 
    132 mkdir -p $PKG/install
    133 cat $CWD/slack-desc > $PKG/install/slack-desc
    134 
    135 cd $PKG
    136 /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE