Script Extracting Desktop Module Offline/Online from ISO File
- Ed_P
- Contributor
- Posts: 8373
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Script Extracting Desktop Module Offline/Online from ISO File
A script that would support extracting 003 files from downloaded iso files would be helpful.
Ed
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Extramod
^
- <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
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8373
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Extramod
hmmmm Now if you preceeded the function with something like this:Bogomips wrote:<Desktop Extracting Script>.sh
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>]";
Ed
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Script Extracting Desktop Module Offline/Online from ISO
My emphasis.Ed_P wrote:A script that would support extracting 003 files from downloaded iso files would be helpful.
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.
Last edited by Bogomips on 20 Feb 2017, 13:55, edited 2 times in total.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8373
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: Script Extracting Desktop Module Offline/Online from ISO
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.
So close.
Ed
- brokenman
- Site Admin
- Posts: 6105
- Joined: 27 Dec 2010, 03:50
- Distribution: Porteus v4 all desktops
- Location: Brazil
Re: Script Extracting Desktop Module Offline/Online from ISO
What about mounting the file over the internet?
Proof of concept
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
How do i become super user?
Wear your underpants on the outside and put on a cape.
Wear your underpants on the outside and put on a cape.
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: Script Extracting Desktop Module Offline/Online from ISO
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
Idea has already been mooted:brokenman wrote:What about mounting the file over the internet?
francois wrote:What about mloop iso?
- 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
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8373
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: Script Extracting Desktop Module Offline/Online from ISO
That's an option!!!brokenman wrote:What about mounting the file over the internet?
Where's your x3get script?Bogomips wrote:Tried Ed's approach, which took some 5 mins, almost all of this, spent on downloading the iso:
Ed
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: Script Extracting Desktop Module Offline/Online from ISO
Renamed function x3wget:Ed_P wrote:Where's your x3get script?
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 $*
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
Last edited by Bogomips on 05 Mar 2017, 01:45, edited 5 times in total.
Reason: Varible length fastest mirror times. Architecture override.
Reason: Varible length fastest mirror times. Architecture override.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8373
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Re: Script Extracting Desktop Module Offline/Online from ISO
And it appears it takes less disk space also since you were able to download all the DEs. Very cool Bogomips.Bogomips wrote:httpfs2 does seem to be a mite faster than the wget approach:
Ed
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: Script Extracting Desktop Module Offline/Online from ISO
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
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
- Ed_P
- Contributor
- Posts: 8373
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Script Extracting Desktop Module Offline/Online from ISO
It works with Cinnamon 64-bit.
Adding a note that the thing is going to run awhile and to be patient would be nice but overall NICE JOB Bogomips.
It should be added to 3.2.3.
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:~$
It should be added to 3.2.3.
Ed
-
- Full of knowledge
- Posts: 2564
- Joined: 25 Jun 2014, 15:21
- Distribution: 3.2.2 Cinnamon & KDE5
- Location: London
Re: Script Extracting Desktop Module Offline/Online from ISO
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
SELECT ALL > Ctl+C > Paste into a Terminal
- Root Terminal if getting Online from Mirror.
- Any Terminal if getting Offline from Directory in Filesystem.
- 003 Module from Online Mirror ISO File
Code: Select all
x3get <Desktop> [<Target Directory>]
- 003 Module from Offline ISO File in the Filesystem
Code: Select all
x3 <Desktop> /Path/to/<ISO File> [<Target Directory>]
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB