-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup and refactor firmware.sh #549
Cleanup and refactor firmware.sh #549
Conversation
Previously it was possible to manually run the python script using python3 firmware.sh. It can be useful in various cases, like having some firmware archive and want to rename it. Iirc, that's why I chose a polyglot script. Will it still be possible? |
Also you have removed many intended blank lines from the code. It becomes a pain to read what is written on the terminal without blank lines. Lots of blank lines missing in create_deb, create_rpm and create_arch_package. |
Also, the commit history is a pain to review here. Probably commit like Refactor Install packages. Etc. Squash the commits which are addressing minor mistakes made by you. Lastly, do the miscellaneous changes like shell check fixes, refactoring the python bit etc. |
If you want, you can open a new PR with a proper commit history. Probably shall also fix the intended blank lines, since hunting them shall be difficult. |
I am going to make the script accept flags to pick a method so I can just add a flag to run the rename function
All of those were changed in d0c05f8, I can just revert that commit.
I can squash down some of the commits but its not going to be that much better. Github is messing up the diff, its a lot cleaner if you run |
31c7ee8
to
d2bc828
Compare
Last 2 commits are absolutely unnecessary, The only thing that is good is replacing echo with cat and renaming firmware.tar to firmware-raw.tar. And please don't remove logging. It's required for have an idea where the script fails, in case it does. Also, why python_check is there in create_firmware even if it is macOS only check? |
And why has this been removed? |
Also replace == with = in comparisons. IIRC == is bash specific, not POSIX compliant |
This isnt the latest version yet, I havent pushed my changes. I will request a review when im done. |
Its appended to the tar archive so its not placed in the ESP anymore. |
It's still placed in esp, and should be placed on esp Line 720 in d2bc828
|
Mark it as a draft then |
The current pushed branch is in a half-fixed state, its in the ESP on my local branch
Why? Its just like the other firmware files, we just need to rename it on macos |
Because ESP files are renamed on Linux, not macOS |
d2bc828
to
c5df8f5
Compare
Im not sure exactly what to put in the help output, its a bit unclear right now. Im open to renaming the subcommands too. |
I put it in the firmware-raw.tar.gz bundle but copy it on linux from the extracted tarball instead of giving it to the python script. |
I'd rather say add the rename only and get from macOS functionality. It would be better to give options to users rather than doing automatation. I don't think there will be a big gain by just reducing the step of choosing the method by the user. In fact passing these long parameters is a bigger pain. |
Get from macOS should be good if you want to add some sort of systemd service which you planned before. Rename only should be good as script is no longer polyglot |
Try to make things simple. |
Change was absolutely unnecessary, but it's fine if it works. |
There is no UX change if you run the script without any subcommands. If you dont pass anything then it uses the old code which interactively prompts the user.
rename_only is the same as running the old script with
The idea was to add just firmware.tar.gz to the ESP in the future with renamed files in it. |
In the script in general or just the argument parsing code? Argument parsing in bash is a PITA, especially without gnu-isms. Im not sure how much simpler it can be. |
Everything is working now. I think the logs are fixed too. |
docs/tools/firmware.sh
Outdated
then | ||
dmg2img -v BaseSystem.dmg fw.img | ||
else | ||
dmg2img -s BaseSystem.dmg fw.img | ||
fi | ||
rm BaseSystem.dmg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm ${verbose}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw in cleanup_dmg function, workdir gets removed, which also has the dmg, so I wonder what's the actual advantage of specifically removing it here, since the next step before cleanup is simply firmware extraction and reloading drivers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tmpfs is usually in ram, if you are running low on ram the script crashes. The DMG is almost 2GB so this saves a lot of ram space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to overwrite BaseSystem.dmg with fw.img without using extra space, but I dont know how to do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tmpfs is usually in ram, if you are running low on ram the script crashes. The DMG is almost 2GB so this saves a lot of ram space.
But it is not removed unless img is made, so what's the benefit here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I was testing the script it would crash a lot here and complain about low disk space, but once I added the rm
it usually worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im going to move the dmg dir to somewhere on disk.
Don't squash the commit addressing these changes. |
Also, separate out python_check for macOS in a separate function like it was in the older version. There is not need to unnecessarily complicate the create_firmware_archive |
No need to squash the commits btw. |
Once I add those files to the right archive it will work. When the tarfile is extracted those files will be in $PWD, which is $workdir
I dont have a mac where that code is used.
Ok |
You can change the model identifier to your Mac and path to the firmware folder to your chip. That's how I test on my Mac.
|
What are you adding python_check in create_firmware_archive? Just put it in macOS specific code. |
I moved it |
Script looks good to me now, I've tested it on Ubuntu as well as Arch. I wonder if there could be a way to use /tmp if storage in RAM is sufficient. I would prefer not to write much on the SSD for such tasks. |
I think its better to use the disk since a lot of macs only have 8Gb of RAM and if you have swap enabled its going to write to disk anyways.
It shouldn't be a problem, a lot of things write more than this to disk. SSD wear only matters if you write large amounts of data regularly, a user will probably only run this script once. |
There are minor visual changes and some of the "warnings" about installing packages got removed but most of the logic is exactly the same.
9c427e2
has a gnarly diff but the code changes are actually really small.