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 Tue 25 Jun 2019, 03:38
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Stripping Down a Puppy
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 3 [45 Posts]   Goto page: 1, 2, 3 Next
Author Message
s243a

Joined: 02 Sep 2014
Posts: 1909

PostPosted: Thu 21 Mar 2019, 15:06    Post subject:  Stripping Down a Puppy  

This is a continuation of another thread. Anyway to start open up a puppy and find the bases sfs and mount it. Copy the files inside a folder called rootfs. The basic code is as follows:

Code:

mkdir -p $curdir/$rootfs/proc;
mkdir -p $curdir/$rootfs/sys
mkdir -p $curdir/$rootfs/dev

 
mount -o rbind /proc $curdir/$rootfs/proc
mount -t sysfs none $curdir/$rootfs/sys
mount -o rbind /dev $curdir/$rootfs/dev
cp -f /etc/resolv.conf $curdir/$rootfs/etc/resolv.conf

chroot $curdir/$rootfs /bin/bash

https://pastebin.com/zrdGa2fV
(I removed some intializations and if blocks from the above code but not in the above link). Use whatever you want for the system shell in the last line such as bash or ash)

Once mounted you can open the puppy package manager with the command:
Code:

xwin & Open a second terminal to uninstall stuff
dotpup

and then select the install tab.

From there you can see what packages are installed, you can even download the packages with all the dependencies. You might want to do the latter if you want to port puppy aps to another distro (or even another version of puppy).

Now if you try uninstalling a package from the command line
Code:

petget -leafpad

you get the following error
Quote:

No file named leafpad.files found in /root.packages/folder

/usr/local/petget/removepreview.sh
refusing cowardly to remove the package

Possible suggestions: No pkgs beginning with I found
Possible solutions: Edit /root/.packages/user-installed-packages to match the package and start again

There is a file called "~/.packages/buitin_files/leafpad". I wonder if we could just move this file up one level and add a .files to the end of the file name and try again.

There is also a tool with puppy to remove built-in packages but I don't know if it works properly or not in a chroot enviornment.

Another issue is when I get above said error that it opens up geany. Perhaps in a minimal system I want to uninstall geany, in which case I want to open nano instead. Maybe the fix is to edit the default text editor file or alternatively maybe I can make a script called geany and have it open nano instead in a new terminal.

Anyway, once you are done you can make an ISO if you want. Here is a script that is approxamitly what we want to make said iso:

make_ISO_Fm_slitaz-rootfs - TazPup64 Build Kit

I'll need to check through it though to make sure that it is looking in all the right places. For instances I need to replace "slitaz-rootfs" with "$root_fs" and I need to set prefix to an empty string. The script in the last link was mast on mistfires built-kit for tazpup.

Similarly I might want to change the default file manager to midnight commander.

Edit: wiak wanted me to add the following to this post:

wiak wrote:
nic007 wrote:
What would really be cool for me is a method whereby one can open all the applications one use on a regular basis and any others one wants to keep in the base sfs/ones specific network and printing connections, take a snapshot of the things running (including the firmware/modules/libs/configurations, etc. currently in use) and then rebuild the base sfs to include ONLY the things currently running and in use.


This comment inspired me to start a related thread, since a lot could be said about this and can also I feel be regarded as a subtopic of "Stripping Down a Puppy".

I'd be grateful therefore if, s243a, you could put a link to the following as a subtopic in your first post, which could be usefully explored in parallel (but, being in separate thread, not swamp your main thread):

Determining "device drivers" (in kernel, external modules, in conjunction sometimes with firmware for hardware devices) used by your computer and how to remove unneeded ones

http://www.murga-linux.com/puppy/viewtopic.php?t=115717

wiak

Last edited by s243a on Sat 23 Mar 2019, 23:50; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
oui

Joined: 20 May 2005
Posts: 3384
Location: near Woof (Germany) :-) - 3 PC's: DELL SX280 750 MB Pentium4, Acer emachines 2 GB AMD64. DELL XPS15

PostPosted: Thu 21 Mar 2019, 17:26    Post subject:  

Hi s243a

