#!/bin/sh
PKG_NAME="mplayer2"
PKG_VER="git$(date +%d%m%Y)"
PKG_REV="1"
PKG_DESC="Video player forked from MPlayer, with static libav"
PKG_CAT="Multimedia"
PKG_DEPS="+dejavu-fonts-ttf,+yad"
download() {
if [ ! -f libav-$PKG_VER.tar.xz ]
then
# download the libav sources
git clone --depth 1 git://git.libav.org/libav.git libav-$PKG_VER
[ $? -ne 0 ] && return 1
# create a libav sources tarball
tar -c libav-$PKG_VER | xz -9 > libav-$PKG_VER.tar.xz
[ $? -ne 0 ] && return 1
# clean up
rm -rf libav-$PKG_VER
[ $? -ne 0 ] && return 1
fi
if [ ! -f $PKG_NAME-$PKG_VER.tar.xz ]
then
# download the mplayer2 sources
git clone --depth 1 git://git.mplayer2.org/mplayer2.git $PKG_NAME-$PKG_VER
[ $? -ne 0 ] && return 1
# create a mplayer2 sources tarball
tar -c $PKG_NAME-$PKG_VER | xz -9 > $PKG_NAME-$PKG_VER.tar.xz
[ $? -ne 0 ] && return 1
# clean up
rm -rf $PKG_NAME-$PKG_VER
[ $? -ne 0 ] && return 1
fi
return 0
}
build() {
# extract the libav sources tarball
tar -xJvf libav-$PKG_VER.tar.xz
[ $? -ne 0 ] && return 1
# extract the mplayer2 sources tarball
tar -xJvf $PKG_NAME-$PKG_VER.tar.xz
[ $? -ne 0 ] && return 1
cd libav-$PKG_VER
# configure the libav package
./configure --prefix=/ \
--enable-static \
--disable-shared \
--enable-gpl \
--disable-nonfree \
--disable-ffmpeg \
--disable-avplay \
--disable-avserver \
--disable-network \
--enable-pthreads \
--enable-small \
--disable-runtime-cpudetect \
--disable-hardcoded-tables \
--disable-devices \
--disable-encoders \
--arch=$PKG_ARCH \
--cpu=$PKG_CPU \
--disable-symver \
--disable-debug
[ $? -ne 0 ] && return 1
# build the libav package
make -j $BUILD_THREADS
[ $? -ne 0 ] && return 1
# create a temporary installation directory for the static libav
libav_install_dir="$(mktemp -d -p `pwd`)"
[ $? -ne 0 ] && return 1
# install the static libav package to the temporary directory
make DESTDIR="$libav_install_dir" install
[ $? -ne 0 ] && return 1
cd ../$PKG_NAME-$PKG_VER
# configure the mplayer2 package and make it link against the previously
# installed libav
./configure --prefix=/usr \
--confdir=/etc/$PKG_NAME \
--disable-libass \
--disable-vesa \
--disable-svga \
--disable-sdl \
--disable-caca \
--disable-pnm \
--disable-md5sum \
--disable-fbdev \
--disable-ossaudio \
--disable-arts \
--disable-esd \
--language-msg=en \
--disable-runtime-cpudetection \
--disable-debug \
--disable-crash-debug \
--extra-cflags="-I$libav_install_dir/include" \
--extra-ldflags="-L$libav_install_dir/lib$LIBDIR_SUFFIX"
[ $? -ne 0 ] && return 1
# build the mplayer2 package against the static libav
make -j $BUILD_THREADS
[ $? -ne 0 ] && return 1
# remove the static libav installation directory
rm -rf "$static_libs_dir"
[ $? -ne 0 ] && return 1
return 0
}
package() {
# install the package
make DESTDIR=$INSTALL_DIR install
[ $? -ne 0 ] && return 1
# install the sample configuration
install -D -m644 etc/codecs.conf $INSTALL_DIR/etc/$PKG_NAME/codecs.conf
[ $? -ne 0 ] && return 1
install -D -m644 etc/input.conf $INSTALL_DIR/etc/$PKG_NAME/input.conf
[ $? -ne 0 ] && return 1
install -D -m644 etc/example.conf $INSTALL_DIR/etc/$PKG_NAME/example.conf
[ $? -ne 0 ] && return 1
# install the icon
install -m644 etc/mplayer.xpm $INSTALL_DIR/usr/share/pixmaps/$PKG_NAME.xpm
[ $? -ne 0 ] && return 1
# set DejaVu Sans as the default subtitles font
mkdir -p $INSTALL_DIR/usr/share/mplayer
[ $? -ne 0 ] && return 1
ln -s /$TTF_FONT_PREFIX/DejaVuSans.ttf \
$INSTALL_DIR/usr/share/mplayer/subfont.ttf
[ $? -ne 0 ] && return 1
# add a menu entry
mkdir -p $INSTALL_DIR/usr/share/applications
[ $? -ne 0 ] && return 1
cat << END > $INSTALL_DIR/usr/share/applications/$PKG_NAME.desktop
[Desktop Entry]
Encoding=UTF-8
Name=MPlayer media player
Icon=$PKG_NAME.xpm
Comment=MPlayer media player
Exec=mplayer_shell
Terminal=false
Type=Application
Categories=AudioVideo;Player;
GenericName=MPlayer media player
END
[ $? -ne 0 ] && return 1
chmod 644 $INSTALL_DIR/usr/share/applications/$PKG_NAME.desktop
[ $? -ne 0 ] && return 1
# add a wrapper which uses Yad for a file selection dialog
echo -n '#!/bin/sh
choice="$(yad --file \
--window-icon=/usr/share/pixmaps/$PKG_NAME.xpm \
--title=MPlayer --width 500 --height 300)"
[ $? -eq 1 ] && exit 0
exec mplayer "$choice"' > $INSTALL_DIR/usr/bin/mplayer_shell
[ $? -ne 0 ] && return 1
chmod 755 $INSTALL_DIR/usr/bin/mplayer_shell
[ $? -ne 0 ] && return 1
# install the libav license and the list of contributors
install -D -m644 ../libav-$PKG_VER/LICENSE \
$INSTALL_DIR/$LEGAL_DIR/libav/LICENSE
[ $? -ne 0 ] && return 1
install -D -m644 ../libav-$PKG_VER/CREDITS \
$INSTALL_DIR/$LEGAL_DIR/libav/CREDITS
[ $? -ne 0 ] && return 1
# install the mplayer2 list of authors and the copyright notice
install -D -m644 AUTHORS $INSTALL_DIR/$LEGAL_DIR/$PKG_NAME/AUTHORS
[ $? -ne 0 ] && return 1
install -D -m644 Copyright $INSTALL_DIR/$LEGAL_DIR/$PKG_NAME/Copyright
[ $? -ne 0 ] && return 1
# add the post-install script
echo '#!/bin/sh
echo "Setting MPlayer as the default media player"
echo "#!/bin/sh
exec mplayer_shell \"\$@\"" > ./usr/local/bin/defaultmediaplayer
chmod 755 ./usr/local/bin/defaultmediaplayer' > $INSTALL_DIR/pinstall.sh
[ $? -ne 0 ] && return 1
chmod 755 $INSTALL_DIR/pinstall.sh
[ $? -ne 0 ] && return 1
return 0
}