Advertisement
Guest User

MPlayer VAAPI SlackBuild

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