Page 1 of 2

Script Extracting Desktop Module Offline/Online from ISO File

Posted: 17 Feb 2017, 15:56
by Ed_P
A script that would support extracting 003 files from downloaded iso files would be helpful. :)

Extramod

Posted: 17 Feb 2017, 18:13
by Bogomips
^
  • <Desktop Extracting Script>.sh

    Code: Select all

     #!/bin/bash 
    x3 () 
    { 
        [[ -n $1 ]] || { 
            echo Usage: "<Desktop>  <ISO File>  [<Target Directory>]";
            return
        };
        bsdtar xf $2 --strip-components 2 -C ${3:-.} porteus/base/003-${1}.xzm;
        /bin/ls $LS_OPTIONS -lh ${3:-.}/003-${1}.xzm
    }
    x3 $*
     

    Code: Select all

    guest@porteus:~$ x3  xfce4  p10/tmp/iso/rc3/i586/Porteus-XFCE-v3.2rc3-i586.iso
    -rw-r--r-- 1 guest users 46M Jun  5  2016 ./003-xfce4.xzm
    
    guest@porteus:~$ x3  xfce4  p10/tmp/iso/rc3/i586/Porteus-XFCE-v3.2rc3-i586.iso   /tmp
    -rw-r--r-- 1 guest users 46M Jun  5  2016 /tmp/003-xfce4.xzm
    
B)

Extramod

Posted: 18 Feb 2017, 00:57
by Ed_P
Bogomips wrote:<Desktop Extracting Script>.sh
hmmmm Now if you preceeded the function with something like this:

Code: Select all

#!/bin/bash 
# https://forum.porteus.org/viewtopic.php?f=140&t=6669&p=53124#p53124

ARCH=i586
if [ `echo $MACHTYPE | sed -e 's/-.*$//'` = x86_64 ]; then
   ARCH=x86_64
fi

# Find closest mirror from here: http://porteus.org/porteus-mirrors.txt

MIRROR=http://www6.frugalware.org/mirrors/linux/porteus/$ARCH/Porteus-v3.2.2/

if [ `whoami` != "root" ]; then
   ktsuss "$0 $1"
   exit
fi

