[c5c522c] | 1 | ### |
---|
| 2 | ## Slackware Package Build Script |
---|
| 3 | ## |
---|
| 4 | ## This file is to assist you in setting global |
---|
| 5 | ## package variables that can are used in Slackware |
---|
| 6 | ## build scripts download from Linuxpackages.net |
---|
| 7 | ## |
---|
| 8 | ## Copyright (C) 2004 LinuxPackages.net |
---|
| 9 | ## |
---|
| 10 | ## Redistribution and use of this software, with or without modification, is |
---|
| 11 | ## permitted provided that the following conditions are met: |
---|
| 12 | ## |
---|
| 13 | ## 1. Redistributions of this software must retain the above copyright |
---|
| 14 | ## notice, this list of conditions and the following disclaimer. |
---|
| 15 | ## |
---|
| 16 | ## THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
| 17 | ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
| 18 | ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
| 19 | ## EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
| 20 | ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 21 | ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
| 22 | ## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
| 23 | ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
| 24 | ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
| 25 | ## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | ## Version of this conf |
---|
| 30 | CONFVER=1.9 |
---|
| 31 | |
---|
| 32 | ## We need to set the umask since by default root has 0077 and this will |
---|
| 33 | ## create broken packages. |
---|
| 34 | umask 0022 |
---|
| 35 | |
---|
| 36 | ## Gota know where we are |
---|
| 37 | CWD=`pwd` |
---|
| 38 | |
---|
| 39 | ## See if the TMP variable is set |
---|
| 40 | if [ "$TMP" = "" ]; then |
---|
| 41 | TMP=/tmp |
---|
| 42 | fi |
---|
| 43 | ## Where to put packages once built |
---|
| 44 | PKG_DIR=`pwd` |
---|
| 45 | if [ ! -d $PKG_DIR ]; then |
---|
| 46 | mkdir -p $PKG_DIR |
---|
| 47 | fi |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | ## Your build tag for the build field such as jim replace the XXX. |
---|
| 51 | MYIN="1DatuX" |
---|
| 52 | |
---|
| 53 | ## Location of wget this should be fine. |
---|
| 54 | WGET="/usr/bin/wget -c" |
---|
| 55 | |
---|
| 56 | ## Set the arch we will build for |
---|
| 57 | #ARCH="i386" |
---|
| 58 | ARCH="i486" |
---|
| 59 | #ARCH="i686" |
---|
| 60 | #ARCH="x86_64" |
---|
| 61 | |
---|
| 62 | ## Determin the CFLAGS based on the arch from above |
---|
| 63 | if [ "$ARCH" = "i386" ]; then |
---|
| 64 | SLKCFLAGS="-O2 -march=i386 -mcpu=i686" |
---|
| 65 | elif [ "$ARCH" = "i486" ]; then |
---|
| 66 | SLKCFLAGS="-O2 -march=i486 -mcpu=i686" |
---|
| 67 | elif [ "$ARCH" = "i686" ]; then |
---|
| 68 | SLKCFLAGS="-O2 -march=i686 -mcpu=i686" |
---|
| 69 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 70 | SLKCFLAGS="-O2 -march=x86_64" |
---|
| 71 | fi |
---|
| 72 | |
---|
| 73 | ## CFLAGS we get these from the above settings |
---|
| 74 | CFLAGS="$SLKCFLAGS" |
---|
| 75 | |
---|
| 76 | CXX=gcc |
---|
| 77 | |
---|
| 78 | ## CXXFLAGS same as the CFLAGS |
---|
| 79 | CXXFLAGS="$SLKCFLAGS" |
---|
| 80 | |
---|
| 81 | ## MaKe some generic funtions for cleaning stipping and permissions |
---|
| 82 | |
---|
| 83 | ## Call this in the script to remove debug and junk |
---|
| 84 | strip_bin() { |
---|
| 85 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | ## Call this in the script to strip libs |
---|
| 89 | strip_lib() { |
---|
| 90 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | ## Call this in the script to strip static libs |
---|
| 94 | strip_static() { |
---|
| 95 | find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | ## Call this to zip up the man directories |
---|
| 99 | gzip_man() { |
---|
| 100 | gzip -9q $1/usr/man/*/* |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | ## Call this to zip up the info documents |
---|
| 104 | gzip_info() { |
---|
| 105 | gzip -9q $1/usr/info/* |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | ## Call this to make sure bin and sbin are the correct groups |
---|
| 109 | bin_perms() { |
---|
| 110 | for DIRECTORY in bin usr/bin usr/local/bin usr/X11R6/bin; do |
---|
| 111 | if [ -d $1/$DIRECTORY ]; then |
---|
| 112 | chown -R root.bin $1/$DIRECTORY |
---|
| 113 | chmod -R 755 $1/$DIRECTORY |
---|
| 114 | fi;done |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | sbin_perms() { |
---|
| 118 | for DIRECTORY2 in sbin usr/sbin usr/local/sbin; do |
---|
| 119 | if [ -d $1/$DIRECTORY2 ]; then |
---|
| 120 | chown -R root.bin $1/$DIRECTORY2 |
---|
| 121 | chmod -R 755 $1/$DIRECTORY2 |
---|
| 122 | fi;done |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | ## Call this to fix various permissions on the source before the compile |
---|
| 127 | ## The last two entries are for suid bins uncomment if you wish to remove them. |
---|
| 128 | |
---|
| 129 | fix_source() { |
---|
| 130 | chown -R root.root . |
---|
| 131 | find . -perm 664 -exec chmod 644 {} \; |
---|
| 132 | find . -perm 600 -exec chmod 644 {} \; |
---|
| 133 | find . -perm 444 -exec chmod 644 {} \; |
---|
| 134 | find . -perm 400 -exec chmod 644 {} \; |
---|
| 135 | find . -perm 440 -exec chmod 644 {} \; |
---|
| 136 | find . -perm 777 -exec chmod 755 {} \; |
---|
| 137 | find . -perm 775 -exec chmod 755 {} \; |
---|
| 138 | find . -perm 511 -exec chmod 755 {} \; |
---|
| 139 | find . -perm 711 -exec chmod 755 {} \; |
---|
| 140 | find . -perm 555 -exec chmod 755 {} \; |
---|
| 141 | find . -perm 666 -exec chmod 644 {} \; |
---|
| 142 | #find . -perm 2775 -exec chmod 755 {} \; |
---|
| 143 | #find . -perm 2755 -exec chmod 755 {} \; |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | ## This will handle documents care of Piotr Simon taken from checkinstall |
---|
| 148 | DOCFILES="ABOUT ABOUT-NLS ANNOUNCE AUTHORS CONFIGURATION CHANGES COPYING COPYRIGHT CREDITS ChangeLog \ |
---|
| 149 | Changelog CHANGELOG CONTRIBUTORS *FAQ* FEATURES FILES HACKING History HISTORY INSTALL* LICENSE LSM \ |
---|
| 150 | MANIFEST NEWS *README* *Readme* SITES *RELEASE* RELNOTES THANKS TIPS TODO VERSION CONFIGURATION* \ |
---|
| 151 | GPL License Doc doc Docs* docs* Roadmap ROADMAP *BUGS* index.ht* *INDEX*" |
---|
| 152 | |
---|
| 153 | ## Pass the pkg variable program name and version to this function to setup all the documents. |
---|
| 154 | ## Example create_docs $PKG apache-2.0.49 I use this method due to some scripts build mulitple |
---|
| 155 | ## packages. |
---|
| 156 | |
---|
| 157 | create_docs () { |
---|
| 158 | DOCS=$1/usr/doc/$2 |
---|
| 159 | mkdir -p ${DOCS} |
---|
| 160 | for i in ${DOCFILES}; do |
---|
| 161 | if [ -e ${i} ]; then |
---|
| 162 | if ! [ -L ${i} ]; then |
---|
| 163 | cp -a ${i} ${DOCS} |
---|
| 164 | else |
---|
| 165 | cp -LRp ${i} ${DOCS} |
---|
| 166 | fi |
---|
| 167 | fi;done |
---|
| 168 | chmod 644 $1/usr/doc/$2/* |
---|
| 169 | chown -R root.root $1/usr/doc/$2/* |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | ## A small function to uprade the slackbuilds package if needed |
---|
| 174 | |
---|
| 175 | upgrade_self() { |
---|
| 176 | # rm -rf |
---|
| 177 | mkdir -p $TMP/slackbuilds-install |
---|
| 178 | cd $TMP/slackbuilds-install |
---|
| 179 | VER_LOC="http://www1.linuxpackages.net/packages/SlackBuilds/LATESTVER" |
---|
| 180 | $WGET -q $VER_LOC || true |
---|
| 181 | NEWVER=`cat LATESTVER` |
---|
| 182 | if [[ "`cat LATESTVER`" > "$CONFVER" ]]; then |
---|
| 183 | echo " Upgraded needed $CONFVER $NEWVER " |
---|
| 184 | UPG_LOC="http://www1.linuxpackages.net/packages/SlackBuilds/slackbuilds-$NEWVER-noarch-1jim.tgz" |
---|
| 185 | $WGET $UPG_LOC || true |
---|
| 186 | upgradepkg slackbuilds-$NEWVER-noarch-1jim.tgz |
---|
| 187 | cd .. |
---|
| 188 | rm -rf slackbuilds-install |
---|
| 189 | exit |
---|
| 190 | else |
---|
| 191 | echo "Your version is current no upgrade needed your Version $CONFVER Latest Version $NEWVER" |
---|
| 192 | cd .. |
---|
| 193 | rm -rf slackbuilds-install |
---|
| 194 | exit |
---|
| 195 | fi |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | |
---|