Skip to content
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

Install script improvements #1456

Merged
merged 25 commits into from
Oct 27, 2024

Conversation

EmDash00
Copy link
Contributor

Various improvements to the installation script. Main feature is to allow specification of the version of PhotonVision to install. Various small backend improvements. Made to address Issue #1452 so that older versions of PhotonVision may be installed for older versions of WPILibPi, allowing users more flexibility.

@EmDash00 EmDash00 requested a review from a team as a code owner October 11, 2024 19:40
@crschardt
Copy link
Contributor

Thanks for these updates. What platforms have you tested the new script on?

@mcm001
Copy link
Contributor

mcm001 commented Oct 12, 2024

Yeah high level this looks fantastic! Maybe we should finally commit to migrating this script over to the other repo too

@crschardt
Copy link
Contributor

Yeah high level this looks fantastic! Maybe we should finally commit to migrating this script over to the other repo too

I'm working on a PR for that and the document update.

echo ""
echo "Photonvision uses NetworkManager to control networking on your device."

if [[ "$DISTRO" != "Ubuntu" || -n "$DISABLE_NETWORKING" || -n "$QUIET" ]] ; then
Copy link
Contributor

@crschardt crschardt Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the logic here will override --install-nm=yes if the --quiet flag is also passed. That's not the current behavior and could cause unexpected results.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes you're right. Let me fix that.

@EmDash00
Copy link
Contributor Author

Tried to address some of the issues in the most recent version. I also caught a few typos. I'll probably try to test them tonight. What would you need from me in order to get this merged?

@mcm001
Copy link
Contributor

mcm001 commented Oct 17, 2024

We'd wanna test it on all supported platforms is all. Maybe it makes more sense to move this all into photon image modifier now for testing and generating images?

@crschardt
Copy link
Contributor

We'd wanna test it on all supported platforms is all. Maybe it makes more sense to move this all into photon image modifier now for testing and generating images?

I copied an earlier version of the script over and the images build. I still need to test them on coprocessors. We could merge the PR here once we've tested for manual install. After that, I'll pull it over to photon-image-modifier and PR the changes to remove it from here.

Comment on lines 196 to 216
# Quiet makes the default "no" instead of "ask".
if [[ -n "$QUIET" && "$INSTALL_NETWORK_MANAGER" == "ask" ]] ; then
INSTALL_NETWORK_MANAGER="no"
fi

DISTRO=$(lsb_release -is)
if [[ "$DISTRO" = "Ubuntu" && "$INSTALL_NETWORK_MANAGER" != "true" && -z "$QUIET" && -z "$DISABLE_NETWORKING" ]]; then
echo ""
echo "Photonvision uses NetworkManager to control networking on your device."

# NetworkManager cannot be installed on non-Ubuntu distros
# --no-networking takes precedence over --install-nm
if [[ "$DISTRO" != "Ubuntu" || -n "$DISABLE_NETWORKING" ]] ; then
INSTALL_NETWORK_MANAGER="no"
fi

if [[ "$INSTALL_NETWORK_MANAGER" == "ask" ]]; then
debug ""
debug "Photonvision uses NetworkManager to control networking on your device."
read -p "Do you want this script to install and configure NetworkManager? [y/N]: " response
if [[ $response == [yY] || $response == [yY][eE][sS] ]]; then
INSTALL_NETWORK_MANAGER="true"
INSTALL_NETWORK_MANAGER="yes"
fi
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't think this matches the original logic. The test for Ubuntu was intended to ask for permission if someone was installing it on Ubuntu to make sure that it wasn't messing up their network configuration. This logic will override --install-nm=yes if the platform isn't Ubuntu, even though the user explicitly calls for it to be installed. I'll propose this alternative:

Suggested change
# Quiet makes the default "no" instead of "ask".
if [[ -n "$QUIET" && "$INSTALL_NETWORK_MANAGER" == "ask" ]] ; then
INSTALL_NETWORK_MANAGER="no"
fi
DISTRO=$(lsb_release -is)
if [[ "$DISTRO" = "Ubuntu" && "$INSTALL_NETWORK_MANAGER" != "true" && -z "$QUIET" && -z "$DISABLE_NETWORKING" ]]; then
echo ""
echo "Photonvision uses NetworkManager to control networking on your device."
# NetworkManager cannot be installed on non-Ubuntu distros
# --no-networking takes precedence over --install-nm
if [[ "$DISTRO" != "Ubuntu" || -n "$DISABLE_NETWORKING" ]] ; then
INSTALL_NETWORK_MANAGER="no"
fi
if [[ "$INSTALL_NETWORK_MANAGER" == "ask" ]]; then
debug ""
debug "Photonvision uses NetworkManager to control networking on your device."
read -p "Do you want this script to install and configure NetworkManager? [y/N]: " response
if [[ $response == [yY] || $response == [yY][eE][sS] ]]; then
INSTALL_NETWORK_MANAGER="true"
INSTALL_NETWORK_MANAGER="yes"
fi
fi
DISTRO=$(lsb_release -is)
if [[ "$INSTALL_NETWORK_MANAGER" == "ask" ]]; then
if [[ "$DISTRO" != "Ubuntu" || -n "$DISABLE_NETWORKING" || -n "$QUIET" ]] ; then
# Only ask if it makes sense to do so
INSTALL_NETWORK_MANAGER="no"
else
debug ""
debug "Photonvision uses NetworkManager to control networking on your device."
read -p "Do you want this script to install and configure NetworkManager? [y/N]: " response
if [[ $response == [yY] || $response == [yY][eE][sS] ]]; then
INSTALL_NETWORK_MANAGER="yes"
else
INSTALL_NETWORK_MANAGER="no"
fi
fi
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I can make these changes. I had the impression that NetworkManager was only available on Ubuntu which is why I had that logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of large nested ifs. I think it's more readable just to have two seperate ones, but the behavior is equivalent. You can see the most recent commit for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. This looks right to me.

scripts/install.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@crschardt crschardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the updates. I think this is good to go. Please merge when you are able.

@mcm001
Copy link
Contributor

mcm001 commented Oct 27, 2024

You can also? I think? Yolo

Let's move this into photon image modifier and delete from this repo post merge

@mcm001 mcm001 merged commit 6f52267 into PhotonVision:master Oct 27, 2024
31 checks passed
crschardt added a commit to PhotonVision/photon-image-modifier that referenced this pull request Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants