VLC removal under Linux

Here’s how to safely and completely remove VLC from OpenDisc, if you’re concerned about legal implications. Thanks to HANtwister for writing the guide. :)

You’ll need mkisofs, along with your favourite text editor.

1. Create a directory for a modified OpenDisc, and open it.
mkdir opendisc && cd opendisc

2. Create a directory named old and a directory named new.

mkdir old && mkdir new

3. Place a copy of the ISO into this directory. If you should already happen to have a copy somewhere, copy or move it (really, this just makes it a bit more convenient). If you don’t have a copy somewhere you can download it.

mv (path to ISO) ./

4. Mount the ISO to the old directory. Since it’s a file and not a block device, you’ll need to use the loopback option.

sudo mount -o loop OpenDisc-##.##.iso old

5. Copy the contents of the ISO to a new directory, where we can edit them. Since the ISO is read-only, the copied files will likewise be read-only, so we’ll need to fix that.

cp -r old/* new/ && sudo chmod u+rw -R new && cd new

6. Remove the folders and files related to VLC.

rm -fr programs/vlc disctree/app_img/vlc* disctree/incl/img/vlc.png disctree/en/vlc*

7. Take VLC out of the Disc Menu. The easy (assuming you can paste into your terminal), but admittingly longer way is to let patch take the appropriate section out for you. Create a patch file:

echo -e '*** disctree/en/home.html.old\t2007-11-08 21:19:15.000000000 -0500' > ../menu.patch
echo -e '--- disctree/en/home.html\t2007-11-08 21:20:09.000000000 -0500' >> ../menu.patch
echo -e '***************' >> ../menu.patch
echo -e '*** 384,401 ****' >> ../menu.patch
echo -e '   href="sumatra_install.lch"> <img src="../incl/img/install-s.png" /><span>Install</span></a>/r' >> ../menu.patch
echo -e '        </td>/r' >> ../menu.patch
echo -e '      </tr>/r' >> ../menu.patch
echo -e '-     <tr>/r' >> ../menu.patch
echo -e '-       <td class="logocell"><a class="info" href="vlc.html"><img/r' >> ../menu.patch
echo -e '-  alt="VLC" src="../incl/img/vlc.png" /> <span><img/r' >> ../menu.patch
echo -e '-  src="../incl/img/info-i.png" /></span></a></td>/r' >> ../menu.patch
echo -e '-       <td>/r' >> ../menu.patch
echo -e '-       <h3>VLC</h3>/r' >> ../menu.patch
echo -e '-       <p>Video and audio player</p>/r' >> ../menu.patch
echo -e '-       </td>/r' >> ../menu.patch
echo -e '-       <td class="installcell"> <a class="install"r' >> ../menu.patch
echo -e '-  href="vlc_install.lch"> <img src="../incl/img/install-s.png" /><span>Install</span></a>/r' >> ../menu.patch
echo -e '-       </td>/r' >> ../menu.patch
echo -e '-     </tr>/r' >> ../menu.patch
echo -e '    </tbody>/r' >> ../menu.patch
echo -e '  </table>/r' >> ../menu.patch
echo -e '  <table class="categoryTable" id="productivity">/r' >> ../menu.patch
echo -e '--- 384,389 ----' >> ../menu.patch

Apply the patch.

patch -p0 < ../menu.patch

Or, you can use the text editor of your choice. Remove the entire table row for VLC.

(insert your favorite text editor here) disctree/en/home.html

8. Use mkisofs to create a new, VLC-less ISO. If you wish, pass more arguments/options to mkisofs than the minimum required to create a working ISO as shown below.

mkisofs -o ../OpenDisc-NoVLC.iso -J ./

Finally, here is a shell script that attempts to automate the above (author notes that there might be errors):

#!/bin/bash
# This script will attempt to remove VLC from an OpenDisc ISO.
# Arguments to this script are optional.
# Should you decide to use arguments:
# Argument 1: 'local' or 'remote'
# Argument 2: If 'local', the relative or absolute path for the ISO on your filesystem.
# Argument 2: If 'remote', the name of the file on the OpenDisc SourceForge project.

checkProgramInPath()
{
  # If the argument passed would be executable, return 0.
  # Otherwise, return 1.

  cmd=$1

  # Check to make sure an argument was given.
  if [ "$cmd" != '' ]; then

    # First, we say we want to find everything after a match.
    # The pattern to match is '?', which is a single character.
    # So, we've found everything after the first match, or, in
    # this case, everything after the first character.
    # Then we say find everything that doesn't match.
    # Since the pattern to match is everything except the first
    # character, the only thing that doesn't match is the first
    # character.

    # If the first character is '/', then we have an absolute path.
    if [ "${cmd%${cmd#?}}" = '/' ] ; then

      # Since we have an absolute path, check to see if the path is
      # executable. If so, return 0; if not, return 1.
      if [ -x $cmd ] ; then
        return 0
      else
        return 1
      fi
    else

      # We don't have an absolute path, which means checking each
      # directory in the Path is necessary.
      path="$PATH"
      nexc=1

      # Since we're going to muck around with shell settings, make a
      # backup so they can be restored.
      oldIFS="$IFS"
      IFS=':'

      for directory in $path
      do
        if [[ $nexc -eq 1 && -x $directory/$cmd ]] ; then
          nexc=0
        fi
      done

      # Restore the proper settings and return the result.
      IFS="$oldIFS"
      return $nexc
    fi
  else
    return 1
  fi
}

checkProgramInstalled()
{
  # Check to see if a program is installed, and, if not,
  # try to install it.

  cmd="$1"

  checkProgramInPath "$cmd"
  if [ $? -ne 0 ] ; then
    echo "It appears that the program $cmd is not in your Path."
    echo "Either $cmd is not installed, or it is not in your Path."
    echo 'In some Linux Distributions, you must run this script'
    echo 'while logged in as the Superuser, modify your Path, or'
    echo 'run su - before running this script for programs that'
    echo 'require Superuser rights.'
    echo ''
    echo -n "Would you like me to try and install $cmd? (y/n): "
    read answer
    answer="${answer%${answer#?}}"
    install=0
    if [[ "$answer" = 'y' || "$answer" = 'Y' ]] ; then
      echo "I will now try to install $cmd."
      instlrs="apt-get install:yum install:yast -i:up2date --install"
      oldIFS="$IFS"
      IFS=':'
      for app in $instlrs
      do
        checkProgramInPath "$app"
        if [ $? -eq 0 ] ; then
          $app $cmd
          checkProgramInPath "$cmd"
          if [ $? -eq 0 ] ; then
            install = 1
          fi
        fi
      done
      IFS="$oldIFS"
    fi

    if [ $install -eq 1 ] ; then
      echo "$cmd was successfully installed."
    elif [[ "$answer" = 'y' || "$answer" = 'Y' ]] ; then
      echo "Attempting to install $cmd failed to add it to the Path."
    fi

    if [ $install -ne 1 ] ; then
      echo -n 'Would you like to continue, or abort? (c/a): '
      read answer
      answer="${answer%${answer#?}}"
      if [[ "$answer" != 'c' && "$answer" != 'C' ]] ; then
        exit
      fi
    fi
  fi
}

sys="$1"
loc="$2"

echo 'I will attempt to remove VLC from an OpenDisc ISO.'
echo 'But first, I need to ask some questions.'
echo ''

# Preform the steps we can do before asking about the ISO.

mkdir -p opendisc
mkdir -p opendisc/new
mkdir -p opendisc/old
echo -e '*** disctree/en/home.html.oldt2007-11-08 21:19:15.000000000 -0500' > opendisc/menu.patch
echo -e '--- disctree/en/home.htmlt2007-11-08 21:20:09.000000000 -0500' >> opendisc/menu.patch
echo -e '***************' >> opendisc/menu.patch
echo -e '*** 384,401 ****' >> opendisc/menu.patch
echo -e '   href="sumatra_install.lch"> <img src="../incl/img/install-s.png" /><span>Install</span></a>r' >> opendisc/menu.patch
echo -e '        </td>r' >> opendisc/menu.patch
echo -e '      </tr>r' >> opendisc/menu.patch
echo -e '-     <tr>r' >> opendisc/menu.patch
echo -e '-       <td class="logocell"><a class="info" href="vlc.html"><imgr' >> opendisc/menu.patch
echo -e '-  alt="VLC" src="../incl/img/vlc.png" /> <span><imgr' >> opendisc/menu.patch
echo -e '-  src="../incl/img/info-i.png" /></span></a></td>r' >> opendisc/menu.patch
echo -e '-       <td>r' >> opendisc/menu.patch
echo -e '-       <h3>VLC</h3>r' >> opendisc/menu.patch
echo -e '-       <p>Video and audio player</p>r' >> opendisc/menu.patch
echo -e '-       </td>r' >> opendisc/menu.patch
echo -e '-       <td class="installcell"> <a class="install"r' >> opendisc/menu.patch
echo -e '-  href="vlc_install.lch"> <img src="../incl/img/install-s.png" /><span>Install</span></a>r' >> opendisc/menu.patch
echo -e '-       </td>r' >> opendisc/menu.patch
echo -e '-     </tr>r' >> opendisc/menu.patch
echo -e '    </tbody>r' >> opendisc/menu.patch
echo -e '  </table>r' >> opendisc/menu.patch
echo -e '  <table class="categoryTable" id="productivity">r' >> opendisc/menu.patch
echo -e '--- 384,389 ----' >> opendisc/menu.patch

isoPath=''

while [ "$isoPath" = '' ] ;
do
  case "$sys" in
    'local')
      answer='y' ;;
    'remote')
      answer='n' ;;
    *)
      echo -n 'Have you already downloaded the OpenDisc ISO? (y/n): '
      read answer
      answer="${answer%${answer#?}}" ;;
  esac

  if [[ "$answer" = 'y' || "$answer" = 'Y' ]] ; then
    if [ "$loc" = '' ] ; then
      echo -n 'Where is the OpenDisc ISO? (relative or absolute path): '
      read answer
    else
      answer="$loc"
    fi
    if [ -r $answer ] ; then
      echo 'OK, I can read the OpenDisc ISO.'
      isoPath="$answer"
    else
      if [ -f $answer ] ; then
        echo 'The OpenDisc ISO exists, but I cannot read it.'
      else
        echo 'The OpenDisc ISO does not appear to exist.'
      fi
    fi
  else
    echo 'OK, I will attempt to download it for you.'
    checkProgramInstalled 'wget'
    if [ "$loc" = '' ] ; then
      echo -n 'What file would you like to download from the OpenDisc SourceForge Project?: '
      read answer
    else
      answer="$loc"
    fi
    echo 'I will now try and download the OpenDisc ISO.'
    cd opendisc
    wget "http://downloads.sourceforge.net/opendisc/$answer?use_mirror=osdn"
    if [ $? -eq 0 ] ; then
      echo 'OK, I have successfully downloaded the OpenDisc ISO.'
      isoPath="opendisc/$answer"
    else
      echo 'There was a problem downloading the ISO from the OpenDisc SourceForge Project.'
    fi
    cd ..
  fi

# We don't need to get caught in an endless loop.
# If the supplied arguments worked, we've acted on them.
# If they didn't work, all the more reason to discard them.
sys=''
loc=''

done

echo ''

echo -n 'If you would like to pass additional arguments to mkisofs, enter them now: '
read arg

checkProgramInstalled 'mkisofs'
checkProgramInstalled 'patch'
echo ''

echo 'I will now attempt to remove VLC from the OpenDisc ISO.'
echo 'You may be asked to authenticate yourself to sudo.'

echo 'Mounting the OpenDisc ISO...'
sudo mount -o loop $isoPath opendisc/old
cd opendisc
echo 'Copying the contents of the OpenDisc ISO...'
cp -r old/* new/
sudo chmod u+rw -R new
cd new
echo 'Removing VLC files...'
rm -fr programs/vlc disctree/app_img/vlc* disctree/incl/img/vlc.png disctree/en/vlc*
echo 'Removing VLC from the Disc Menu...'
patch -p0 < ../menu.patch
echo 'Creating a new ISO...'
if [ "$arg" != '' ] ; then
  mkisofs -o ../OpenDisc-NoVLC.iso -Jr $arg ./
else
  mkisofs -o ../OpenDisc-NoVLC.iso -Jr ./
fi
cd ..
echo 'Cleaning up...'
sudo umount old
rm -r old new menu.patch

echo ''
echo 'I have finished removing VLC from the OpenDisc ISO.'

That’s it!
Is there a problem with the instructions? Let us know on the forum thread for this subject.

Colours