Advertisement
Guest User

ponce

a guest
Sep 16th, 2009
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.94 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Copyright 2006, 2007, 2008, 2009 Eric Hameleers, Eindhoven, NL
  4. # Copyright 2009 Patrick J. Volkerding, Sebeka, MN, USA
  5. # All rights reserved.
  6. #
  7. # Permission to use, copy, modify, and distribute this software for
  8. # any purpose with or without fee is hereby granted, provided that
  9. # the above copyright notice and this permission notice appear in all
  10. # copies.
  11. #
  12. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. # IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. # SUCH DAMAGE.
  24. # -----------------------------------------------------------------------------
  25. #
  26. # Slackware SlackBuild script
  27. # ===========================
  28. # By: Eric Hameleers <alien@slackware.com>
  29. # For: MPlayer
  30. # Descr: a movie player for LINUX
  31. # URL: http://www.mplayerhq.hu/
  32. # -----------------------------------------------------------------------------
  33.  
  34. PRGNAM=MPlayer32
  35. SRCNAM=MPlayer
  36. VERSION=${VERSION:-r29681}
  37. ARCH=${ARCH:-x86_64}
  38. BUILD=${BUILD:-1}
  39. TAG=${TAG:-ponce}
  40.  
  41. DOCS="AUTHORS Changelog Copyright LICENSE README DOCS/HTML-single DOCS/tech"
  42.  
  43. DEFSKIN=${DEFSKIN:-"Blue"} # Download more skins at the following url:
  44. SKINVER=${SKINVER:-"1.7"} # http://www.mplayerhq.hu/design7/dload.html
  45.  
  46. # Available languages: all bg cs de dk el en es fr hu it ja
  47. # ko mk nb nl pl ro ru sk sv tr uk pt_BR zh_CN zh_TW
  48. LANGUAGES="it en" # The default is to just add "en" documentation
  49.  
  50. EXTRACONFIGUREOPTIONS=""
  51. LIBDIRSUFFIX="64"
  52.  
  53. CODECSDIR=/usr/lib/codecs # Where the WIN32 codecs are expected for instance
  54.  
  55. # ---------------------------------------------------------------------------
  56. # -- PATENT ALERT! --
  57. # MPlayer source contains an internal copy of 'libdvdcss' for reading DVD's.
  58. # This is considered illegal software in some countries.
  59. # Also, MPLayer can be built with MP3 (lame) and AMR audio encoders
  60. # (needed for FLV and .3GP videos) but these libraries are 'contaminated'
  61. # with patents from Fraunhofer and GGP.
  62. # Also, the AAC encoder has patent issues.
  63. # The Slackware package is built with "USE_PATENTS=NO" i.e. without using
  64. # the lame mp3, faac, AMR and dvdcss libraries.
  65. # This also means that this creates a version of MPlayer that is unable
  66. # to play encrypted DVD's (which is most DVD's on the market). If it is
  67. # allowed in your country to use libdvdcss, this is not a big problem though.
  68. # Install a libdvdcss package and it will be picked up automatically by
  69. # MPlayer's internal libdvdread library, so that MPlayer will again be able
  70. # to play encrypted DVD's.
  71. #
  72. # If you have licenses to use the code, and/or the patents do not apply in
  73. # your region, and you take all legal responsibility, you may wish to build
  74. # MPlayer with the option USE_PATENTS=YES which will include potentially
  75. # patent-encumbered code.
  76. # ---------------------------------------------------------------------------
  77. USE_PATENTS=${USE_PATENTS:-"YES"}
  78.  
  79. # MPlayer will try to use one of the TrueType fonts present on the target
  80. # system for it's On Screen Display (OSD) font.
  81. # Slackware 11.0 ships with the Vera and DejaVu fonts, you may want to add
  82. # more fonts to this list. The first font found will be used by creating a
  83. # symbolic link "/usr/share/mplayer/subfont.ttf" to it.
  84. # The use of bitmapped fonts is considered deprecated, but you can still use
  85. # those if you want. Read http://www.mplayerhq.hu/DOCS/HTML/en/fonts-osd.html
  86. # if you want to know more about OSD font configuration.
  87. OSDFONTS="LiberationSans-Regular.ttf \
  88. Arialuni.ttf arial.ttf \
  89. DejaVuSans.ttf Vera.ttf"
  90.  
  91. # We will work with a stripped-down source tarball, not containing libdvdcss:
  92. [ "$USE_PATENTS" != "YES" ] && EXTRA="_nolibdvdcss" || EXTRA=""
  93.  
  94. # Where do we look for sources?
  95. SRCDIR=$(cd $(dirname $0); pwd)
  96.  
  97. SOURCE[0]="$SRCDIR/${SRCNAM}${EXTRA}-${VERSION}.tar.xz"
  98. SRCURL[0]=""
  99.  
  100. # The default skin to use (we need to add at least one)
  101. SOURCE[1]="$SRCDIR/${DEFSKIN}-${SKINVER}.tar.bz2"
  102. SRCURL[1]="http://www.mplayerhq.hu/MPlayer/skins/${DEFSKIN}-${SKINVER}.tar.bz2"
  103.  
  104. # Use the src_checkout() function if no downloadable tarball exists.
  105. # This function checks out sources from SVN/CVS and creates a tarball of them.
  106. src_checkout() {
  107. # Param #1 : index in the SOURCE[] array.
  108. # Param #2 : full path to where SOURCE[$1] tarball should be created.
  109. # Determine the tarball extension:
  110. PEXT=$(echo "${2}" | sed -r -e 's/.*[^.].(tar.xz|tar.gz|tar.bz2|tgz).*/\1/')
  111. case "$PEXT" in
  112. "tar.xz") TARCOMP="J" ;;
  113. "tar.gz") TARCOMP="z" ;;
  114. "tgz") TARCOMP="z" ;;
  115. "tar.bz2") TARCOMP="j" ;;
  116. *) echo "Archive can only have extension 'tar.xz', '.tar.gz' '.tar.bz2' or '.tgz'" ; exit 1 ;;
  117. esac
  118. case ${1} in
  119. 0) # mplayer
  120. if [ "$(echo ${VERSION}|cut -c1)" == 'r' ]; then # revision instead of date
  121. REV=$(echo ${VERSION} | cut -c2-)
  122. else
  123. REV="{${VERSION}}"
  124. fi
  125. mkdir MPlayer-${VERSION} \
  126. && cd MPlayer-${VERSION} \
  127. && svn checkout --revision $REV svn://svn.mplayerhq.hu/mplayer/trunk . \
  128. && find . -type d -name '.svn' -depth | xargs rm -rf \
  129. && ([ "$USE_PATENTS" != "YES" ] && rm -rf libdvdcss || true) \
  130. && chown -R root:root . \
  131. && cd .. \
  132. && tar -${TARCOMP}cf ${2} MPlayer-${VERSION}
  133. rm -rf MPlayer-${VERSION}
  134. ;;
  135. *) # Do nothing
  136. ;;
  137. esac
  138. }
  139.  
  140. # Place to build (TMP) package (PKG) and output (OUTPUT) the program:
  141. TMP=${TMP:-/tmp/txz}
  142. PKG=$TMP/package-$PRGNAM
  143. OUTPUT=${OUTPUT:-/tmp}
  144.  
  145. ##
  146. ## --- with a little luck, you won't have to edit below this point --- ##
  147. ##
  148.  
  149. # Exit the script on errors:
  150. set -e
  151. trap 'echo "$0 FAILED at line $LINENO!" | tee $OUTPUT/error-${PRGNAM}.log' ERR
  152. # Catch unitialized variables:
  153. set -u
  154. P1=${1:-1}
  155.  
  156. # Create working directories:
  157. mkdir -p $TMP/tmp-$PRGNAM # location to build the source
  158. rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build
  159. mkdir -p $PKG # place for the package to be built
  160. rm -rf $PKG/* # erase old package's contents
  161. mkdir -p $OUTPUT # place for the package to be saved
  162.  
  163. # Source file availability:
  164. for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
  165. if ! [ -f ${SOURCE[$i]} ]; then
  166. echo "Source '$(basename ${SOURCE[$i]})' not available yet..."
  167. # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
  168. [ -w "$SRCDIR" ] || SOURCE[$i]="$OUTPUT/$(basename ${SOURCE[$i]})"
  169. if ! [ "x${SRCURL[$i]}" == "x" ]; then
  170. echo "Will download file to $(dirname $SOURCE[$i])"
  171. wget -nv -T 20 -O "${SOURCE[$i]}" "${SRCURL[$i]}" || true
  172. if [ $? -ne 0 -o ! -s "${SOURCE[$i]}" ]; then
  173. echo "Downloading '$(basename ${SOURCE[$i]})' failed.. aborting the build."
  174. mv -f "${SOURCE[$i]}" "${SOURCE[$i]}".FAIL
  175. exit 1
  176. fi
  177. else
  178. # Try if we have a SVN/CVS download routine for ${SOURCE[$i]}
  179. echo "Will checkout sources to $(dirname $SOURCE[$i])"
  180. src_checkout $i "${SOURCE[$i]}" 2>&1 > $OUTPUT/checkout-$(basename ${SOURCE[$i]}).log
  181. fi
  182. if [ ! -f "${SOURCE[$i]}" -o ! -s "${SOURCE[$i]}" ]; then
  183. echo "File '$(basename ${SOURCE[$i]})' not available.. aborting the build."
  184. exit 1
  185. fi
  186. fi
  187. done
  188.  
  189. if [ "$P1" == "--download" ]; then
  190. echo "Download complete."
  191. exit 0
  192. fi
  193.  
  194. # --- PACKAGE BUILDING ---
  195.  
  196. echo "++"
  197. echo "|| $PRGNAM-$VERSION"
  198. echo "++"
  199.  
  200. # Warn about libdvdread requirement:
  201. if [ "$USE_PATENTS" != "YES" ]; then
  202. cat <<"EOT"
  203. **
  204. ** Removing internal DeCSS library.
  205. ** If you want to play encrypted DVD's you need to install libdvdcss separately.
  206. ** You take full legal responsibility for any use of DeCSS. We neither supply
  207. ** DeCSS code nor endorse any illegal use of it.
  208. **
  209. ** If you are unaffected by patent concerns because you hold the required
  210. ** licenses and permission to use the patented code, or reside in a
  211. ** location where this is not a concern, and wish to include the patented
  212. ** and restricted code (you take all legal responsibility for doing so),
  213. ** then edit this SlackBuild script and change the line:
  214. ** USE_PATENTS=${USE_PATENTS:-"NO"}
  215. ** to:
  216. ** USE_PATENTS="YES"
  217. **
  218. EOT
  219. sleep 5
  220. fi
  221.  
  222. cd $TMP/tmp-$PRGNAM
  223. echo "Extracting the source archive(s) for $PRGNAM..."
  224. tar -xvf ${SOURCE[0]}
  225. [ "$USE_PATENTS" != "YES" ] && rm -rf libdvdcss
  226. chown -R root:root *
  227. chmod -R u+w,go+r-w,a-s *
  228. cd ${SRCNAM}-${VERSION}
  229.  
  230. # Determine what X we're running (the modular X returns the prefix
  231. # in the next command, while older versions stay silent):
  232. XPREF=$(pkg-config --variable=prefix x11) || true
  233. [ "$XPREF" == "" ] && XPREF='/usr/X11R6'
  234.  
  235. # Remove support for patent encumbered and possibly illegal code:
  236. if [ "$USE_PATENTS" != "YES" ]; then
  237. DO_PATENTED="--disable-libdvdcss-internal \
  238. --disable-mp3lame --disable-mp3lame-lavc \
  239. --disable-faac --disable-faac-lavc \
  240. --disable-libamr_nb --disable-libamr_wb"
  241. else
  242. DO_PATENTED=""
  243. fi
  244.  
  245. echo Building ...
  246. # MPlayer wants to automatically determine compiler flags,
  247. # so we don't provide CFLAGS:
  248. LDFLAGS="-L/usr/lib" \
  249. ./configure --prefix=/usr \
  250. --mandir=/usr/man \
  251. --libdir=/usr/lib \
  252. --confdir=/etc/mplayer \
  253. --enable-vdpau \
  254. --enable-menu \
  255. --enable-largefiles \
  256. --target=i686-linux \
  257. --as="as --32" \
  258. --cc="gcc -m32" \
  259. --disable-arts \
  260. --codecsdir=${CODECSDIR} \
  261. --win32codecsdir=${CODECSDIR} \
  262. --realcodecsdir=${CODECSDIR} \
  263. --language="${LANGUAGES}" \
  264. ${EXTRACONFIGUREOPTIONS} \
  265. ${DO_PATENTED} \
  266. 2>&1 | tee $OUTPUT/configure-${PRGNAM}.log
  267. # So that MPlayer does not report "UNKNOWN" as it's version:
  268. echo $VERSION > VERSION
  269. make -j2 2>&1 | tee $OUTPUT/make-${PRGNAM}.log
  270. make DESTDIR=$PKG install 2>&1 |tee $OUTPUT/install-${PRGNAM}.log
  271.  
  272. # Build the html documentation (not all languages are available):
  273. ( cd DOCS/xml
  274. for i in $(echo $LANGUAGES | tr , ' ') ; do
  275. [ -d $i ] && make html-single-$i ;
  276. done
  277. )
  278.  
  279. # Prepare the configfile:
  280. mkdir -p $PKG/etc/mplayer
  281. cp etc/example.conf $PKG/etc/mplayer/mplayer.conf.new
  282.  
  283. # Add this to the doinst.sh:
  284. ! [ -d $PKG/install ] && mkdir -p $PKG/install
  285.  
  286. # Add documentation:
  287. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  288.  
  289. # Save a transcript of all configured options for this specific build:
  290. if [ -n $OUTPUT/configure-${PRGNAM}.log ]; then
  291. cat $OUTPUT/configure-${PRGNAM}.log \
  292. | sed -n "/^Config files successfully generated/,/^'config.h' and 'config.mak' contain your configuration options./p" \
  293. > $PKG/usr/doc/$PRGNAM-$VERSION/${PRGNAM}.configuration
  294. fi
  295. find $PKG/usr/doc -type f -exec chmod 644 {} \;
  296.  
  297. # Compress the man page(s):
  298. if [ -d $PKG/usr/man ]; then
  299. find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
  300. for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  301. fi
  302.  
  303. # Strip binaries:
  304. ( find $PKG | xargs file | grep -e "executable" -e "shared object" \
  305. | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null )
  306.  
  307. # clean everything not needed
  308. rm -fR $PKG/etc $PKG/usr/doc $PKG/usr/share $PKG/usr/man $PKG/usr/bin/mencoder
  309.  
  310. # rename binary
  311. mv $PKG/usr/bin/mplayer $PKG/usr/bin/mplayer32
  312.  
  313. # Add a package description:
  314. mkdir -p $PKG/install
  315. cat $SRCDIR/slack-desc > $PKG/install/slack-desc
  316. if [ -f $SRCDIR/doinst.sh ]; then
  317. cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh
  318. fi
  319.  
  320. # Build the package:
  321. cd $PKG
  322. makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log
  323.  
  324. # Warn about libdvdcss requirement (again):
  325. if [ "$USE_PATENTS" != "YES" ]; then
  326. cat <<"EOT"
  327. **
  328. ** Internal DECSS library was not built.
  329. ** If you want to play encrypted DVD's you need to install libdvdcss separately.
  330. ** You take full legal responsibility for any use of DeCSS. We neither supply
  331. ** DeCSS code nor endorse any illegal use of it.
  332. **
  333. ** If you are unaffected by patent concerns because you hold the required
  334. ** licenses and permission to use the patented code, or reside in a
  335. ** location where this is not a concern, and wish to include the patented
  336. ** and restricted code (you take all legal responsibility for doing so),
  337. ** then edit this SlackBuild script and change the line:
  338. ** USE_PATENTS=${USE_PATENTS:-"NO"}
  339. ** to:
  340. ** USE_PATENTS="YES"
  341. **
  342. EOT
  343.  
  344. fi
  345.  
  346.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement