Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 29 Mar 2017, 03:53
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to find out SFS loaded under which pup_ro dir? (Solved)
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [22 Posts]   Goto page: 1, 2 Next
Author Message
LazY Puppy


Joined: 21 Nov 2014
Posts: 1920
Location: Germany

PostPosted: Fri 20 Jan 2017, 16:00    Post subject:  How to find out SFS loaded under which pup_ro dir? (Solved)  

Hi.

For a small auto-update script I need to know into which one of the pup_ro directories the content of a specific SFS is loaded/mounted.

I'm sure there's an easy solution, so how to achieve this?

Thanks.

_________________
RSH

Wer böses sagt wider mich und die Meinen, der gehe nach Hause und betrachte sich und die Seinen.

Last edited by LazY Puppy on Fri 20 Jan 2017, 23:41; edited 1 time in total
Back to top
View user's profile Send private message 
jlst

Joined: 23 Nov 2012
Posts: 568

PostPosted: Fri 20 Jan 2017, 22:30    Post subject:  

You have to use losetup-FULL (the busybox losetup can't display long paths) and mount.

Let's say we have seamonkey.sfs loaded

Code:
# losetup-FULL -a | sed -e 's|(||' -e 's|)||' | grep "/seamonkey.sfs$"
/dev/loop/5: [2049]:30 /initrd/mnt/dev_save/seamonkey.sfs


seamonkey.sfs is in /dev/loop5 ... in this weird case in /dev/loop/5 (you have to fix that)

Code:
# mount | grep "^/dev/loop5"
/dev/loop5 on /initrd/pup_ro4 type squashfs (ro,noatime)


/dev/loop5 is mounted on /initrd/pup_ro4 ... seamonkey.sfs -> /initrd/pup_ro4

-----

script

Code:
SFS=seamonkey.sfs
DEVLOOP=$(losetup-FULL -a | sed -e 's|(||' -e 's|)||' | grep "/${SFS}$" | cut -f 1 -d ':' | sed 's|/dev/loop/|/dev/loop|')
MOUNTPOINT=$(mount | grep "^${DEVLOOP} " | cut -f 3 -d ' ')


results
Quote:
SFS=seamonkey.sfs
DEVLOOP=/dev/loop5
MOUNTPOINT=/initrd/pup_ro4


seamonkey.sfs mounted on /initrd/pup_ro4

--

In puppy losetup usually points to busybox.

In recent woofce releases it's a script that supports different versions of losetup-FULL and busybox losetup, But defaults to displaying losetup-FULL's output.
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 1920
Location: Germany

PostPosted: Fri 20 Jan 2017, 23:40    Post subject:  

Thank you very much! Very Happy
_________________
RSH

Wer böses sagt wider mich und die Meinen, der gehe nach Hause und betrachte sich und die Seinen.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 9845
Location: Gatineau (Qc), Canada

PostPosted: Sat 21 Jan 2017, 00:07    Post subject:  

Hi, Lazy_Puppy.

I suggest to create a list of the executables in pup_ro*/usr/bin and then
search that list with awk or grep.
Code:
#!/bin/ash
# /root/my-applications/bin/ro-content.sh # Requires tree
# DRAFT for Lazy_Puppy
####
cd /initrd
> /tmp/ro-contents
tree -fi -L 3 pup_ro*/usr/bin >> /tmp/ro-contents

# Search examples with "gnumeric"
# S=gnumeric;awk -F"/" '$NF ~ /'$S'/ { print $1 }' /tmp/ro-contents
# This shows the pup_ro number.

# S=gnumeric;grep -m 1 $S /tmp/ro-contents
# This shows the 1st line applicable.

You'll find the tree executable here.

IHTH

_________________
musher0
~~~~~~~~~~
« Un insensé sur le trône n'est qu'un singe sur le haut d'un toit. » / "A madman
on the throne is just a monkey on top of a roof." (Bernard de Clervaux)
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 1920
Location: Germany

PostPosted: Sat 21 Jan 2017, 00:37    Post subject:  

Thanks musher0.

Though, I'll use the very smart and short script by jlst.

I need to have a solution without additional dependencies (hmm, tree seems to be installed in tahr 602).

Also I'm not in the need to know anything about the executables in the related pup_ro directory. All I need is the names of the .desktop files to update its Categories= content for a use in a plain Puppy. They usually don't have a category: JackAudio (which I invented already in LazY Puppy 2 and it is constantly in use here for all JACK programs).

I already made a script containing jlst's code as a function (psl_getpuprodir) and established this function as a global environment function. So I can call this function from within all of my scripts without to get in contact with that function / script again.

_________________
RSH

Wer böses sagt wider mich und die Meinen, der gehe nach Hause und betrachte sich und die Seinen.
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2587

PostPosted: Sat 21 Jan 2017, 09:53    Post subject:  

You could also parse the output of the mount command.
Back to top
View user's profile Send private message 
jlst

Joined: 23 Nov 2012
Posts: 568

PostPosted: Sat 21 Jan 2017, 10:11    Post subject:  

In puppy the mount command is a script that calls busybox mount if no argument is provided.

Code:
# mount | grep seamonkey
...


Code:
# mount-FULL | grep seamonkey
/initrd/mnt/dev_save/seamonkey.sfs on /initrd/pup_ro4 type squashfs (ro,noatime)


This is what i get running mount and mount-FULL

Quote:
# mount | grep pup_
/dev/loop0 on /initrd/pup_ro2 type squashfs (ro,noatime)
/dev/loop1 on /initrd/pup_z type squashfs (ro,noatime)
/dev/loop2 on /initrd/pup_y type squashfs (ro,noatime)
/dev/loop3 on /initrd/pup_a type squashfs (ro,noatime)
/dev/loop4 on /initrd/pup_ro3 type squashfs (ro,noatime)
/dev/loop5 on /initrd/pup_ro4 type squashfs (ro,noatime)


Quote:
# mount-FULL | grep pup_
/dev/loop0 on /initrd/pup_ro2 type squashfs (ro,noatime)
/dev/loop1 on /initrd/pup_z type squashfs (ro,noatime)
/dev/loop2 on /initrd/pup_y type squashfs (ro,noatime)
/dev/loop3 on /initrd/pup_a type squashfs (ro,noatime)
/initrd/mnt/dev_save/PUPPYBOOT/precise-retro/devx_stretch_7.0.0a1.sfs on /initrd/pup_ro3 type squashfs (ro,noatime)
/initrd/mnt/dev_save/seamonkey.sfs on /initrd/pup_ro4 type squashfs (ro,noatime)


in mount-FULL all sfs's mounted by the init script appear as /dev/loop... in recent releases of woofce puppies: these can only be puppy.sfs, zdrv.sfs, fdrv.sfs, adrv.sfs, ydrv.sfs

The sfs's loaded by sfs_load (woofce version) or any other apps, appear with their full path

=============

This stuff in puppy is really confusing and you have to test in different puppy versions if you want to make it somewhat "universal". Old mount-FULL versions might behave differently.. don't know.. using dpup strech right now.. which is too modern.

So the method i provided works for all SFS files no matter how and when they were loaded.

---

Let's say the code i provided is the plan B

you might want to check mount-FULL output first

Code:
SFS=seamonkey.sfs
MOUNTPOINT=$(mount-FULL | grep "/${SFS} " | cut -f 3 -d ' ')
[ "$MOUNTPOINT" = "" ] && Plan_B


results

Quote:
SFS=seamonkey.sfs
MOUNTPOINT=/initrd/pup_ro4
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 1920
Location: Germany

PostPosted: Sat 21 Jan 2017, 19:41    Post subject:  

Global environment function works pretty well (attached image). Cool

What do you think, jlst?

Should I add the 'mount-FULL' code or should I stay with what I already got working?

Thanks again!
Screenshot-2017-01-22-00-36-15.jpg
 Description   
 Filesize   20.36 KB
 Viewed   188 Time(s)

Screenshot-2017-01-22-00-36-15.jpg


_________________
RSH

Wer böses sagt wider mich und die Meinen, der gehe nach Hause und betrachte sich und die Seinen.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 9845
Location: Gatineau (Qc), Canada

PostPosted: Sun 22 Jan 2017, 00:32    Post subject:  

Hi Lazy_Puppy.

Not that I'm a genius or anything like that, Laughing (ahem, there's a lot of wind
in this room!), but couldn't getting your listing be as simple as
Code:
more /etc/rc.d/BOOTCONFIG
(hehe)

