Advertisement
Guest User

Untitled

a guest
Mar 14th, 2010
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.52 KB | None | 0 0
  1. #!/usr/bin/bash
  2. # This script assumes it will be launched within "/NAME/VERSION/src" dir.
  3. # With all sources in "src" Your Vector Linux .tlz package, slack-desc,
  4. # and slack-required will be found in "VERSION" dir. The extraction and
  5. # build will be in a temp dir created in "NAME" dir, and then removed on exit.
  6. # Comment out second to last line to keep this dir intact.
  7. #
  8. # This Template was compiled from the contributions of many users of the Vector
  9. # Linux forum at http://forum.vectorlinux.com and from tidbits collected
  10. # from all over the internet.
  11. #
  12. # Generated by sbbuilder-0.4.12, written by Rodrigo Bistolfi
  13. # (rbistolfi) and Raimon Grau Cuscó (Kidd) for VectorLinux.
  14. # Edited by J Humphrey for slackware March 12, 2010
  15. #
  16. # Please put your name below if you add some original scripting lines.
  17. # AUTHORS =
  18.  
  19. NAME="libxdg-basedir"            #Enter package Name!
  20. VERSION=${VERSION:-"1.0.2"}      #Enter package Version!
  21. VER=$(echo $VERSION|sed 's/-/_/') #this fixes - in version
  22. VL_PACKAGER=${VL_PACKAGER:-"J Humphrey"}   #Enter your Name!
  23. LINK=${LINK:-"http://n.ethz.ch/~nevillm/download/$NAME/$NAME-$VERSION.tar.gz"}  #Enter URL for package here!
  24.  
  25.  
  26. #SYSTEM VARIABLES
  27. #----------------------------------------------------------------------------
  28. BUILDNUM=${BUILDNUM:-"1"}
  29. VL_VERSION=${VL_VERSION:-"$(ls /var/log/packages/|grep vlconfig2|cut -d "-" -f4|cut -c 2-5)"}
  30. BUILD=${BUILD:-"$BUILDNUM""$VL_VERSION"}
  31. ARCH=${ARCH:-"$(uname -m)"}
  32. CONFIG_OPTIONS=${CONFIG_OPTIONS:-""}
  33. LDFLAG_OPTIONS=${LDFLAG_OPTIONS:-""}
  34. ADDRB=${ADDRB:-""} #Add deps that need to be added to the slack-required file here
  35. EXRB=${EXRB:-""} #Add deps that need to be excluded from the slack-required file here
  36. #----------------------------------------------------------------------------
  37.  
  38.  
  39. #SETUP PACKAGING ENVIRONMENT
  40. #--------------------------------------------
  41. CWD=$(pwd)
  42. cd ../
  43. RELEASEDIR=$(pwd)
  44. cd $CWD
  45. mkdir -p $RELEASEDIR/tmp
  46. TMP=$RELEASEDIR/tmp
  47. PKG=$TMP/package-$NAME
  48. #--------------------------------------------
  49.  
  50.  
  51.  
  52. if [ $UID != 0 ]; then
  53.    echo "You are not authorized to run this script. Please login as root"
  54.    exit 1
  55. fi
  56.  
  57. #if [ ! -x /usr/bin/requiredbuilder ]; then
  58. #   echo "Requiredbuilder not installed, or not executable."
  59. #   exit 1
  60. #fi
  61.  
  62. if [ $VL_PACKAGER = "YOURNAME" ]; then
  63.    echo 'Who are you?
  64.   Please edit VL_PACKAGER=${VL_PACKAGER:-YOURNAME} in this script.
  65.   Change the word "YOURNAME" to your VectorLinux packager name.
  66.   You may also export VL_PACKAGER, or call this script with
  67.   VL_PACKAGER="YOUR NAME HERE"'
  68.    exit 1
  69. fi
  70.  
  71.  
  72. #CFLAGS SETUP
  73. #--------------------------------------------
  74. if [[ "$ARCH" = i?86 ]]; then
  75.   ARCH=i586
  76.   SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  77.   CONFIGURE_TRIPLET="i486-slackware-linux"
  78. elif [ "$ARCH" = "x86_64" ]; then
  79.   SLKCFLAGS="-O2 -fpic"
  80.   CONFIGURE_TRIPLET="x86_64-vlocity-linux"
  81. elif [ "$ARCH" = "powerpc" ]; then
  82.   SLKCFLAGS="-O2"
  83.   CONFIGURE_TRIPLET="powerpc-vlocity-linux"
  84. fi
  85.  
  86. export CFLAGS="$SLKCFLAGS $CFLAG_OPTIONS"
  87. export CXXFLAGS=$CFLAGS
  88. export LDFLAGS="$LDFLAGS $LDFLAG_OPTIONS"
  89. #--------------------------------------------
  90.  
  91.  
  92. #GET THE SOURCE
  93. #--------------------------------------------
  94. for SRC in $(echo $LINK);do
  95. if [ ! -f $CWD/$(basename $SRC) ]
  96. then
  97.         wget -c $SRC
  98. fi
  99. done
  100. #--------------------------------------------
  101.  
  102.  
  103. rm -rf $PKG
  104. mkdir -p $PKG
  105. cd $TMP
  106. rm -rf $NAME-$VERSION
  107.  
  108.  
  109. #EXTRACT SOURCES
  110. #-----------------------------------------------------
  111. echo "Extracting source..."
  112. tar xvf $CWD/$NAME-$VERSION.tar.* || exit 1
  113. #-----------------------------------------------------
  114.  
  115.  
  116. cd $TMP/$NAME-$VERSION
  117.  
  118. # Put any Patches here
  119. #-----------------------------------------------------
  120. #patch -p1 <
  121. #-----------------------------------------------------
  122.  
  123.  
  124. #SET PERMISSIONS
  125. #-----------------------------------------
  126. echo "Setting permissions..."
  127. chown -R root:root .
  128. find . -perm 664 -exec chmod 644 {} \;
  129. find . -perm 777 -exec chmod 755 {} \;
  130. find . -perm 2777 -exec chmod 755 {} \;
  131. find . -perm 775 -exec chmod 755 {} \;
  132. find . -perm 2755 -exec chmod 755 {} \;
  133. find . -perm 774 -exec chmod 644 {} \;
  134. find . -perm 666 -exec chmod 644 {} \;
  135. find . -perm 600 -exec chmod 644 {} \;
  136. find . -perm 444 -exec chmod 644 {} \;
  137. find . -perm 400 -exec chmod 644 {} \;
  138. find . -perm 440 -exec chmod 644 {} \;
  139. find . -perm 511 -exec chmod 755 {} \;
  140. find . -perm 711 -exec chmod 755 {} \;
  141. find . -perm 555 -exec chmod 755 {} \;
  142. #-----------------------------------------
  143.  
  144.  
  145.  
  146. #CONFIGURE & MAKE
  147. #----------------------------------------------------------------------
  148. # If you are building a KDE-related app, then change the following
  149. # arguments in the script below:
  150. # --prefix=$(kde-config -prefix) \
  151. # --sysconfdir=/etc/kde \
  152. #
  153. # Making these changes will ensure that your package will build in the
  154. # correct path and that it will work seamlessly within the KDE environment.
  155. #
  156. #-----------------------------------------------------------------------
  157.  
  158. echo "Configuring source..."
  159. ./configure --prefix=/usr \
  160.   --sysconfdir=/etc \
  161.   --localstatedir=/var \
  162.   --mandir=/usr/man \
  163.   --with-included-gettext \
  164.   --disable-debug \
  165.   --program-prefix="" \
  166.   --program-suffix="" \
  167.   --build=$CONFIGURE_TRIPLET \
  168.   $CONFIG_OPTIONS || exit 1
  169.  
  170. make || exit 1
  171.  
  172. make install DESTDIR=$PKG || exit
  173.  
  174.  
  175.  
  176.  
  177. #######################################################################
  178. #Miscellenious tweaks and things outside a normal ./configure go here #
  179. #######################################################################
  180.  
  181. #mkdir -p $PKG/usr/share/applications
  182. #cp $CWD/$NAME.desktop $PKG/usr/share/applications/$NAME.desktop
  183. #mkdir -p $PKG/usr/share/pixmaps
  184. #cp $CWD/$NAME.png $PKG/usr/share/pixmaps/$NAME.png
  185.  
  186. mkdir -p $PKG/usr/doc/$NAME-$VERSION
  187. cp -a AUTHORS COPYING ChangeLog Credits MANIFEST README TODO \
  188. $PKG/usr/doc/$NAME-$VERSION
  189. cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild
  190.  
  191. #----------------------------------------------------------------------
  192.  
  193. if [ -d $PKG/usr/share/man ] ; then
  194. mkdir -p $PKG/usr/man
  195. mv $PKG/usr/share/man/* $PKG/usr/man
  196. rm -rf $PKG/usr/share/man
  197. fi
  198. find $PKG/usr/man -type f -exec gzip -9 {} \;
  199.  
  200. if [ -d $PKG/usr/share/info ] ; then
  201. mkdir -p $PKG/usr/info
  202. mv $PKG/usr/share/info/* $PKG/usr/info
  203. rm -rf $PKG/usr/share/info
  204. fi
  205.  
  206. find $PKG/usr/info -type f -exec gzip -9 {} \;
  207. mkdir -p $PKG/install
  208. if [ -d $PKG/usr/info ] ; then
  209. cat >> $PKG/install/doinst.sh << EOF
  210. cd usr/info
  211. if [ -f dir ]; then
  212.     rm dir
  213. fi
  214. if [ -f dir.gz ]; then
  215.     rm dir.gz
  216. fi
  217. for i in *.info.gz
  218.         do
  219.         install-info $i dir
  220.     done
  221. EOF
  222. fi
  223.  
  224. mkdir -p $PKG/install
  225.  
  226.  
  227. #if there is a slack-desc in src dir use it
  228. if test -f $CWD/slack-desc; then
  229. cp $CWD/slack-desc $RELEASEDIR/slack-desc
  230. else
  231. # This creates the white space in front of "handy-ruler" in slack-desc below.
  232.  
  233. LENGTH=$(expr length "$NAME")
  234. SPACES=0
  235. SHIM=""
  236. until [ "$SPACES" = "$LENGTH" ]; do
  237. SHIM="$SHIM "
  238. let SPACES=$SPACES+1
  239. done
  240.  
  241. # Fill in the package summary between the () below.
  242. # Then package the description, License, Author and Website.
  243. # There may be no more then 11 $NAME: lines in a valid slack-desc.
  244.  
  245. cat > $RELEASEDIR/slack-desc << EOF
  246. # HOW TO EDIT THIS FILE:
  247. # The "handy ruler" below makes it easier to edit a package description.  Line
  248. # up the first '|' above the ':' following the base package name, and the '|'
  249. # on the right side marks the last column you can put a character in.  You must
  250. # make exactly 11 lines for the formatting to be correct.  It's also
  251. # customary to leave one space after the ':'.
  252.  
  253. $SHIM|-----handy-ruler------------------------------------------------------|
  254. $NAME: $NAME (XDG specification higher level functions)
  255. $NAME: The XDG Base Directory Specification defines where should user files
  256. $NAME: be looked for by defining one or more base directories relative in
  257. $NAME: with they should be located. This library implements functions to
  258. $NAME: list the directories according to the specification and provides a
  259. $NAME: few higher-level functions.
  260. $NAME:
  261. $NAME: License: MIT License
  262. $NAME: Authors: Mark Nevill
  263. $NAME: Website: https://www.ohloh.net/p/libxdg-basedir
  264.  
  265. EOF
  266. fi
  267. cat >> $RELEASEDIR/slack-desc << EOF
  268.  
  269.  
  270.  
  271. #----------------------------------------
  272. BUILDDATE: $(date)
  273. PACKAGER:  $VL_PACKAGER
  274. HOST:      $(uname -srm)
  275. DISTRO:    $(cat /etc/vector-version)
  276. CFLAGS:    $CFLAGS
  277. LDFLAGS:   $LDFLAGS
  278. CONFIGURE: $(awk "/\.\/configure\ /" $TMP/$NAME-$VERSION/config.log)
  279.  
  280. EOF
  281.  
  282. cat $RELEASEDIR/slack-desc > $PKG/install/slack-desc
  283.  
  284. #STRIPPING
  285. #------------------------------------------------------------------------------------------------------------------
  286. cd $PKG
  287. echo " "
  288. echo "Stripping...."
  289. echo " "
  290. find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  291. find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  292. #------------------------------------------------------------------------------------------------------------------
  293.  
  294.  
  295. #FINISH PACKAGE
  296. #--------------------------------------------------------------
  297. #echo "Finding dependencies..."
  298. #ADD="$ADDRB" EXCLUDE="$EXRB" requiredbuilder -v -y -s $RELEASEDIR $PKG
  299. echo "Creating package $NAME-$VERSION-$ARCH-$BUILD.tlz"
  300. makepkg -l y -c n $RELEASEDIR/$NAME-$VERSION-$ARCH-$BUILD.tgz
  301.  
  302. #cd $CWD
  303. #echo "Cleaning up temp files..." && rm -rf $TMP
  304. echo "Package Complete"
  305. #--------------------------------------------------------------
  306.  
  307. # vim: set tabstop=4 shiftwidth=4 foldmethod=marker : ##
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement