Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

mplayer2 Build Script

By: a guest on Nov 26th, 2011  |  syntax: Bash  |  size: 5.95 KB  |  hits: 144  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2.  
  3. PKG_NAME="mplayer2"
  4. PKG_VER="git$(date +%d%m%Y)"
  5. PKG_REV="1"
  6. PKG_DESC="Video player forked from MPlayer, with static libav"
  7. PKG_CAT="Multimedia"
  8. PKG_DEPS="+dejavu-fonts-ttf,+yad"
  9.  
  10. download() {
  11.         if [ ! -f libav-$PKG_VER.tar.xz ]
  12.         then
  13.                 # download the libav sources
  14.                 git clone --depth 1 git://git.libav.org/libav.git libav-$PKG_VER
  15.                 [ $? -ne 0 ] && return 1
  16.  
  17.                 # create a libav sources tarball
  18.                 tar -c libav-$PKG_VER | xz -9 > libav-$PKG_VER.tar.xz
  19.                 [ $? -ne 0 ] && return 1
  20.  
  21.                 # clean up
  22.                 rm -rf libav-$PKG_VER
  23.                 [ $? -ne 0 ] && return 1
  24.         fi
  25.  
  26.         if [ ! -f $PKG_NAME-$PKG_VER.tar.xz ]
  27.         then
  28.                 # download the mplayer2 sources
  29.                 git clone --depth 1 git://git.mplayer2.org/mplayer2.git $PKG_NAME-$PKG_VER
  30.                 [ $? -ne 0 ] && return 1
  31.  
  32.                 # create a mplayer2 sources tarball
  33.                 tar -c $PKG_NAME-$PKG_VER | xz -9 > $PKG_NAME-$PKG_VER.tar.xz
  34.                 [ $? -ne 0 ] && return 1
  35.  
  36.                 # clean up
  37.                 rm -rf $PKG_NAME-$PKG_VER
  38.                 [ $? -ne 0 ] && return 1
  39.         fi
  40.  
  41.         return 0
  42. }
  43.  
  44. build() {
  45.         # extract the libav sources tarball
  46.         tar -xJvf libav-$PKG_VER.tar.xz
  47.         [ $? -ne 0 ] && return 1
  48.  
  49.         # extract the mplayer2 sources tarball
  50.         tar -xJvf $PKG_NAME-$PKG_VER.tar.xz
  51.         [ $? -ne 0 ] && return 1
  52.  
  53.         cd libav-$PKG_VER
  54.  
  55.         # configure the libav package
  56.         ./configure --prefix=/ \
  57.                     --enable-static \
  58.                     --disable-shared \
  59.                     --enable-gpl \
  60.                     --disable-nonfree \
  61.                     --disable-ffmpeg \
  62.                     --disable-avplay \
  63.                     --disable-avserver \
  64.                     --disable-network \
  65.                     --enable-pthreads \
  66.                     --enable-small \
  67.                     --disable-runtime-cpudetect \
  68.                     --disable-hardcoded-tables \
  69.                     --disable-devices \
  70.                     --disable-encoders \
  71.                     --arch=$PKG_ARCH \
  72.                     --cpu=$PKG_CPU \
  73.                     --disable-symver \
  74.                     --disable-debug
  75.         [ $? -ne 0 ] && return 1
  76.  
  77.         # build the libav package
  78.         make -j $BUILD_THREADS
  79.         [ $? -ne 0 ] && return 1
  80.  
  81.         # create a temporary installation directory for the static libav
  82.         libav_install_dir="$(mktemp -d -p `pwd`)"
  83.         [ $? -ne 0 ] && return 1
  84.  
  85.         # install the static libav package to the temporary directory
  86.         make DESTDIR="$libav_install_dir" install
  87.         [ $? -ne 0 ] && return 1
  88.  
  89.         cd ../$PKG_NAME-$PKG_VER
  90.  
  91.         # configure the mplayer2 package and make it link against the previously
  92.         # installed libav
  93.         ./configure --prefix=/usr \
  94.                     --confdir=/etc/$PKG_NAME \
  95.                     --disable-libass \
  96.                     --disable-vesa \
  97.                     --disable-svga \
  98.                     --disable-sdl \
  99.                     --disable-caca \
  100.                     --disable-pnm \
  101.                     --disable-md5sum \
  102.                     --disable-fbdev \
  103.                     --disable-ossaudio \
  104.                     --disable-arts \
  105.                     --disable-esd \
  106.                     --language-msg=en \
  107.                     --disable-runtime-cpudetection \
  108.                     --disable-debug \
  109.                     --disable-crash-debug \
  110.                     --extra-cflags="-I$libav_install_dir/include" \
  111.                     --extra-ldflags="-L$libav_install_dir/lib$LIBDIR_SUFFIX"
  112.         [ $? -ne 0 ] && return 1
  113.  
  114.         # build the mplayer2 package against the static libav
  115.         make -j $BUILD_THREADS
  116.         [ $? -ne 0 ] && return 1
  117.  
  118.         # remove the static libav installation directory
  119.         rm -rf "$static_libs_dir"
  120.         [ $? -ne 0 ] && return 1
  121.  
  122.         return 0
  123. }
  124.  
  125. package() {
  126.         # install the package
  127.         make DESTDIR=$INSTALL_DIR install
  128.         [ $? -ne 0 ] && return 1
  129.  
  130.         # install the sample configuration
  131.         install -D -m644 etc/codecs.conf $INSTALL_DIR/etc/$PKG_NAME/codecs.conf
  132.         [ $? -ne 0 ] && return 1
  133.         install -D -m644 etc/input.conf $INSTALL_DIR/etc/$PKG_NAME/input.conf
  134.         [ $? -ne 0 ] && return 1
  135.         install -D -m644 etc/example.conf $INSTALL_DIR/etc/$PKG_NAME/example.conf
  136.         [ $? -ne 0 ] && return 1
  137.  
  138.         # install the icon
  139.         install -m644 etc/mplayer.xpm $INSTALL_DIR/usr/share/pixmaps/$PKG_NAME.xpm
  140.         [ $? -ne 0 ] && return 1
  141.  
  142.         # set DejaVu Sans as the default subtitles font
  143.         mkdir -p $INSTALL_DIR/usr/share/mplayer
  144.         [ $? -ne 0 ] && return 1
  145.         ln -s /$TTF_FONT_PREFIX/DejaVuSans.ttf \
  146.               $INSTALL_DIR/usr/share/mplayer/subfont.ttf
  147.         [ $? -ne 0 ] && return 1
  148.  
  149.         # add a menu entry
  150.         mkdir -p $INSTALL_DIR/usr/share/applications
  151.         [ $? -ne 0 ] && return 1
  152. cat << END > $INSTALL_DIR/usr/share/applications/$PKG_NAME.desktop
  153. [Desktop Entry]
  154. Encoding=UTF-8
  155. Name=MPlayer media player
  156. Icon=$PKG_NAME.xpm
  157. Comment=MPlayer media player
  158. Exec=mplayer_shell
  159. Terminal=false
  160. Type=Application
  161. Categories=AudioVideo;Player;
  162. GenericName=MPlayer media player
  163. END
  164.         [ $? -ne 0 ] && return 1
  165.         chmod 644 $INSTALL_DIR/usr/share/applications/$PKG_NAME.desktop
  166.         [ $? -ne 0 ] && return 1
  167.  
  168.         # add a wrapper which uses Yad for a file selection dialog
  169.         echo -n '#!/bin/sh
  170. choice="$(yad --file \
  171.              --window-icon=/usr/share/pixmaps/$PKG_NAME.xpm \
  172.              --title=MPlayer --width 500 --height 300)"
  173. [ $? -eq 1 ] && exit 0
  174. exec mplayer "$choice"' > $INSTALL_DIR/usr/bin/mplayer_shell
  175.         [ $? -ne 0 ] && return 1
  176.         chmod 755 $INSTALL_DIR/usr/bin/mplayer_shell
  177.         [ $? -ne 0 ] && return 1
  178.  
  179.         # install the libav license and the list of contributors
  180.         install -D -m644 ../libav-$PKG_VER/LICENSE \
  181.                          $INSTALL_DIR/$LEGAL_DIR/libav/LICENSE
  182.         [ $? -ne 0 ] && return 1
  183.         install -D -m644 ../libav-$PKG_VER/CREDITS \
  184.                          $INSTALL_DIR/$LEGAL_DIR/libav/CREDITS
  185.         [ $? -ne 0 ] && return 1
  186.  
  187.         # install the mplayer2 list of authors and the copyright notice
  188.         install -D -m644 AUTHORS $INSTALL_DIR/$LEGAL_DIR/$PKG_NAME/AUTHORS
  189.         [ $? -ne 0 ] && return 1
  190.         install -D -m644 Copyright $INSTALL_DIR/$LEGAL_DIR/$PKG_NAME/Copyright
  191.         [ $? -ne 0 ] && return 1
  192.  
  193.         # add the post-install script
  194.         echo '#!/bin/sh
  195.  
  196. echo "Setting MPlayer as the default media player"
  197. echo "#!/bin/sh
  198. exec mplayer_shell \"\$@\"" > ./usr/local/bin/defaultmediaplayer
  199. chmod 755 ./usr/local/bin/defaultmediaplayer' > $INSTALL_DIR/pinstall.sh
  200.         [ $? -ne 0 ] && return 1
  201.         chmod 755 $INSTALL_DIR/pinstall.sh
  202.         [ $? -ne 0 ] && return 1
  203.  
  204.         return 0
  205. }
  206.  
  207.