Advertisement
Guest User

Untitled

a guest
Jul 11th, 2011
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # GENERAL INFO
  4. PKGNAME=`echo $1 | rev | cut -d/ -f1 | rev | sed s/.tar.gz// | sed s/.tar.bz2// | sed s/.zip//`
  5. SUFFIX=`echo $1 | sed s/$PKGNAME// | rev | cut -d/ -f1 | rev | sed s/^.//`
  6. ARCH=x86_64
  7. BUILD=1ftm
  8. TMP=/tmp/src2xzm
  9. SOURCE=$TMP/SOURCE
  10. WORK=$TMP/WORK
  11. TOGO=/root/paczki
  12.  
  13. c='\e[36m'
  14. r='\e[38m'
  15. e=`tput sgr0`
  16.  
  17. if [ ! -x /usr/bin/make ]; then
  18. echo
  19. echo -e "${r}please activate 005-devel module first..."$e
  20. echo
  21. exit 1
  22. fi
  23.  
  24. if [ "$1" = "" -o "$1" = "--help" -o "$1" = "-h" -o "$1" = "-help" -o "$1" = "help" ]; then
  25. echo
  26. echo -e "${r}launch me as $0 path_to_source"$e
  27. echo
  28. exit 1
  29. fi
  30.  
  31. if [ "$SUFFIX" = "tar.gz" -o "$SUFFIX" = "tar.bz2" -o "$SUFFIX" = "zip" ]; then
  32. echo
  33. echo -e "${c}$SUFFIX archive found, proceeding..."$e
  34. else
  35. echo
  36. echo -e "${r}only following archives are supported: tar.gz, tar.bz2 and zip"$e
  37. echo
  38. exit 1
  39. fi
  40.  
  41. if [ -d $TMP ]; then
  42. echo
  43. echo -e "${r}clearing files from previous run"$e
  44. rm -r $TMP
  45. fi
  46. mkdir $TMP $SOURCE $WORK $TOGO 2>/dev/null
  47.  
  48. # step 1: UNPACK SOURCE AND PREPARE PACKAGE
  49. if [ "$SUFFIX" = "zip" ]; then
  50. unzip -q $1 -d $SOURCE
  51. else
  52. tar xf $1 -C $SOURCE
  53. fi
  54. PKG=`ls $SOURCE`
  55. cd $SOURCE/$PKG
  56.  
  57. case "$ARCH" in
  58. "i686") SLKCFLAGS="-O2 -march=i686 -mtune=i686" ;;
  59. "i486") SLKCFLAGS="-O2 -march=i486 -mtune=i686" ;; # or Os for reducing size
  60. "i386") SLKCFLAGS="-O2 -march=i386 -mcpu=i686" ;;
  61. "x86_64") SLKCFLAGS="-Os -march=x86-64 -fPIC" ;;
  62. "native") SLKCFLAGS="-O2 -march=native -mtune=native" ;;
  63. *) SLKCFLAGS="-O2" ;;
  64. esac
  65.  
  66. echo
  67. echo -e "${c}please provide extra configuration parameters for this package,
  68. press enter to stick with default ones or type ? for listing availiable options
  69.  
  70. Example:
  71. --enable-gtk"$e
  72. echo
  73. read answer
  74. echo
  75. if [ "$answer" = "?" ]; then
  76. ./configure --help
  77. echo
  78. echo -e "${c}please provide extra configuration options for this package or
  79. press enter to stick with default ones"$e
  80. echo
  81. read answer
  82. echo
  83. fi
  84.  
  85. CONFIG=`echo $answer`
  86.  
  87. #if [ -e 'Makefile' ]; then
  88. CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" MAKEOPTS="-j2" ./configure \
  89. --prefix=/usr \
  90. --disable-static \
  91. --libdir=/usr/lib64 \
  92. --mandir=/usr/man \
  93. $CONFIG
  94. --sysconfdir=/etc \
  95. --program-prefix="" \
  96. --program-suffix="" \
  97. --build=$ARCH-Slackware-linux
  98. #fi
  99.  
  100. echo
  101. echo -e "${c}if configuration stage finished successfully then press enter to start
  102. compilation or press ctrl+c to exit"$e
  103. read
  104. echo
  105.  
  106. make
  107. make install DESTDIR=$WORK
  108.  
  109. # step 2: PACKAGE DESCRIPTION
  110. clear
  111. NAME=`echo $PKG | rev | cut -d- -f2- | rev`
  112. mkdir $WORK/install
  113. echo > ./file
  114. dialog --title "Please provide package description and press 'OK' to continue" \
  115. --editbox ./file 15 60 \
  116. 2>./desc
  117. cat ./desc | fmt -w $(( 80 - `echo $NAME | wc -c` - 3 )) | perl -pe "s/^/$NAME: /" > $WORK/install/slack-desc
  118.  
  119. # step 3: STRIP BINARIES
  120. cd $WORK
  121. ( find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : \
  122. | xargs strip --strip-unneeded 2> /dev/null
  123. find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : \
  124. | xargs strip --strip-unneeded 2> /dev/null
  125. find . | xargs file | grep "current ar archive" | grep ELF | cut -f 1 -d : \
  126. | xargs strip --strip-debug 2> /dev/null )
  127.  
  128. # step 4: CREATE PACKAGE & CLEAN TMP
  129. if [ `find . | wc -l` -le 1 ]; then
  130. echo -e "${r}no files found!"$e
  131. else
  132. makepkg -l y -c n $TOGO/$PKG-$ARCH-$BUILD.txz
  133. rm -r $SOURCE $WORK
  134. fi
  135.  
  136. # step 5: CREATE MODULE
  137. cd $TOGO
  138. txz2xzm $PKG-$ARCH-$BUILD.txz $PKG-$ARCH-$BUILD.xzm
  139. rm $PKG-$ARCH-$BUILD.txz
  140.  
  141. # FINISH
  142. echo
  143. echo -e "${r}$PKG-$ARCH-$BUILD module is created in $TOGO directory."$e
  144. echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement