This isn't done yet as the code doesn't currently do anything with
checking whether patches were correctly applied or not. Also the
function is really ugly. I need to start making python modules and
classes out of a few things here to clean this up further.
I'm not real pleased with the outcome here, but all of the functions
related to mounting the HFS image and getting the a2boot files out of it
has been factored out of the bootblock installation function.
I also rewrote the disk7 download code (which has been refactored) be a
lot more robust. It's longer than it maybe needs to be, but it's going
the right direction.
Because the way we deal with the A2SETUP.img varies based on your OS,
there's a lot of platform-specific clutter. Not only that, the boot
block installation function has started to get rather unwieldy. So we
begin thinning it out a little.
This is the start of a major cleanup of the code in install-gsos.py
(which really is turning into install-a2boot.py). First, the code is
developing three levels of output: Silent, normal, and verbose. There
might eventually be also a fourth debug level, but that's not happening
yet.
Second, variable names just haphazardly chosen as I've been working on
this are being sanitized, made consistent, and otherwise improved.
Third (and this has only just begun), the code is being refactored a
bit for what belongs where. That will continue.
This isn't done, but it reflects largely starting over. The goal right
now is to install the boot blocks. To do this we need to:
* Find out if we need to install anything
* Download the disk image archive
* Extract the disk image from the archive
* Mount the image
* Copy the files out of the image
* Unmount the image
* Patch the files if they need patching
* Verify the files are patched correctly
The branching possibilities for installing the disk images are:
1. That the image is currently always a .sea.bin file. In future, it
might not be! After all, the other six disk images are available
multiple places and they're not stored as self-extracting images in
MacBinary format.
2. That there are three different ways I know of to extract the HFS disk
image: Mount it as a loop filesystem (Linux), attach it as a disk
image file (OS X), or extract its contents using hfsutils which
should be able to run just about anywhere. Of course hfsutils has an
additional branch in that hfsutils "sanitizes" the files you copy out
of it for you in ways we don't want, so we need to know the file
names it uses so we can change them back to OS X expectations.
3. How are we installing these files? If we're installing them for
netatalk, we need to rename a file. If just to a UNIX path, that's
something different. If there was some reason to package them in
ProDOS format, again, we need to do something different.
At this time, since I'm developing this on a Mac, I'm assuming .sea.bin
with an 800k image, I'm implementing hdiutil to mount the image, and
I'll implement the UNIX naming first (so as Mac/Linux mount the files.)
Next I'll implement renaming for netatalk and hfsutils. I'll check it
out on the pi and implement the Linux filesystem mounting probably last,
then clean it up to behave more like Python is supposed to if I can
before I start on the GS/OS install itself.
I need a better MacBinary unpacker than unar gives me. The way that
works right now is just clumsy.
I'm not real happy with how I'm doing this. It's obviously not as clean
or as simple as a shell script would be, but that's to be expected since
we have to emulate with those shell commands--whole programs in their
own right--do. But right now, the logic doesn't flow right either for a
structured program or an unstructured shell script. Probably trying to
do too much in one go there.
This script replaces--or rather will eventually replace--the bash script
that installs netboot files in /media/A2SHARED. It generally is going
to be implemented for now as a copy of the shell script, not quite
verbatim. For example, rather than run individual commands with sudo,
it re-runs itself with sudo. And rather than force scriptURL to include
a trailing slash, it explicitly chops the slash off to behave more like
you'd expect directories to.
Also, the body of installing the netboot files will be built as a
function rather than as straight script execution. Basically the idea
there is to begin breaking the components of the netboot script into
their own functions that can be accessed independently in the future.
One step at a time there.
Anyway, very little of the script is done yet. This is just to begin
the process and perhaps elicit some feedback if I'm really doing
something totally wrong here--my python's a little rusty.