Drewsif / PiShrink

Make your pi images smaller!
MIT License
3.44k stars 636 forks source link

Add better detection of existing /etc/rc.local changes #258

Open Drewsif opened 1 year ago

Drewsif commented 1 year ago

Currently PiShrink uses md5sum to detect if we have already changed /etc/rc.local. This is extremely fragile and not the best choice.

The new method should:

  1. Allow for the expansion script to be edited without having to update anything else in the script.
  2. Detect if a PiShrink expansion script is already present in the image and overwrite it with it's own version.
    • In this case the backup made of /etc/rc.local should not be touched

My initial idea for a new method is to put a unique string into the expansion script which we key on.

Sniffleupagus commented 11 months ago

How about "if /etc/rc.local.bak already exists, don't overwrite it". Overwrite rc.local all you want, but keep the original backup to be eventually restored. that's what I did to keep a multistage build (where I use a shrunken image as the input to the next phase, then shrink again) from ending up with an rc.local-loop. It works in my case because I know pishrink is the only thing messing with /etc/rc.local.

When would you have a case where you edit the expansion script and need to retain those changes? Why not just put them in the backup, which gets run at the end of the expansion?