Very interesting observations. But I find the only right way, especially for those having the intention to change heavily the classic mixture of Puppy (no rox, no jwm, no seamonkey, no mplayer but vlc, etc or from very different sources and use (rox in the iso named busterpup!) would be to always process and publish two separate versions, a one-bone classic and her full "rantings" (I hope the word is right, comes from translate.google.com!)... Only that permit don't to have tonnes and tonnes of avoidable dependencies completing later a stripped down Puppy...

which was the last one-bone in Puppy (pls link)?

Kind regards
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1909

PostPosted: Thu 21 Mar 2019, 18:22    Post subject:  

oui wrote:
Hi s243a

Very interesting observations. But I find the only right way, especially for those having the intention to change heavily the classic mixture of Puppy (no rox, no jwm, no seamonkey, no mplayer but vlc, etc or from very different sources and use (rox in the iso named busterpup!) would be to always process and publish two separate versions, a one-bone classic and her full "rantings" (I hope the word is right, comes from translate.google.com!)... Only that permit don't to have tonnes and tonnes of avoidable dependencies completing later a stripped down Puppy...

which was the last one-bone in Puppy (pls link)?

Kind regards


Maybe LazY Unicorn:

LazY Unicorn Version 001

The LazY puppy series (and successors) are a good model for a barebones pup because a lot of stuff has been moved into sfs files. I recall that unicorn was a minimal version of tahrpup but I can't find the thread link. Granted I don't think that Unicorn is as minimal as you are asking.
Back to top
View user's profile Send private message Visit poster's website 
nic007


Joined: 13 Nov 2011
Posts: 2936
Location: Cradle of Humankind

PostPosted: Thu 21 Mar 2019, 21:53    Post subject:  

What would really be cool for me is a method whereby one can open all the applications one use on a regular basis and any others one wants to keep in the base sfs/ones specific network and printing connections, take a snapshot of the things running (including the firmware/modules/libs/configurations, etc. currently in use) and then rebuild the base sfs to include ONLY the things currently running and in use.
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1909

PostPosted: Thu 21 Mar 2019, 22:11    Post subject:  

nic007 wrote:
What would really be cool for me is a method whereby one can open all the applications one use on a regular basis and any others one wants to keep in the base sfs/ones specific network and printing connections, take a snapshot of the things running (including the firmware/modules/libs/configurations, etc. currently in use) and then rebuild the base sfs to include ONLY the things currently running and in use.


That might be doable because the "ps" command often gives the file location of the program running. One could in said system block the removal of all packages that contain files listed by the ps command. A tool could take several snapshots with the ps command and merge them into a list of packages not to remove. Let's call this a block list.

One might also want to use the strace command for the formation of said block list.
Back to top
View user's profile Send private message Visit poster's website 
nic007


Joined: 13 Nov 2011
Posts: 2936
Location: Cradle of Humankind

PostPosted: Thu 21 Mar 2019, 22:20    Post subject:  

It's relatively easy to remove software packages with their associated libs. A method to retain the specific modules, firmware, device drivers etc. in current use and exclude the rest will be cool.
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1909

PostPosted: Thu 21 Mar 2019, 22:32    Post subject:  

nic007 wrote:
It's relatively easy to remove software packages with their associated libs. A method to retain the specific modules, firmware, device drivers etc. in current use and exclude the rest will be cool.


That's more than I want to tackle but google brings up some stuff.

If you know what kernal modules you are using then you can use the modinfo command to see what firmware is being used by the module.
(See https://unix.stackexchange.com/questions/196021/check-the-firmware-which-a-module-needs )

Finding out what modules are required seems also possible but is much more difficult:

Quote:



Actually, there seems to be a way to list processes that claim a module/driver - however, I haven't seen it advertised (outside of Linux kernel documentation), so I'll jot down my notes here:

First of all, many thanks for @haggai_e's answer; the pointer to the functions try_module_get and try_module_put as those responsible for managing the use count (refcount) was the key that allowed me to track down the procedure.

Looking further for this online, I somehow stumbled upon the post Linux-Kernel Archive: [PATCH 1/2] tracing: Reduce overhead of module tracepoints; which finally pointed to a facility present in the kernel, known as (I guess) "tracing"; the documentation for this is in the directory Documentation/trace - Linux kernel source tree. In particular, two files explain the tracing facility, events.txt and ftrace.txt.
....

https://stackoverflow.com/questions/448999/is-there-a-way-to-figure-out-what-is-using-a-linux-kernel-module
Back to top
View user's profile Send private message Visit poster's website 
nic007


Joined: 13 Nov 2011
Posts: 2936
Location: Cradle of Humankind

PostPosted: Thu 21 Mar 2019, 23:22    Post subject:  

I think I'm going to use Pup-SysInfo and work from there. As far as software goes: stripping out an older browser from the base sfs is probably the only worthwhile thing to do as far as functionality and saving space is concerned.
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1909

PostPosted: Fri 22 Mar 2019, 00:04    Post subject:  

nic007 wrote:
I think I'm going to use Pup-SysInfo and work from there. As far as software goes: stripping out an older browser from the base sfs is probably the only worthwhile thing to do as far as functionality and saving space is concerned.


That would be the most relevant thing to strip out size wise and because older browsers become obsolete. That said I still want to look at the general problem. As for applicability, consider the case that someone is running multiple virtual machines at once but at the same time we can look at this as purely as an academic exercise.
Back to top
View user's profile Send private message Visit poster's website 
s243a

Joined: 02 Sep 2014
Posts: 1909

PostPosted: Fri 22 Mar 2019, 00:07    Post subject:  

Here is some skeleton code. which is neither finished nor tested:

Code:

curdir=`pwd`
s_rootfs="root_fs"
prefix=""
action="move"

#Let's remove these applications and maybe put them into an sfs
A=( "leafpad" "solitaire-minesweeper-1.3-i486"
"gtkhash-0.6.0-i686-up" "leafpad" "MPlayer" "clipit" "geany" "get_java"
  "getflash" "get_libreoffice" "gnome-mplayer" "pfind" )
#Let's remove this desktop related stuff and move it into a different sfs
B=( "desk_icon_theme_blue_moon_Slacko" "desk_icon_theme_stardust"
"desk_icon_theme_zabuton" "desktop-file-utils" "gnome-menus" )


for arr_name in A B; do
  eval "arr=( \"\${"$arr_name"[@]}\" ):
  arr_action=$"$arr_name"_action
  #Move is faster but perhaps copy is safer
  arr_action=${arr_action:-cp}
  target=$"$arr_name"_target
  target=${target:-"$curdir/$arr_name"}
  for app in "$arr{[@]}"; do
      case "$arr_action" in
      cp)
          copy_built_in()
      ;;
      mv)
          move_built_in()
      ;;
      pet) #We might also want to convert to other package formats
          mk_pet_fm_built_in()
      ;;
      esac
      chroot "$curdir/s_rootfs" $remove_builtin "$app" #This tool is part of puppy
  done