If you want the full list:
Code:
cat /etc/rc.d/BOOTCONFIG | grep LAST | tr " " "\n"

If you want only the ones loaded with sfs_load
Code:
cat /etc/rc.d/BOOTCONFIG | grep EXTRA | tr " " "\n"
(i.e. excluding the ?drive.sfs's and the main puppy sfs)
(Image 1)

Then you can have a script such as
Code:
for i in soffice jajuk wish gnumeric # depending on the titles in BOOTCONFIG
do
   whereis -b -B /initrd/pup_ro?/usr/bin -f $i
done
(Image 2)

Just a thought. IHTH
where-is-what-from-BOOTCONFIG.JPG
 Description   (Image 2)
 Filesize   23.72 KB
 Viewed   170 Time(s)

where-is-what-from-BOOTCONFIG.JPG

myBOOTCONFIG.JPG
 Description   Look what I found! ;-)
 Filesize   49.71 KB
 Viewed   178 Time(s)

myBOOTCONFIG.JPG


_________________
musher0
~~~~~~~~~~
« Un insensé sur le trône n'est qu'un singe sur le haut d'un toit. » / "A madman
on the throne is just a monkey on top of a roof." (Bernard de Clervaux)
Back to top
View user's profile Send private message 
drunkjedi


Joined: 24 May 2015
Posts: 650