if [ -d  "/tmp/*.iso" ]; then
   rm /tmp/*.iso*
fi
wget $MIRROR/Porteus-$1-v3.2.2-$ARCH.iso      -P /tmp

You could shorten the Usage to be:

Code: Select all

echo Usage: "<Desktop>  [<Target Directory>]";
;)

Extramod

Posted: 18 Feb 2017, 03:01
by francois
What about mloop iso? ;)

Re: Extramod

Posted: 18 Feb 2017, 21:16
by Ed_P
francois wrote:What about mloop iso? :wink:
Ok, where's the rest of your code? :twisted:

Script Extracting Desktop Module Offline/Online from ISO

Posted: 18 Feb 2017, 22:49
by Bogomips
Ed_P wrote:A script that would support extracting 003 files from downloaded iso files would be helpful. :)
My emphasis.

Provided such a script, but as it seems more was in mind, have enhanced script to fit in with this:
  • Code: Select all

    #!/bin/bash 
    dayset(){
        # Set up Desktop Conversion Array
        dtp=(cinnamon kde mate xfce);
        day[${dtp[0]}]=${dtp[0]}; day[${dtp[1]}]=${dtp[1]}5
        day[${dtp[2]}]=${dtp[2]}; day[${dtp[3]}]=${dtp[3]}4
    }
    chkid(){
        # Convert to Lower Case
        id=${1,,}; id=${id/kde5/kde}; id=${id/xfce4/xfce};
        [[ ${day[$id]} ]] && return 0;
        echo Desktop must be one of:; printf "%s\n" ${!day[*]};
        return 1;
    }
    x3 () 
    { 
        [[ -n $1 ]] || { 
            echo Usage: "<Desktop>  <ISO File>  [<Target Directory>]";
            return
        };
        unset day;
        declare -A day;
        dayset;
        chkid $1 || return $?;
        bsdtar xf $2 --strip-components 2 -C ${3:-.} porteus/base/003-${day[$id]}.xzm || return $?;
        /bin/ls $LS_OPTIONS -lh ${3:-.}/003-${day[$id]}.xzm
    }
    x3 $*
    
  • Code: Select all

    guest@porteus:~$ x3 cinn p10/tmp/iso/rc3/i586/Porteus-CINNAMON-v3.2rc3-i586.iso /tmp
    Desktop must be one of:
    cinnamon
    mate
    kde
    xfce
    
    guest@porteus:~$ x3 mate p10/tmp/iso/rc3/i586/Porteus-MATE-v3.2rc3-i586.iso  /tmp
    -rw-r--r-- 1 guest users 44M Jun  5  2016 /tmp/003-mate.xzm
    
    guest@porteus:~$ x3 kde  p10/tmp/iso/rc3/i586/Porteus-KDE-v3.2rc3-i586.iso  /tmp
    -rw-r--r-- 1 guest users 230M Jun  5  2016 /tmp/003-kde5.xzm
    
    guest@porteus:~$ x3 cinnamon  p10/tmp/iso/rc3/i586/Porteus-CINNAMON-v3.2rc3-i586.iso /tmp
    -rw-r--r-- 1 guest users 65M Jun  5  2016 /tmp/003-cinnamon.xzm
    
    guest@porteus:~$ x3 xfce  p10/tmp/iso/rc3/i586/Porteus-XFCE-v3.2rc3-i586.iso /tmp
    -rw-r--r-- 1 guest users 46M Jun  5  2016 /tmp/003-xfce4.xzm
    
    guest@porteus:~$ x3 kde5 p10/tmp/iso/rc3/i586/Porteus-KDE-v3.2rc3-i586.iso /tmp-rw-r--r-- 1 guest users 230M Jun  5  2016 /tmp/003-kde5.xzm
    
    guest@porteus:~$ x3 mate p10/tmp/iso/rc3/i586/Porteus-XFCE-v3.2rc3-i586.iso
    bsdtar: porteus/base/003-mate.xzm: Not found in archive
    bsdtar: Error exit delayed from previous errors.
    
;)

Re: Script Extracting Desktop Module Offline/Online from ISO

Posted: 19 Feb 2017, 04:46
by Ed_P
So close bogomips, so close. But stills requires a user to manually download an ISO file to do the DE extract and then delete it.

So close.

:D

Re: Script Extracting Desktop Module Offline/Online from ISO

Posted: 19 Feb 2017, 19:59
by brokenman
What about mounting the file over the internet?

Proof of concept

Code: Select all

iso=http://ftp.vim.org/ftp/os/Linux/distr/porteus/x86_64/Porteus-v3.2.2/modules/003-lxde.xzm
mkdir /mnt/{httpfs2,xzm}
httpfs2 $iso /mnt/httpfs2
mount /mnt/httpfs2/003-lxde.xzm /mnt/xzm
ls /mnt/xzm

Re: Script Extracting Desktop Module Offline/Online from ISO

Posted: 20 Feb 2017, 00:11
by Bogomips
Tried Ed's approach, which took some 5 mins, almost all of this, spent on downloading the iso:

Code: Select all

guest@porteus:~$ x3get cinn /tmp
Desktop must be one of:
cinnamon
mate
kde
xfce

guest@porteus:~$ x3get cinnamon /tmp
2017-02-19 18:35:59 URL:http://ftp.nluug.nl/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso [285741056/285741056] -> "/tmp/Porteus-CINNAMON-v3.2.2-i586.iso" [1]
-rw-r--r-- 1 guest users 78M Dec 24 00:19 ./003-cinnamon.xzm
Downloaded file Porteus-CINNAMON-v3.2.2-i586.iso is also accessible in /tmp

guest@porteus:~$ ls -lh /tmp/Porteus-CINNAMON-v3.2.2-i586.iso 
-rw-r--r-- 1 guest users 273M Dec 24 00:59 /tmp/Porteus-CINNAMON-v3.2.2-i586.iso
brokenman wrote:What about mounting the file over the internet?
Idea has already been mooted:
francois wrote:What about mloop iso? :wink:
  • MLOOP not really suited to a script:

    Code: Select all

    root@porteus:/home/guest# mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso
    using /dev/loop4
    
    Please wait while i gather some info ....
    
    Checking given link ...
    link is good
     Connecting to:   Porteus-CINNAMON-v3.2.2-i586.iso ...
    file name:      Porteus-CINNAMON-v3.2.2-i586.iso
    host name:      ftp.vim.org
    port number:    80
    protocol:       http
    request path:   /ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso
    auth data:      (null)
    file size:      285741056
     Attemptingto mount:   Porteus-CINNAMON-v3.2.2-i586.iso ...
    
     #################################
     Your online file has been mounted at: 
    /mnt/http
    
    You can unmount it by typing: uloop
    
    Here is a list of the files:
    USB_INSTALLATION.txt  boot  porteus
    
    root@porteus:/home/guest# ls -lh /mnt/http/porteus/base/003-cinnamon.xzm 
    -rw-r--r-- 1 root root 78M Dec 24 00:19 /mnt/http/porteus/base/003-cinnamon.xzm
    root@porteus:/home/guest# uloop
    
    /mnt/loop has been unmounted
    
  • Code: Select all

    root@porteus:/home/guest# mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-KDE-v3.2.2-i586.iso
    file size:      439152640
    root@porteus:/home/guest# ls -lh /mnt/http/porteus/base/003-kde5.xzm 
    -rw-r--r-- 1 root root 225M Dec 24 00:19 /mnt/http/porteus/base/003-kde5.xzm
    
    root@porteus:/home/guest# mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-MATE-v3.2.2-i586.iso
    file size:      256028672
    root@porteus:/home/guest# ls -lh /mnt/http/porteus/base/003-mate.xzm 
    -rw-r--r-- 1 root root 50M Dec 24 00:18 /mnt/http/porteus/base/003-mate.xzm
    
    root@porteus:/home/guest# mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-XFCE-v3.2.2-i586.iso
    file size:      251113472
    root@porteus:/home/guest# ls -lh /mnt/http/porteus/base/003-xfce4.xzm 
    -rw-r--r-- 1 root root 45M Dec 24 00:14 /mnt/http/porteus/base/003-xfce4.xzm
    
    guest@porteus:~$ sudo mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso
    /usr/bin/mloop: line 53: losetup: command not found
    file size:      285741056
    guest@porteus:~$ ls -lh /mnt/http/porteus/base/003-cinnamon.xzm 
    -rw-r--r-- 1 root root 78M Dec 24 00:19 /mnt/http/porteus/base/003-cinnamon.xzm
    guest@porteus:~$ sudo uloop
    /mnt/loop has been unmounted
    
So, was going to try and look up latest hhtpfs2 coding example supplied by tome, but now saved the troublle by the example provided. Hope it's not just going to try and download the whole iso, which was the impression being given to me when trying to mloop the Slackware 14.2 iso, which kept on crashing no matter the mirror, because it seemed due to insufficient disk space. :twisted:

Re: Script Extracting Desktop Module Offline/Online from ISO

Posted: 20 Feb 2017, 04:37
by Ed_P
brokenman wrote:What about mounting the file over the internet?
:shock: That's an option!!!
Bogomips wrote:Tried Ed's approach, which took some 5 mins, almost all of this, spent on downloading the iso:
Where's your x3get script?

Re: Script Extracting Desktop Module Offline/Online from ISO

Posted: 20 Feb 2017, 15:33
by Bogomips
Ed_P wrote:Where's your x3get script?
Renamed function x3wget:

Code: Select all

#!/bin/bash 
dayset(){
    dtp=(cinnamon kde mate xfce);
    day[${dtp[0]}]=${dtp[0]}; day[${dtp[1]}]=${dtp[1]}5
    day[${dtp[2]}]=${dtp[2]}; day[${dtp[3]}]=${dtp[3]}4
}
chkid(){
    # Convert to Lower Case
    id=${1,,}; id=${id/kde5/kde}; id=${id/xfce4/xfce};
    [[ ${day[$id]} ]] && return 0;
    echo Desktop must be one of:; printf "%s\n" ${!day[*]};
    return 1;
}
x3(){
[[ $1 ]] || { echo Usage:  "<Desktop>  <ISO File>  [<Target Directory>]"; return; }
unset day; declare -A day;
dayset; chkid $1 || return $?;
bsdtar xf $2 --strip-components 2 -C ${3:-.} porteus/base/003-${day[$id]}.xzm
ls -lh ${3:-.}/003-${day[$id]}.xzm
}
x3wget(){
[[ $1 ]] || { echo Usage:  "<Desktop>  [<Target Directory>]"; return; }
unset day; declare -A day;
dayset; chkid $1 || return $?;
# Mirror Mirror ...
fm=$(yes n | fastest-mirror 2>&1 | grep -A 2 Results: | tail -n1)
a=$(uname -m); a=${a/i6/i5}
iso=Porteus-${id^^}-v3.2.2-${a}.iso
url=${fm:6}$a/Porteus-v3.2.2/$iso
echo This will take some time . . . ; echo
wget -nv -O /tmp/$iso $url
x3  $id  /tmp/$iso  $2
echo Downloaded file $iso is also accessible in /tmp.
}
x3wget $*
httpfs2 does seem to be a mite faster than the wget approach: ( *** !!!SCRIPT IS HERE!!! *** )
  • Code: Select all

    #!/bin/bash 
    dayset(){
        dtp=(cinnamon kde mate xfce);
        day[${dtp[0]}]=${dtp[0]}; day[${dtp[1]}]=${dtp[1]}5
        day[${dtp[2]}]=${dtp[2]}; day[${dtp[3]}]=${dtp[3]}4
    }
    chkid(){
        # Convert to Lower Case
        id=${1,,}; id=${id/kde5/kde}; id=${id/xfce4/xfce};
        [[ ${day[$id]} ]] && return 0;
        echo Desktop must be one of:; printf "%s\n" ${!day[*]};
        return 1;
    }
    x3(){
    [[ $1 ]] || { echo Usage:  "<Desktop>  /Path/to/<ISO File>  [<Target Directory>]"; return; }
    unset day; declare -A day;
    dayset; chkid $1 || return $?;
    bsdtar xf $2 --strip-components 2 -C ${3:-.} porteus/base/003-${day[$id]}.xzm || return $?
    ls -lh ${3:-.}/003-${day[$id]}.xzm
    }
    x3get () 
    { 
        [[ -n $1 ]] || { 
            echo Usage: "<Desktop>  [<Target Directory>]";
            return
        };
        [[ $(whoami) != root ]] && { 
            echo Script requires Superuser Privilege, and has to be run as Root.;
            return
        };
        [[ -n $1 ]] || return;
        unset day;
        declare -A day;
        dayset;
        chkid $1 || return $?;
        fm=$(yes n | fastest-mirror 2>&1 | grep -A 2 Results: | tail -n1);
        fm=${fm%/*};
       # Architecture Override, when Invoked as Function, 
       # by setting arc=i586/x86_64 before invoking x3get.
       a=${arc:-$(uname -m)}; a=${a/i6/i5}
       iso=Porteus-${id^^}-v3.2.2-${a}.iso
       url=http${fm#*http}/$a/Porteus-v3.2.2/$iso;     # Varaiable Length fastest times
        [[ -d u$$ ]] || mkdir u$$ && mountpoint -q u$$ && umount -f u$$;
        echo This will take some time . . . ; echo
        httpfs2 $url u$$ > /dev/null && x3 $id u$$/$iso $2;
        mountpoint -q u$$ && umount u$$;
        rmdir u$$
    }
    x3get $*
    
  • Code: Select all

    guest@porteus:~$ x3get
    Usage: <Desktop>  [<Target Directory>]
    guest@porteus:~$ x3get cinnamon /tmp
    Script requires Superuser Privilege, and has to be run as Root.
    
    root@porteus:/home/guest# x3get
    Usage: <Desktop>  [<Target Directory>]
    
  • Code: Select all

    root@porteus:/home/guest# time x3get cinnamon /tmp
    file name:      Porteus-CINNAMON-v3.2.2-i586.iso
    host name:      ftp.vim.org
    port number:    80
    protocol:       http
    request path:   /porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso
    auth data:      (null)
    file size:      285741056
    -rw-r--r-- 1 root root 78M Dec 24 00:19 /tmp/003-cinnamon.xzm
    
    real    2m37.927s
    user    0m0.239s
    sys     0m1.947s
    
    root@porteus:/home/guest# time x3get mate /tmp
    file name:      Porteus-MATE-v3.2.2-i586.iso
    host name:      ftp.vim.org
    port number:    80
    protocol:       http
    request path:   /porteus/i586/Porteus-v3.2.2/Porteus-MATE-v3.2.2-i586.iso
    auth data:      (null)
    file size:      256028672
    -rw-r--r-- 1 root root 50M Dec 24 00:18 /tmp/003-mate.xzm
    
    real    1m58.505s
    user    0m0.242s
    sys     0m1.307s
    
    root@porteus:/home/guest# time x3get xfce  /tmp
    file name:      Porteus-XFCE-v3.2.2-i586.iso
    host name:      ftp.vim.org
    port number:    80
    protocol:       http
    request path:   /porteus/i586/Porteus-v3.2.2/Porteus-XFCE-v3.2.2-i586.iso
    auth data:      (null)
    file size:      251113472
    -rw-r--r-- 1 root root 45M Dec 24 00:14 /tmp/003-xfce4.xzm
    
    real    1m32.261s
    user    0m0.223s
    sys     0m1.219s
    
    root@porteus:/home/guest# time x3get kde  /tmp
    file name:      Porteus-KDE-v3.2.2-i586.iso
    host name:      ftp.vim.org
    port number:    80
    protocol:       http
    request path:   /porteus/i586/Porteus-v3.2.2/Porteus-KDE-v3.2.2-i586.iso
    auth data:      (null)
    file size:      439152640
    -rw-r--r-- 1 root root 225M Dec 24 00:19 /tmp/003-kde5.xzm
    
    real    11m10.591s
    user    0m0.236s
    sys     0m2.365s
    

Re: Script Extracting Desktop Module Offline/Online from ISO

Posted: 20 Feb 2017, 16:23
by Ed_P
Bogomips wrote:httpfs2 does seem to be a mite faster than the wget approach:
:good: And it appears it takes less disk space also since you were able to download all the DEs. Very cool Bogomips. :beer:

Re: Script Extracting Desktop Module Offline/Online from ISO

Posted: 20 Feb 2017, 22:06
by Bogomips
As I feared, there comes a point of diminishing returns with httpfs2:

Code: Select all

guest@porteus:~$ time x3wget kde5 /tmp
2017-02-20 22:41:24 URL:http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-KDE-v3.2.2-i586.iso [439152640/439152640] -> "/tmp/Porteus-KDE-v3.2.2-i586.iso" [1]
-rw-r--r-- 1 guest users 225M Dec 24 00:19 /tmp/003-kde5.xzm
Downloaded file Porteus-KDE-v3.2.2-i586.iso is also accessible in /tmp.

real    5m50.319s
user    0m2.143s
sys     0m18.500s

guest@porteus:~$ ls -lh /tmp/Porteus-KDE-v3.2.2-i586.iso 
-rw-r--r-- 1 guest users 419M Dec 24 01:13 /tmp/Porteus-KDE-v3.2.2-i586.iso
:(

Script Extracting Desktop Module Offline/Online from ISO

Posted: 21 Feb 2017, 05:58
by Ed_P
:Yahoo!: It works with Cinnamon 64-bit. :Yahoo!:

Code: Select all

guest@porteus:~$ sh ./DEmod.sh mate /tmp
Script requires Superuser Privilege, and has to be run as Root.
guest@porteus:~$ sudo sh ./DEmod.sh mate /tmp
Password: 
Do you think like you type?
Password: 
Have you considered trying to match wits with a rutabaga?
Password: 
file name: 	Porteus-MATE-v3.2.2-x86_64.iso
host name: 	ftp.nluug.nl
port number: 	80
protocol: 	http
request path: 	/os/Linux/distr/porteus/x86_64/Porteus-v3.2.2/Porteus-MATE-v3.2.2-x86_64.iso
auth data: 	(null)
file size: 	255627264
-rw-r--r-- 1 root root 49M Dec 23 23:13 /tmp/003-mate.xzm
guest@porteus:~$ 
Adding a note that the thing is going to run awhile and to be patient would be nice but overall NICE JOB Bogomips. :Bravo:

It should be added to 3.2.3. ;)

Re: Script Extracting Desktop Module Offline/Online from ISO

Posted: 22 Feb 2017, 23:43
by Bogomips
If wishing to employ the script with a minimum of hassle, at the Code Block holding the Script:
SELECT ALL > Ctl+C > Paste into a Terminal
  1. Root Terminal if getting Online from Mirror.
  2. Any Terminal if getting Offline from Directory in Filesystem.
Then there is nothing to stop one from using the shell functions of the script to extract:
  1. 003 Module from Online Mirror ISO File

    Code: Select all

    x3get  <Desktop>  [<Target Directory>] 
  2. 003 Module from Offline ISO File in the Filesystem

    Code: Select all

    x3  <Desktop>  /Path/to/<ISO File>  [<Target Directory>]