done


It looks like we can use the remove_builtin function from the command line.

Before we call this function I want to either move, copy or repackage the stuff we are removing in case we want it later (e.g. as a package for a buildsystem or as an sfs that we can load when needed). All built-ins in the above array are found in x-slacko slim. I thought X-Slacko slim was a good test candidate because it supports multile package formats (e.g. void linux and tinycore) as well as supporting pet repos for multiple versions of puppylinux.

The stuff that is architecture specif I'm more likely to want to remove.

Also note that we might need to add some post removal hacks to the loop. For example we might want to create a fake geany once it is removed that calls a terminal based text editor instead. And a fake rox or pcmanfm that calls midnight commander once either of those are removed. This might not be necessary though if all functions call /usr/local/bin/default"$apptype" rather than calling the application directly.
Back to top
View user's profile Send private message Visit poster's website 
nic007


Joined: 13 Nov 2011
Posts: 2936
Location: Cradle of Humankind

PostPosted: Fri 22 Mar 2019, 02:58    Post subject:  

I removed the builtin old Palemoon browser from Tahr605 manually and saved about 30MB on base sfs size (maximum compression). Remove builtin packages does not work for me (applications are not removed from base sfs after a remaster). Actually, I'm going to try and use remove builtin packages again but this time using one of my alternative remaster scripts which works totally different from Puppy's builtin remaster script.
Last edited by nic007 on Fri 22 Mar 2019, 03:15; edited 1 time in total
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1909

