Advertisement
pintcat

do-mediainfo v1.2 - build script for the static command line version of MediaInfo

Dec 24th, 2022 (edited)
1,518
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.78 KB | Software | 1 0
  1. #!/bin/sh
  2.  
  3. # Build script for the static cli version of MediaInfo v1.2
  4.  
  5. INSTALL_PATH=~/ubin
  6. WORK_PATH=/media/ramdisk/mediainfo_tmp
  7. CHANGELOG=http://mediaarea.net/MediaInfo/ChangeLog
  8. DOWNLOAD1=http://sourceforge.net/projects/mediainfo/files/binary/mediainfo/
  9. DOWNLOAD2=http://mediaarea.net/download/binary/mediainfo/
  10. OPT=NONE
  11.  
  12. CLEAN(){
  13.     printf "\nCleaning up... "
  14.     cd ~/
  15.     if rm -drf $WORK_PATH; then
  16.         echo "done."
  17.         exit $1
  18.     else
  19.         echo "not done. Warning: temporary files are still present in $WORK_PATH"
  20.         exit 1
  21.     fi
  22. }
  23.  
  24. BUILD(){
  25.     echo "Unpacking & compiling binary...   "
  26.     tar -xjf latest.tar.bz2
  27.     cd MediaInfo_CLI_GNU_FromSource
  28.     if ./CLI_Compile.sh; then
  29.         cd $INSTALL_PATH
  30.         if [ -f MediaInfo~ ]; then rm -f MediaInfo~; fi
  31.         if [ -f MediaInfo ]; then mv MediaInfo MediaInfo~; fi
  32.         echo "Compressing & installing MediaInfo to $INSTALL_PATH..."
  33.         upx --lzma -9 $WORK_PATH/MediaInfo_CLI_GNU_FromSource/MediaInfo/Project/GNU/CLI/mediainfo -o MediaInfo
  34.         echo "All done - finished MediaInfo $LATEST_VERS update."
  35.         CLEAN 0
  36.     else
  37.         echo "Unable to compile. Try another source or contact developer!"
  38.         CLEAN 1
  39.     fi
  40. }
  41.  
  42. echo
  43. if [ -d "$WORK_PATH" ]; then
  44.     rm -rf $WORK_PATH/*
  45. else
  46.     mkdir $WORK_PATH
  47. fi
  48. cd $WORK_PATH
  49. if [ $# -gt 0 ]; then
  50.     if [ $1 = CHECK ] || [ $1 = check ]; then OPT=CHECK
  51.     elif [ $1 = FORCE ] || [ $1 = force ]; then OPT=FORCE
  52.     else
  53.         printf "Unknown option: '"$1"' Try again! ;)\n\n"
  54.         exit 1
  55.     fi
  56. fi
  57. printf "Checking MediaInfo version...   "
  58. if wget -q $CHANGELOG -O changelog; then
  59.     STRING=$(grep -m 1 'Version ' changelog)
  60.     LATEST_VERS=${STRING#*Version\ }
  61.     LATEST_VERS=${LATEST_VERS%,\ 2*}
  62.     if [ -d $INSTALL_PATH ]; then
  63.         echo "Latest version:            "$LATEST_VERS
  64.         if [ -f $INSTALL_PATH/MediaInfo ]; then
  65.             INSTALLED_VERS=$($INSTALL_PATH/MediaInfo --version | grep MediaInfoLib 2>/dev/null)
  66.             INSTALLED_VERS=${INSTALLED_VERS#*\ v}
  67.             printf "                                Current installed version: $INSTALLED_VERS\n\n"
  68.             if [ $LATEST_VERS = $INSTALLED_VERS ]; then
  69.                 printf "Installed version is already the latest"
  70.         if [ $OPT = CHECK ]; then
  71.             echo " - no update necessary."
  72.             CLEAN 0
  73.         fi
  74.         if [ $OPT = FORCE ]; then
  75.             echo ", but FORCE option was called. Updating anyway."
  76.         else
  77.             read -p " - update anyway (y/N)? " YN
  78.             case $YN in
  79.             [Yy]*)
  80.                 echo "Starting update..."
  81.                 ;;
  82.             *)
  83.                 echo "Nothing changed."
  84.                 CLEAN 0
  85.                 ;;
  86.             esac
  87.         fi
  88.         else
  89.             printf "New version available - "
  90.             if [ $OPT = CHECK ]; then
  91.                 echo "update recommended!"
  92.                 CLEAN 0
  93.             fi
  94.             echo "starting update."
  95.             fi
  96.         else
  97.             echo "No information about installed version found."
  98.             if [ $OPT = CHECK ]; then CLEAN 0; fi
  99.         fi
  100.     else
  101.         printf "$INSTALL_PATH not found - "
  102.         if [ $OPT = CHECK ]; then
  103.             echo "could not get version information"
  104.         else
  105.             echo "no install possible."
  106.         fi
  107.         CLEAN 1
  108.     fi
  109. else
  110.     echo "Could not find release information - no download possible :("
  111.     CLEAN 1
  112. fi
  113.  
  114. #LATEST_VERS=0.7.95    # <-- enable this to enforce a certain version
  115.  
  116. printf "Downloading latest MediaInfo source package...\n\n"
  117. if wget $DOWNLOAD1$LATEST_VERS/"MediaInfo_CLI_"$LATEST_VERS"_GNU_FromSource.tar.bz2" -O latest.tar.bz2; then
  118.     BUILD
  119. else
  120.     printf "No luck with source 1. Trying alternative source...\n\n"
  121.     if wget $DOWNLOAD2$LATEST_VERS/"MediaInfo_CLI_"$LATEST_VERS"_GNU_FromSource.tar.bz2" -O latest.tar.bz2; then
  122.         BUILD
  123.     else
  124.         echo "Unable to download source - try again later!"
  125.         CLEAN 1
  126.     fi
  127. fi
  128.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement