Guest User

ponce

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