PostPosted: Fri 22 Mar 2019, 03:01    Post subject:  

nic007 wrote:
I removed the builtin old Palemoon browser from Tahr605 manually and saved about 30MB on base sfs size (maximum compression). Remove builtin packages does not work for me (applications are not removed from base sfs after a remaster).


That sounds like a bug in the remaster program.
Back to top
View user's profile Send private message Visit poster's website 
wiak

Joined: 11 Dec 2007
Posts: 1430
Location: not Bulgaria

PostPosted: Fri 22 Mar 2019, 04:52    Post subject:  

nic007 wrote:
What would really be cool for me is a method whereby one can open all the applications one use on a regular basis and any others one wants to keep in the base sfs/ones specific network and printing connections, take a snapshot of the things running (including the firmware/modules/libs/configurations, etc. currently in use) and then rebuild the base sfs to include ONLY the things currently running and in use.


This comment inspired me to start a related thread, since a lot could be said about this and can also I feel be regarded as a subtopic of "Stripping Down a Puppy".

I'd be grateful therefore if, s243a, you could put a link to the following as a subtopic in your first post, which could be usefully explored in parallel (but, being in separate thread, not swamp your main thread):

Determining "device drivers" (in kernel, external modules, in conjunction sometimes with firmware for hardware devices) used by your computer and how to remove unneeded ones

http://www.murga-linux.com/puppy/viewtopic.php?t=115717

wiak

_________________
Tiny Linux Blog: http://www.tinylinux.info/
makepup: http://www.murga-linux.com/puppy/viewtopic.php?p=965541
tinycore/slitaz: http://www.murga-linux.com/puppy/viewtopic.php?p=990130#990130
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1909

PostPosted: Sun 24 Mar 2019, 00:21    Post subject:  

I've made some progress:
https://pastebin.com/EbhGMD5N

the remove_builtin (of puppylinux) doesn't work if the list of files isn't given as full paths. This is an issue for leafpad:
Code:

....
/usr/share/icons/hicolor/scalable/apps
 leafpad.svg
/usr/share/pixmaps
 leafpad.png
 leafpad.xpm


since only the directories are given as full paths. My script gets around this but I can't call remove_builtin to remove the files. Worse yet in older versions of puppy this tool doesn't work from the command line.

I think I"ll just incorporate what "remove-builtin does into my script rather than trying to utilize puppies version.

On another note if one wants to use the package manager in a chroot enviornment, one might not necessirly be able to call "dotpup" as I did in a x-slacko slim chroot. As an alternative one can call:
Code:

/usr/local/petget/pkg_chooser.sh

This will populate all the files in /root/.packages based on "0setup <<<copied in by Woof"

Edit: I did a quick hack to get puppylinux remove_builtin to work with leafpad. What I did in my script is to re-write the list of files for leafpad located in:
Code:

/root/.packages/builtin_files/

so that all entries had a full path given. After doing this then the remove_builtin functions works. The modified script is located at:
https://pastebin.com/yw0Z7kWH

I will modify the script so that you can use puppies built-in tool to remove built-in files or by changing a variable, use an external version of this script that will be written by me.

On another note, In the case where I'm using puppylinux built-in tool to remove built-in programs I will pass a list of programs to this function at once. Currently, I'm calling this script once per built-in that I want to remove. This slows things down because each time this function is called the menus are updated. This slows things down.

Also if we remove jwm then we don't want to update these menus.

Last edited by s243a on Sun 24 Mar 2019, 02:55; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website 
nic007


Joined: 13 Nov 2011
Posts: 2936
Location: Cradle of Humankind

PostPosted: Sun 24 Mar 2019, 02:10    Post subject:  

Actually, remove builtin packages did work for me but the few I removed hardly made a dent in the size of the base sfs (that's why I thought it didn't work). So apart from removing the old browser as mentioned before, not really worthwhile removing any other software.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 3 [45 Posts]   Goto page: 1, 2, 3 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.0592s ][ Queries: 12 (0.0095s) ][ GZIP on ]