|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# openGLReftoMan.SlackBuild - SlackBuild script for creating OpenGL Ref manpages |
| 4 | +# Copyright © 2022 Necib ÇAPAR <necipcapar@gmail.com> |
| 5 | + |
| 6 | +# This file is part of openGLRefToMan |
| 7 | + |
| 8 | +# openGLRefToMan is free software: you can redistribute it and/or modify |
| 9 | +# it under the terms of the GNU General Public License as published by |
| 10 | +# the Free Software Foundation, either version 3 of the License, or |
| 11 | +# (at your option) any later version. |
| 12 | + |
| 13 | +# openGLRefToMan is distributed in the hope that it will be useful, |
| 14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +# GNU General Public License for more details. |
| 17 | + |
| 18 | +# You should have received a copy of the GNU General Public License |
| 19 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + |
| 21 | +cd $(dirname $0) ; CWD=$(pwd) |
| 22 | + |
| 23 | +PRGNAM=openGLRefToMan # replace with name of program |
| 24 | +VERSION=${VERSION:-1.0.0} # replace with version of program |
| 25 | +BUILD=${BUILD:-1} |
| 26 | +TAG=${TAG:-_SBo} |
| 27 | +PKGTYPE=${PKGTYPE:-tgz} |
| 28 | + |
| 29 | +if [ -z "$ARCH" ]; then |
| 30 | + case "$( uname -m )" in |
| 31 | + i?86) ARCH=i586 ;; |
| 32 | + arm*) ARCH=arm ;; |
| 33 | + *) ARCH=$( uname -m ) ;; |
| 34 | + esac |
| 35 | +fi |
| 36 | + |
| 37 | +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what |
| 38 | +# the name of the created package would be, and then exit. This information |
| 39 | +# could be useful to other scripts. |
| 40 | +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then |
| 41 | + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" |
| 42 | + exit 0 |
| 43 | +fi |
| 44 | + |
| 45 | +TMP=${TMP:-/tmp/SBo} |
| 46 | +PKG=$TMP/package-$PRGNAM |
| 47 | +OUTPUT=${OUTPUT:-/tmp} |
| 48 | + |
| 49 | +if [ "$ARCH" = "i586" ]; then |
| 50 | + SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
| 51 | + LIBDIRSUFFIX="" |
| 52 | +elif [ "$ARCH" = "i686" ]; then |
| 53 | + SLKCFLAGS="-O2 -march=i686 -mtune=i686" |
| 54 | + LIBDIRSUFFIX="" |
| 55 | +elif [ "$ARCH" = "x86_64" ]; then |
| 56 | + SLKCFLAGS="-O2 -fPIC" |
| 57 | + LIBDIRSUFFIX="64" |
| 58 | +else |
| 59 | + SLKCFLAGS="-O2" |
| 60 | + LIBDIRSUFFIX="" |
| 61 | +fi |
| 62 | + |
| 63 | +set -e |
| 64 | + |
| 65 | +rm -rf $PKG |
| 66 | +mkdir -p $TMP $PKG $OUTPUT |
| 67 | +cd $TMP |
| 68 | +rm -rf $PRGNAM-$VERSION |
| 69 | + |
| 70 | +# If required download source files into source directory |
| 71 | +if [ ! -f $CWD/$PRGNAM-$VERSION.tar.gz ]; then |
| 72 | + mkdir $PRGNAM-$VERSION |
| 73 | + cd $PRGNAM-$VERSION |
| 74 | + |
| 75 | + # get official OpenGL-Reference sources |
| 76 | + openGLRef_website=${source_website:-'https://github.com/KhronosGroup/OpenGL-Refpages/archive/refs/heads/main.zip'} |
| 77 | + LANG=us wget --execute robots=off --no-parent --no-host-directories --no-verbose \ |
| 78 | + --no-check-certificate $openGLRef_website |
| 79 | + |
| 80 | + unzip main.zip |
| 81 | + rm --verbose main.zip |
| 82 | + |
| 83 | + # get corrected_manpages/ and scripts/ directory from the maintainer's repo |
| 84 | + slackBuild_scr_website=${scr_website:-'https://github.com/N-Tek/openGLRefToMan/archive/refs/heads/master.zip'} |
| 85 | + LANG=us wget --execute robots=off --no-parent --no-host-directories --no-verbose \ |
| 86 | + --no-check-certificate $slackBuild_scr_website |
| 87 | + |
| 88 | + unzip master.zip *corrected_manpages* *scripts* |
| 89 | + mv openGLRefToMan-master/SlackBuild/sources/{corrected_manpages,scripts} . |
| 90 | + rm --verbose --force --recursive master.zip openGLRefToMan-master |
| 91 | + |
| 92 | + cd .. |
| 93 | +else |
| 94 | + tar --extract --verbose --file="$CWD/$PRGNAM-$VERSION.tar.gz" |
| 95 | +fi |
| 96 | + |
| 97 | +cd $PRGNAM-$VERSION |
| 98 | +chown -R root:root . |
| 99 | +find -L . \ |
| 100 | + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ |
| 101 | + -o -perm 511 \) -exec chmod 755 {} \; -o \ |
| 102 | + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ |
| 103 | + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; |
| 104 | + |
| 105 | +mkdir --parents patches |
| 106 | +scripts/OpenGLprocessRepo.sh OpenGL-Refpages* |
| 107 | +scripts/OpenGLcreateManPatches.sh ./OpenGL-Refpages*/man3 ./corrected_manpages/* ./patches |
| 108 | +scripts/OpenGLpatchManPages.sh OpenGL-Refpages*/man3 patches |
| 109 | + |
| 110 | +mkdir --parents $PKG/usr/man |
| 111 | +cp --archive $TMP/$PRGNAM-$VERSION/OpenGL-Refpages*/man3 $PKG/usr/man |
| 112 | + |
| 113 | +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION |
| 114 | +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild |
| 115 | + |
| 116 | +mkdir -p $PKG/install |
| 117 | +if [ -f $CWD/slack-desc ]; then |
| 118 | + cat $CWD/slack-desc > $PKG/install/slack-desc |
| 119 | +else |
| 120 | +echo "# HOW TO EDIT THIS FILE: |
| 121 | +# The \"handy ruler\" below makes it easier to edit a package description. |
| 122 | +# Line up the first '|' above the ':' following the base package name, and |
| 123 | +# the '|' on the right side marks the last column you can put a character in. |
| 124 | +# You must make exactly 11 lines for the formatting to be correct. It's also |
| 125 | +# customary to leave one space after the ':' except on otherwise blank lines. |
| 126 | +
|
| 127 | + |-----handy-ruler------------------------------------------------------| |
| 128 | +openGLRefToMan: openGLRefToMan (manpages for OpenGL API references) |
| 129 | +openGLRefToMan: |
| 130 | +openGLRefToMan: converted OpenGL API references in manpage format |
| 131 | +openGLRefToMan: |
| 132 | +openGLRefToMan: |
| 133 | +openGLRefToMan: |
| 134 | +openGLRefToMan: |
| 135 | +openGLRefToMan: |
| 136 | +openGLRefToMan: |
| 137 | +openGLRefToMan: |
| 138 | +openGLRefToMan: https://github.com/N-Tek/openGLRefToMan.git" >| $PKG/install/slack-desc |
| 139 | +fi |
| 140 | + |
| 141 | +if [ -f $CWD/doinst.sh ]; then |
| 142 | + cat $CWD/doinst.sh >| $PKG/install/doinst.sh |
| 143 | +else # update whatis database after taking a backup with .orig suffix |
| 144 | +echo "if [ -f /usr/man/whatis.orig ]; then |
| 145 | + cp --verbose --archive /usr/man/whatis.orig /usr/man/whatis |
| 146 | +fi |
| 147 | +cp --verbose --archive /usr/man/whatis /usr/man/whatis.orig |
| 148 | +/usr/sbin/makewhatis -u -v -s 3" >| $PKG/install/doinst.sh |
| 149 | +chmod 0644 $PKG/install/doinst.sh |
| 150 | +fi |
| 151 | + |
| 152 | +cd $PKG |
| 153 | +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE |
0 commit comments