PostPosted: Sun 22 Jan 2017, 04:11    Post subject:  

There's no /etc/rc.d/BOOTCONFIG file in Fatdog.

But the mount method shown by jlst works in Fatdog too.
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 1920
Location: Germany

PostPosted: Sun 22 Jan 2017, 11:16    Post subject:  

drunkjedi wrote:
There's no /etc/rc.d/BOOTCONFIG file in Fatdog.

But the mount method shown by jlst works in Fatdog too.

Yes.

FatDog also has its own script to load SFS Modules. It's not compatible to shinobar's sfs_load.

_________________
RSH

Wer böses sagt wider mich und die Meinen, der gehe nach Hause und betrachte sich und die Seinen.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 9845
Location: Gatineau (Qc), Canada

PostPosted: Sun 22 Jan 2017, 14:19    Post subject:  

Hello, drunkjedi and all

FatDog doesn't work on this 64-bit laptop. So BOOTCONFIG is good! Wink
Also: is FatDog a Puppy?...

Don't pay attention to my code, I don't really care.

What I fail to understand, though, is why jlst insists on playing with the
mounting of the sfs to discover which are loaded when you have a simple
ready-made list avaialble. Reading this list is not destructive, whereas
playing around with mount can be if the app is active.

Ok maybe mount-FULL and losetup -a are not destructive. But they are
only generic, to the point of being useless to really answer the question
asked in this thread.

For example, the adrive.sfs is not in "loop2" but in the /initrd/pup_a
directory. A big help it is to know that it is in loop2, especially when you
can confuse it with pup_ro2, which is your pupsave file.

If the sfs is not named according to the app it contains, jlst's script is
of little help, I'm sorry to say. Even so, it will not be precise enough if the
sfs contains many important executables, such as a Libre|OpenOffice sfs.

With all due respect, jlst, I prefer my more informative approach.

BFN

_________________
musher0
~~~~~~~~~~
« Un insensé sur le trône n'est qu'un singe sur le haut d'un toit. » / "A madman
on the throne is just a monkey on top of a roof." (Bernard de Clervaux)

Last edited by musher0 on Sun 22 Jan 2017, 14:52; edited 1 time in total
Back to top
View user's profile Send private message 
jlst

Joined: 23 Nov 2012
Posts: 568

PostPosted: Sun 22 Jan 2017, 14:44    Post subject:  

I just answered the question Lazy Puppy asked.

musher, with all due respect, you apparently have no clue what the question is about.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 9845
Location: Gatineau (Qc), Canada

PostPosted: Sun 22 Jan 2017, 14:54    Post subject:  

jlst wrote:
I just answered the question Lazy Puppy asked.

musher, with all due respect, you apparently have no clue what the question is about.
In my opinion you didn't and please keep your insults to yourself.
_________________
musher0
~~~~~~~~~~
« Un insensé sur le trône n'est qu'un singe sur le haut d'un toit. » / "A madman
on the throne is just a monkey on top of a roof." (Bernard de Clervaux)
Back to top
View user's profile Send private message 
jlst

Joined: 23 Nov 2012
Posts: 568

PostPosted: Sun 22 Jan 2017, 14:57    Post subject:  

musher0 wrote:

In my opinion you didn't and please keep your insults to yourself.

Of course i did. The man himself said that. And i'm not insulting you, i'm just replying with the same level of respect... with all due respect.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [22 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0687s ][ Queries: 12 (0.0024s) ][ GZIP on ]