OpenDisc Forum » Development

Help wanted: VLC cleansing

(11 posts)
  • Started 8 months ago by ChrisGray
  • Latest reply from HANtwister

  1. Since we added VLC to the lineup there's been a few people warning us that in the USA people could get into legal trouble for distributing VLC. However unlikely that is, we don't want to see anybody fined or jailed, so we're after somebody to write a tutorial on how to remove all traces and references of it from the disc, so users can make a "safe" copy for distribution.

    Screenshots most likely won't be necessary, just a quick step-by-step guide to follow that covers everything, beginning the original packaged.ISO and ending with the "safe" packaged .ISO.

    Versions for Windows / Mac / Linux would be ideal, as the latter two are favourites amongst people distributing OpenDisc. :)

    Posted 8 months ago #
  2. HANtwister
    Contributor
    20 posts

    Forgive me, as I'm somewhat of a newbie as far as Linux and Darwin are concerned, and I'm not too familiar with some of the CLI OSS tools out there that can handle ISOs (that I know exist, as I've used one before).

    Below is one way to do it under Windows. Here I've relied upon the Non-OSS IsoBuster, but I'll try and post another version, possibly also for Mac/Linux once I start digging around in Google for that that eludes my memory.

    1. Download a copy of IsoBuster from http://www.isobuster.com/.
    2. Open IsoBuster, and open the OpenDisc ISO.
    3. Select "|>>>| OpenDisc-##.##" (Joilet) on the left.
    4. Select all the files on the right, then drag them into a folder to extract them.
    5. Open the Folder you extracted the files to.
    6. Open the "programs" Folder.
    7. Delete the Folder "vlc".
    8. Go up a Folder, into the Folder you extracted the files to.
    9. Open the "disctree" Folder.
    10. Open the "app_img" Folder.
    11. Delete any files beginning with "vlc".
    12. Go up a Folder, into the "disctree" Folder.
    13. Open the "incl" Folder.
    14. Open the "img" Folder.
    15. Delete the file "vlc.png".
    16. Go up two Folders, into the "disctree" Folder.
    17. Open the "en" Folder.
    18. Delete any files beginning with "vlc".
    19. Open the file home.html with your favorite text editor.
    20. Delete the Table Row related to VLC. As of OpenDisc 07.10, you should delete lines 420-432.
    21. Open InfraRecorder.
    22. Add all the files from the Folder you extracted the files to.
    23. Modify the default project settings if you wish; the default settings are sufficient.
    24. Click the "Actions" Menu, select Burn Compilation, and select to either create a Disc Image or burn a Disc.

    Personally, I don't like the idea of having to remove VLC (I was excited that VLC made it onto the disc), but I suppose if an option to remove VLC from the disc exists, those that are more cautious individuals would be more likely to distribute all the remaining programs on the disc (not to discredit any of the other programs; I remember a saying of something to the effect that we could consider ourselves all drops in an ocean, and that, without any given drop, that ocean would be less of an ocean).

    Posted 7 months ago #
  3. HANtwister
    Contributor
    20 posts

    Apparently 7-Zip can open ISOs. And to believe I've claimed to know what's on this disc while distributing it...

    Replace 1 - 4 of the above with:
    1. Install 7-Zip.
    2. Open 7-Zip.
    3. Open the ISO.
    4. Extract the contents of the ISO to a folder.

    I'm still digging for the CLI ISO Creator for *nix...

    Posted 7 months ago #
  4. HANtwister
    Contributor
    20 posts

    Since Google has refreshed my memory, here's a way for Linux Boxes.

    Beyond the standard CLI tools one would expect (read: hope) to find on an average Linux System, for this method you'll also need mkisofs, along with your choice of either patch or your favorite text editor. Should one not be sure if they do or don't have a needed package (or if they know they don't have a needed package), invoke the package manager to install them if they aren't there, and do nothing should they happen to be there. Depending on what your favorite package manager is (or the favorite package manager of your Distribution, depending on the scenario), it'll probably be one of the following:

    apt-get install (package name here)
    yum install (package name here)
    yast -i (package name here)
    up2date --install (package name here)

    [snipped the instruction, which can now be found in the FAQ]

    I'm sure I've somehow mucked up the shell script, seeing as how the last time I've actually written one was about 6 months ago (and that was something to the equivelent of "Hello World!"), so if you find any problems, let me know (or feel free to fix whatever is[/are] the problem[s] yourself if you feel inclined :) ). There are parts that have more comments than others, simply because the parts that lack comments call upon echo. Also, the reason behind using a shell script was so that it would hopefully work regardless of which Desktop Environment(s), or lack thereof, one had on their Linux Box.

    As for Macs... supposedly, mkisofs would have to be compiled and installed the old fashioned way, and I'm sure there would be an easier route than the above after compiling mkisofs, so I'll leave that up to someone who has the pleasure of owning and hacking... I mean using a Mac.

    Posted 7 months ago #
  5. Apparently 7-Zip can open ISOs. And to believe I've claimed to know what's on this disc while distributing it...
    That makes two of us, I had no idea either. :)

    Thanks for taking the time to write these up, I'll add them to the FAQ soon. Unless you have any objections?

    Posted 7 months ago #
  6. HANtwister
    Contributor
    20 posts

    Not at all. :)

    Posted 7 months ago #
  7. Done :) I've also snipped your Linux post above so this page isn't as long.

    Posted 7 months ago #
  8. HANtwister
    Contributor
    20 posts

    Just a heads up -

    For whatever reason, on the Linux page, the escaped characters in the echo commands are no longer escaped. The first two echo commands should have \t after the file name and before the date instead of t, and the lines representing the contents of the file should end in \r instead of r. Wordpress seems to have done this on both the echo commands in the step-by-step instructions and inside the shell script.

    I'll try and start downloading random Linux Distributions tonight and make sure that the shell script works without a hitch; it seems to work fine under *buntu. The last time I used SuSE, I think mount and umount weren't in the user's path, but only in the Superuser's Path, so I suspect that'll be one change I'll have to make (insure the two are in fact in the path) unless that's changed in a more recent version of SuSE than I've used (but, even then, I'd still probably add the checks for older versions).

    -HN

    Posted 7 months ago #
  9. I just appended them again, but wordpress stripped them right back out again. Once you've confirmed that it works (I wouldn't go grabbing a bunch of distro's, just SuSE like you said) we'll just make them files instead of text.

    Posted 7 months ago #
  10. HANtwister
    Contributor
    20 posts

    Yep - SuSE makes sure that only the Superuser has programs in the Path that would actually require the rights of the Superuser. As an added bonus, SuSE, Fedora, and a few others use a fork of mkisofs, genisoimage, which handles arguments differently, and complicates things a bit; that is, mkisofs only accepts -Jr, while genisoimage only accepts -J -r.

    I've made some adjustments, and I can say that this does work with *buntu, including installing additional packages, it works with Fedora, which happens to already have all the packages it needs, and it'll at least let someone with SuSE or another Distro that behaves in a similar manner as far as the Path is concerned know what they need to do to make it work (run as the Superuser, su -). The only thing the user would have to do would be to download the file, change it's permissions to allow it to be executable (chmod a+x (file)), and answer the questions or follow any further instructions.

    If there are any improvements, adjustments or extra features you think should be added to this, let me know :) .

    The next version of the Shell Script:

    #!/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 the disk.
    # Argument 2: If 'remote', the name of the file on the OpenDisc SourceForge project.
    # Anything after Argument 2 gets passed to mkisofs or genisoimage.
    
    if [ $(whoami) = 'root' ] ; then
      runAsRoot=1
    else
      runAsRoot=0
    fi
    
    checkProgramInPath()
    {
      # If the argument passed would be executable, return 0.
      # Otherwise, return 1.
    
      cmdChk=$1
    
      # Check to make sure an argument was given.
      if [ "$cmdChk" != '' ] ; 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 [ "${cmdChk%${cmdChk#?}}" = '/' ] ; 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 $cmdChk ] ; 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.
          pth="$PATH"
          nexc=1
    
          # Since we're going to muck around with shell settings, make a
          # backup so they can be restored.
          oldIFSpath="$IFS"
          IFS=':'
    
          for directory in $pth
          do
            if [[ $nexc -eq 1 && -x $directory/$cmdChk ]] ; then
              nexc=0
            fi
          done
    
          # Restore the proper settings and return the result.
          IFS="$oldIFSpath"
          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
    
        # Unless it happens that the command not found is mkisofs,
        # and genisoimage is findable, try to install.
        checkProgramInPath 'genisoimage'
        if [[ $? -ne 0 || "$cmd" != 'mkisofs' ]] ; 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, including package managers.'
          echo ''
          install=0
          answer=''
          pkgmgr=0
    
          checkProgramInPath 'sudo'
          if [[ $? -eq 0 || $runAsRoot -eq 1 ]] ; then
            echo -n "Would you like me to try and install $cmd? (y/n): "
            read answer
            answer="${answer%${answer#?}}"
            if [[ "$answer" = 'y' || "$answer" = 'Y' ]] ; then
              echo "I will now try to install $cmd."
              instlrs="apt-get yum yast urpmi emerge up2date smart"
              packages=$*
              oldIFSinst="$IFS"
              IFS=' '
    
              # First, we need to loop by package managers.
              for pkgmgrApp in $instlrs
              do
    
                # We don't need to do anything else if it's been installed.
                if [ $install -ne 1 ] ; then
                  checkProgramInPath "$pkgmgrApp"
                  if [ $? -eq 0 ] ; then
                    pkgmgr=1
                    case "$pkgmgrApp" in
                      'apt-get')
                        pkgmgrAppPrm='install' ;;
                      'yum')
                        pkgmgrAppPrm='install' ;;
                      'yast')
                        pkgmgrAppPrm='-i' ;;
                      'urpmi')
                        pkgmgrAppPrm='' ;;
                      'emerge')
                        pkgmgrAppPrm='' ;;
                      'up2date')
                        pkgmgrAppPrm='--install' ;;
                      'smart')
                        pkgmgrAppPrm='install' ;;
                    esac
    
                    # Since we've found a package manager, we have to try
                    # and install the package by any known name.
                    for package in $packages
                    do
                      if [ $install -ne 1 ] ; then
                        if [ $runAsRoot -eq 1 ] ; then
                          if [ "$pkgmgrAppPrm" != '' ] ; then
                            $pkgmgrApp $pkgmgrAppPrm $package
                          else
                            $pkgmgrApp $package
                          fi
                        else
                          if [ "$pkgmgrAppPrm" != '' ] ; then
                            sudo $pkgmgrApp $pkgmgrAppPrm $package
                          else
                            sudo $pkgmgrApp $package
                          fi
                        fi
                        checkProgramInPath "$cmd"
                        if [ $? -eq 0 ] ; then
                          install=1
                        else
                          if [ "$cmd" = 'mkisofs' ] ; then
                            checkProgramInPath 'genisoimage'
                            if [ $? -eq 0 ] ; then
                              install=1
                            fi
                          fi
                        fi
                      fi
                    done
                  fi
                fi
              done
              IFS="$oldIFSinst"
            fi
          else
            echo "I cannot install $cmd, as I am neither running as root,"
            echo 'nor can I find sudo. Try exiting this script, and, before'
            echo 'relaunching, log in as the Superuser, or run su - .'
          fi
    
          if [ $install -eq 1 ] ; then
            echo "$cmd was successfully installed."
          elif [[ "$answer" = 'y' || "$answer" = 'Y' ]] ; then
            if [ $pkgmgr -eq 1 ] ; then
              echo "Attempting to install $cmd failed to add it to the Path."
              echo "$cmd is either installed but not in your Path, or I don't"
              echo "know what package contains $cmd for your Distribution."
            else
              echo "I could not find a package manager to install $cmd."
              echo 'In some Linux Distributions, package managers will'
              echo 'only be in the Path of the Superuser.'
            fi
            echo 'Try exiting this script, and, before relaunching, log'
            echo 'in as the Superuser, modify your path to include the'
            echo 'necessary programs, or run su - .'
          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
      fi
    }
    
    checkForError()
    {
      errorNum="$1"
      if [ $errorNum -ne 0 ] ; then
        echo 'It seems that the last command I ran encountered a problem.'
        echo "The exit code was $errorNum. You may also reference the output above."
        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
    }
    
    sys="$1"
    loc="$2"
    
    shift
    shift
    
    # If we have more than 2 arguments, the first two go to us.
    # Anything afterwards goes to mkisofs.
    arg=''
    while [ $# -ge 1 ] ;
    do
      if [ "$arg" != '' ] ; then
        arg="$arg $1"
      else
        arg="$1"
      fi
      shift
    done
    
    echo 'I will attempt to remove VLC from an OpenDisc ISO.'
    echo 'But first, I need to ask some questions.'
    echo ''
    
    echo 'Checking for required packages...'
    # If you can't find it on the Path in the base install
    # of either LinuxFromScratch or SuSE, check for it.
    # We only need sudo if the current user isn't root.
    if [ $runAsRoot -ne 1 ] ; then
      checkProgramInstalled 'sudo'
    fi
    checkProgramInstalled 'mount' 'util-linux'
    checkProgramInstalled 'patch'
    checkProgramInstalled 'mkisofs' 'cdrkit-cdrtools-compat' 'genisoimage'
    checkProgramInstalled 'umount' 'util-linux'
    # We'll only check for wget if it turns out that the user
    # hasn't already downloaded the OpenDisc ISO.
    echo ''
    
    # We need to find out if we're dealing with the
    # original mkisofs or the fork, genisoimage.
    origmki=1
    mkifound=0
    
    checkProgramInPath 'mkisofs'
    if [ $? -eq 0 ] ; then
      mkifound=1
    
      mkivrsn=<code>mkisofs -version</code>
      # If mkisofs' version mentions genisoimage, it's part of the fork.
      if [[ "$mkivrsn" =~ .*genisoimage.* ]] ; then
        origmki=0
      fi
    
      # Also, the installed version might be aged. If it's too old, it'll use
      # the old method of accepting arguments.
      # The following versions are considered old:
      # 0, 1, 2.00, 2.01, 2.01.01a0 - 2.01.01a8
      if [[ "$mkivrsn" =~ .*[[:space:]](2\.0*1\.0*1(a0*[0-8])?|((2(\.0*1)?(\.0+)+|[0-1])(\.[[:digit:]]+)*|2(\.0*1)?)(a[[:digit:]]+)?)[[:space:]].* ]] ; then
        origmki=0
      fi
    fi
    
    echo 'Insuring proper umask...'
    # Get and save the current umask.
    let "svumask = 8#<code>umask</code>"
    # We should have full permissions to any file or folder created.
    # 7077 in octal = 3647.
    # The zero in 7077 eliminates any restrictions for the current
    # user for newly created files and folders.
    nwumask=$[ svumask & 3647 ]
    # Convert the (possibly) new umask back to octal and set it.
    umask <code>printf %o $nwumask</code>
    echo ''
    
    echo 'Creating required files...'
    mkdir -p opendisc
    checkForError $?
    mkdir -p opendisc/new
    checkForError $?
    mkdir -p opendisc/old
    checkForError $?
    echo -e '*** disctree/en/home.html.old\t2007-11-08 21:19:15.000000000 -0500' > opendisc/menu.patch
    checkForError $?
    echo -e '--- disctree/en/home.html\t2007-11-08 21:20:09.000000000 -0500' >> opendisc/menu.patch
    checkForError $?
    echo -e '***************' >> opendisc/menu.patch
    checkForError $?
    echo -e '*** 384,401 ****' >> opendisc/menu.patch
    checkForError $?
    echo -e '   href="sumatra_install.lch"> <img src="../incl/img/install-s.png" /><span>Install</span></a>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '        </td>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '      </tr>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-     <tr>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-       <td class="logocell"><a class="info" href="vlc.html"><img\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-  alt="VLC" src="../incl/img/vlc.png" /> <span><img\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-  src="../incl/img/info-i.png" /></span></a></td>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-       <td>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-       <h3>VLC</h3>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-       <p>Video and audio player</p>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-       </td>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-       <td class="installcell"> <a class="install"\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-  href="vlc_install.lch"> <img src="../incl/img/install-s.png" /><span>Install</span></a>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-       </td>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '-     </tr>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '    </tbody>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '  </table>\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '  <table class="categoryTable" id="productivity">\r' >> opendisc/menu.patch
    checkForError $?
    echo -e '--- 384,389 ----' >> opendisc/menu.patch
    checkForError $?
    echo ''
    
    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
        if [ "$answer" != '' ] ; then
          echo 'I will now try and download the OpenDisc ISO.'
          cd opendisc
          wget "http://downloads.sourceforge.net/opendisc/$answer"
          if [[ $? -eq 0 && -r $answer ]] ; 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 ..
        else
          echo 'You must supply a file name.'
        fi
      fi
    
    # We don't need to get caught in an endless loop.
    # If the supplied arguments worked, we've acted upon 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 argAdd
    if [ "$arg" != '' ] ; then
      arg="$arg $argAdd"
    else
      arg="$argAdd"
    fi
    
    echo ''
    
    echo 'I will now attempt to remove VLC from the OpenDisc ISO.'
    if [ $runAsRoot -ne 1 ] ; then
      echo 'You may be asked to authenticate yourself to sudo.'
    fi
    
    echo 'Mounting the OpenDisc ISO...'
    if [ $runAsRoot -eq 1 ] ; then
      mount -o loop $isoPath opendisc/old
      checkForError $?
    else
      sudo mount -o loop $isoPath opendisc/old
      checkForError $?
    fi
    cd opendisc
    checkForError $?
    echo 'Copying the contents of the OpenDisc ISO...'
    cp -r old/* new/
    checkForError $?
    if [ $runAsRoot -eq 1 ] ; then
      chmod u+rw -R new
      checkForError $?
    else
      sudo chmod u+rw -R new
      checkForError $?
    fi
    cd new
    checkForError $?
    echo 'Removing VLC files...'
    rm -fr programs/vlc disctree/app_img/vlc* disctree/incl/img/vlc.png disctree/en/vlc*
    checkForError $?
    echo 'Removing VLC from the Disc Menu...'
    patch -p0 < ../menu.patch
    checkForError $?
    echo 'Creating a new ISO...'
    if [[ $mkifound -eq 1 && $origmki -eq 1 ]] ; then
      if [ "$arg" != '' ] ; then
        mkisofs -Jr $arg -o ../OpenDisc-NoVLC.iso ./
        checkForError $?
      else
        mkisofs -Jr -o ../OpenDisc-NoVLC.iso ./
        checkForError $?
      fi
    else
      isoCtr='mkisofs'
      if [ $mkifound -ne 1 ] ; then
        isoCtr='genisoimage'
      fi
      if [ "$arg" != '' ] ; then
        $isoCtr -J -r $arg -o ../OpenDisc-NoVLC.iso ./
        checkForError $?
      else
        $isoCtr -J -r -o ../OpenDisc-NoVLC.iso ./
        checkForError $?
      fi
    fi
    cd ..
    checkForError $?
    echo 'Cleaning up...'
    if [ $runAsRoot -eq 1 ] ; then
      umount old
      checkForError $?
    else
      sudo umount old
      checkForError $?
    fi
    rm -r old new menu.patch
    checkForError $?
    # Don't forget to restore the saved umask.
    umask <code>printf %o $svumask</code>
    
    echo ''
    echo 'I have finished removing VLC from the OpenDisc ISO.'
    Posted 7 months ago #
  11. HANtwister
    Contributor
    20 posts

    Just a note - there are a few places where BBPress put <code> and </code>. Replace those tags with backticks.

    -HN

    Posted 7 months ago #

RSS feed for this topic

Reply

You must log in to post.