-
Notifications
You must be signed in to change notification settings - Fork 370
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.sh: Simplify syntax and improvements #9223
base: master
Are you sure you want to change the base?
Conversation
Please try in containers! |
: "${GTIHUB_OWNER:=chromebrew}" | ||
: "${GITHUB_REPO:=chromebrew}" | ||
: "${GITHUB_BRANCH:=master}" | ||
: "${GITLAB_REPO:=26210301}" |
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.
To be honest, I don't know if there's any practical value to changing the gitlab repo, I don't know of any other repos that mirror our package repository or would be otherwise useful to switch to.
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.
This is used to set the PREBUILT_URL
variable below to reduce duplicate long assignments. This is actually good because if this value changes in the future, we only have to change in one place...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.
Wouldn't that be the same if we just had the value set in PREBUILT_URL? I'm not a fan of single-use variables.
@@ -102,15 +109,17 @@ fi | |||
|
|||
if [[ "$ARCH" == "x86_64" ]]; then | |||
LIB_SUFFIX='64' | |||
else | |||
LIB_SUFFIX='' |
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.
Is LIB_SUFFIX not already empty by default, since we don't set the variable?
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 doesn't hurt to set it explicitly for clarity and in the off chance it's set outside of crew.
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.
Reduce?
LIB_SUFFIX=''
[[ "${ARCH}" == "x86_64" ]] && LIB_SUFFIX='64'
@@ -194,16 +200,16 @@ for package in $BOOTSTRAP_PACKAGES; do | |||
# This is really ugly, FIXME after #7082 is merged. |
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.
Obviously this isn't something you have to do, but if you wanted you could change the code to not have two copies of each url based on the tar compression, and instead use the value of binary_compression now that that's a possibility.
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.
If not, I'll get around to it soon.
|
||
# Check if the script is being run as root. | ||
if [ "${EUID}" == "0" ]; then | ||
echo_error "Chromebrew should not be installed or run as root." | ||
echo_info "Please login as 'chronos' and restart the install." | ||
echo_info "Please login as 'chronos' and restart the install." |
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.
Extra space?
exit 1 | ||
fi | ||
|
||
# Reject crostini. | ||
if [[ -d /opt/google/cros-containers && "${CREW_FORCE_INSTALL}" != '1' ]]; then | ||
echo_error "Crostini containers are not supported by Chromebrew :/" | ||
echo_info "Run 'CREW_FORCE_INSTALL=1 exec bash --init-file <(curl -Ls git.io/vddgY)' to perform install anyway" | ||
echo_info "Run 'CREW_FORCE_INSTALL=1 exec bash --init-file <(curl -Ls git.io/vddgY)' to perform install anyway" |
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.
Extra space?
echo_error "Please run the installer in the VT-2 shell." | ||
echo_info "To start the VT-2 session, type Ctrl + Alt + ->" | ||
echo_info "To start the VT-2 session, press Ctrl + Alt + -> and login with user 'chronos'" |
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.
Extra 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.
End sentence with a .
?
echo_info "This will delete ALL files in ${CREW_PREFIX}!" | ||
echo_info "Continue?" | ||
echo_info "This will delete ALL files in ${CREW_PREFIX}!" | ||
echo_info "Continue?" |
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.
Extra space?
export "$(grep CHROMEOS_RELEASE_CHROME_MILESTONE /etc/lsb-release)" | ||
else | ||
echo_info "Unable to detect system information, installation will continue." | ||
if ! [[ "${CHROMEOS_RELEASE_TRACK}" == 'stable-channel' || "${CREW_FORCE_INSTALL}" == '1' ]]; then |
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.
if [[ -z "${CREW_FORCE_INSTALL}" && "${CHROMEOS_RELEASE_TRACK}" != 'stable-channel' ]]; then
?
: "${CREW_CACHE_DIR:=$CREW_PREFIX/tmp/packages}" | ||
|
||
BOOTSTRAP_PACKAGES=(zstd crew_mvdir ruby git ca_certificates openssl) | ||
SPARSE_CHECKOUT=(packages manifest/${USER_SPACE_ARCH} lib bin crew tests tools) |
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.
USER_SPACE_ARCH
not defined yet?
echo_info "If this happens, please report them to: https://github.com/chromebrew/chromebrew/issues" | ||
echo_info "If the install fails, try running 'CREW_AMD_INSTALL=1 exec bash --init-file <(curl -Ls git.io/vddgY)'" | ||
echo_info "If this happens, please report them to: ${REPO_URL}/issues" | ||
echo_info "If the install fails, try running 'CREW_AMD_INSTALL=1 exec bash --init-file <(curl -L git.io/vddgY)'" |
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.
Now you are starting to think like me. I don't like when ANY command is silenced.
else | ||
urls+=("https://gitlab.com/api/v4/projects/26210301/packages/generic/${name}/${version}_${ARCH}/${name}-${version}-chromeos-${ARCH}.tar.zst") | ||
urls+=("${PREBUILT_URL}/${name}/${version}_${ARCH}/${name}-${version}-chromeos-${ARCH}.tar.zst") |
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.
Reduce "${PREBUILT_URL}/${name}/${version}_${ARCH}/${name}-${version}-chromeos-${USER_SPACE_ARCH}.tar.${ARCHIVE_EXTENSION}"
to one line and simply assign ARCHIVE_EXTENSION
instead?
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.
And we don't need to assign ARCHIVE_EXTENSION, we can just use the binary_compression value in each package.
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.
(once this is rebased onto master, this review is no longer relevant)
@@ -3,56 +3,81 @@ | |||
# Exit on fail. | |||
set -e | |||
|
|||
RESET='\e[0m' | |||
# Default chromebrew repo values. | |||
: "${GTIHUB_OWNER:=chromebrew}" |
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.
GITHUB_OWNER
?
@supechicken: Did you want to merge master into this PR branch and resolve merge conflicts? |
Changes
sudo
availability in a more elegant way/etc/lsb-release
directly instead of usinggrep
$(id -u)
calls with${EUID}
pixz
since.pixz
should be backward compatible withxz
git sparse-checkout
from the repo tarballBOOTSTRAP_PACKAGES
instead of stringNot tested yet