-
Notifications
You must be signed in to change notification settings - Fork 45
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
Major rewrite of pico_setup.sh #20
base: master
Are you sure you want to change the base?
Conversation
I'm questioning whether I should have submitted this PR. If I could get a clear ruling on whether or not the Raspberry Pi organization wants it, I'd appreciate that. If Raspberry Pi doesn't want it, please close the PR. To be clear: I'm not meaning to be dramatic or sour-grapes about the decision. I'm just looking to keep moving forward. So please let me know. :) Thanks, |
Very nice rewrite, I will test it soon. I'm usually working on OpenSuse, and I think the clear structure and encapsulation of features makes it easy to port the script to this slightly different flavor of Linux. |
Thank you for the kind words and encouragement. 😊 What package manager are you using? |
OpenSuse uses its own manager called zypper (this is rpm based). There is a wrapper for apt on the system, this should not be a problem. But package names are usually slightly different. |
@michaelstoops this looks really good. Thanks for your hard work. The original was just something I whipped up to stop mistakes when people were following the written instructions. From our point of view, if it's the same as our current script on a Raspbian install (so the documentation doesn't change) then I'm happy to accept it. I would just like to confirm that myself before doing so. |
This script works on most Debian-derived Linux distros and macOS, running on common Raspberry Pi, PC, and Mac hardware. This ***DOESN'T*** mean that all of the pico tools work properly on these platforms. It just means that this script runs and passes its own tests. | ||
|
||
Operating systems: | ||
* Raspberry Pi OS (32-bit) |
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.
FYI I did test the "previous" pico_setup.sh on Raspberry Pi OS (64-bit) too, so it would be nice if that still worked (I'll do some testing myself later).
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.
It really should work. I think the only explicit consideration to 32-bit vs 64-bit was part of the old VSCode installation. That's been refactored to rely on APT to get the right build.
I'm leaving this conversation open pending confirmation.
test/README.md
Outdated
| | Raspberry Pi | x86_64 | AArch64 | | ||
|-|-|-|-| | ||
| Raspberry Pi OS (32-bit) | ✅ | Not tested | Not tested | | ||
| Raspberry Pi OS (64-bit) | ✅ | Not tested | Not tested | |
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.
Technically speaking, Raspberry Pi OS (64-bit) is AArch64 😉
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.
Yeah, yeah. I looked for a way to write that in, but didn't find anything that was more helpful than distracting.
pico_setup.sh
Outdated
# Restore working directory | ||
popd >> /dev/null |
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.
Would be nice to do this pushd / popd thing in the other functions too :)
pico_setup.sh
Outdated
@@ -24,13 +24,19 @@ | |||
set -e | |||
# Show all commands | |||
set -x | |||
|
|||
# Trying to use an non-existent variable is an error |
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.
"an" -> "a"
I just tried running this in a Debian docker image, and it got as far as:
I dunno if that's a standard Debian thing, or just a Debian-in-Docker thing? 🤷 I guess at the very least it's probably worth checking if the |
If |
I side-stepped that problem by doing |
I think Docker images tend to contain as little as possible. What image were you using? |
|
Good guy @lurch to the rescue! Thanks. :) |
I think we could support the Debian Docker image, sans sudo, by invoking sudo only if we aren't already root. I would ask whether we want to go to such trouble to support this image, but it would enable Docker as a platform for automated builds, and I like that idea. |
I’m not quite following. Did I miss something?
On Apr 7, 2021, at 4:08 AM, Alasdair Allan ***@***.*** ***@***.***> > wrote:
@aallan commented on this pull request.
--------------------------------
In pico_setup.sh:
+if printenv TARGET_DIR; then
+ echo "Using target dir from \$TARGET_DIR: ${TARGET_DIR}"
Starting with macOS Catalina, Macs will now use zsh as the default login shell and interactive shell across the operating system. All newly created user accounts in macOS Catalina will use zsh by default. That said, mosts existing Mac users will be running bash. I know I am, the script will have to handle both cases.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I’ve managed to remove a few `cd`s with `git -C`, and the remaining `cd`s have been wrapped with pushd/popd, as has the script as a whole, just in case.
On Apr 7, 2021, at 4:04 AM, Andrew Scheller ***@***.*** ***@***.***> > wrote:
@lurch commented on this pull request.
--------------------------------
In pico_setup.sh:
+ # Restore working directory
+ popd >> /dev/null
Would be nice to do this pushd / popd thing in the other functions too :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Status update, FYI: This work is in a testing and test-development phase, which has some long cycles and may take a bit of wall-clock time to complete. I think the core functionality of the setup script is about where it needs to be, so moving on to testing is good progress. I've re-framed the code that used to be called Testing is critical for a piece of software like this: meant to be run by end-users, working on lots of different platforms, with varying assumptions, and dependent on distinct repos that may or may not have what we expect. Not only do I need to make sure my code works this time, but it will need to be tested again after the next bug fix, the one after that, etc. In summary, if I don't automate testing, this work will go to waste. Therefore, I'm investing effort in writing a new test suite, which runs this code through all of the supported circumstances for the host it's running on. For example, the setup script should work on bash and zsh, both on the first installation and later updates, etc. The test suite tests those scenarios. I may or may not automate testing across host types. I am comfortable with spreading these tests out to EC2 instances, but I suspect that most members of this community aren't comfortable with EC2. If there's a more appropriate tool among the potential developers of this code, that might be better. VirtualBox comes to mind, although that isn't particularly convenient for me, running on a MacBook Air M1. None of the virtual host technologies work on M1 as far as I know. This is all a bit more work than I meant to do, but I think it's a good cause and will make a difference to people. Probably a good piece of work for my portfolio too. 🙂 Michael |
Regarding testing, GitHub Actions might be worth considering, because they give us access to Windows, Ubuntu, and macOS hosts, and all for free -- plus, the testing can be fully integrated into the GitHub workflow itself -- when somebody submits a PR, their code will be tested on these platforms automatically. The downside is that the machines are not clean -- they have lots of dev tools preinstalled, but that will still give us some level of validation. The only platform not covered there would be Raspberry Pi hardware itself. Another option that covers that somewhat would be Docker, which can be used to test Windows, Ubuntu, and Raspbian x86-64 (not sure how close that is to the Pi distros though.) Docker leaves out macOS though. Personally I'd be happy with an EC2-based solution -- even though the macOS bit is a pain to manage because of the 24-hour minimum -- it's really up to the Pi folks to figure out what would work for them in the long term in terms of maintaining this code, reviewing PRs, and so on. |
I think what you're doing is fantastic. I was thinking about making some radical changes to the setup process myself, but you actually put in the hard work and produced something usable right now. Which is worth a lot more than just ideas. What were those ideas?
|
Instead of using pushd/popd, you could just run the relevant commands in a subshell (enclose commands in parenthesis But my suggestion is: just merge the pull request. It has been polished more than most of the other stuff for pico. And once that is done, we can have incremental pull-requests for the missing functions/cleanups/etc. |
I spent a couple days away from this code. I'm back but I would like to wrap it up. As discussed, I have moved the validation code into the setup script. The installer hasn't changed much from earlier revisions, but the testing code is new and I suspect I'll get some feedback on it. Let's do one more round of review, then do the final tests on all the platforms, and then merge the change. |
I think we were waiting for @liamfraser to run a clean room test to confirm that it performed the same as his original script. |
Sorry I disappeared off the radar on this after all my earlier feedback - I had other stuff to work on.
and I only get a |
Perhaps we can use this for testing on macOS? At least for a quick smoke test? https://github.com/sickcodes/Docker-OSX/ |
@michaelstoops Did you see @lurch's comment? |
This is a complete overhaul of pico-setup. I'd like to specifically point out my appreciation for the first version, which was very helpful to understand the requirements. Thank you, @liamfraser. I have also incorporated changes are in others' pull requests, but have not yet been merged. Thank you to those authors as well.
Design
The setup actions are grouped into phases. There's a fair bit going on in this script, and I think it's easier to understand with some sensible structure. The phases approximately follow the Getting Started documentation, adjusted for the non-interactive use case.
This code is factored into functions, where the previous version was a straight-through script. This code certainly is longer, but should be very easy to read, understand, and modify.
Testing
This version adds some automation for testing. See
test/
for details.Documentation
This version adds
README.md
andLICENSE.txt
. The license is copied from the pico-examples, including the American spelling of "license". :)Compatibility
This update works with a number of OS and hardware platforms (see
README.md
). It should work on all up-to-date derivatives of Debian, as the key prerequisite is APT. I've tested it on a number of combinations and left notes (seetest/README.md
). I have have not exhaustively tested since the last modification, so it's possible that I broke something. Still, it's fair to say it supports lots of platforms.This should resolve these issues:
Fixes for known issues
.bashrc
This version puts the environment variables in
.z?profile
, correctly handling both bash and zsh, which is particularly relevant as it's the default shell on macOS. #13, #14Additionally, the new code handles the case where the file didn't end in a newline. #12
Idempotence
This version is idempotent with regard to
mkdir
specifically (#10, #11) and generally picks up where it left off when rerun (#6). If interrupted with signal or transient failure, it's fine to rerun.Visual Studio Code
The script installs VS Code when it looks like there's a local XWindows server. #7
But--the features around Visual Studio Code only work on Raspberry Pi OS, not Debian, Ubuntu or macOS. This is mostly because the Raspberry Pi OS repos already have VS Code and it installs nicely.
Paths with spaces
I think this version handles paths with spaces correctly, but it does download all git submodules, and one of openocd's submodules doesn't handle spaces. #17, #18
Features not added
UI
The design of the code should lend itself nicely to adding an interactive interface or otherwise de/selecting features, but I haven't implemented this and removed the
SKIP*
method because I didn't like it. I think if it's important, a better mechanism would be command line switches.Your review is appreciated
Feedback welcome, as always. :)