-
Notifications
You must be signed in to change notification settings - Fork 369
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
Split upload command into separate file #9594
base: master
Are you sure you want to change the base?
Conversation
f568908
to
3e99fc0
Compare
bin/crew
Outdated
@@ -202,10 +203,9 @@ def generate_compatible | |||
puts 'Generating compatible packages done.'.orange if @opt_verbose | |||
end | |||
|
|||
def search(pkg_name, silent = false) | |||
pkg_path = File.join(CREW_PACKAGES_PATH, "#{pkg_name}.rb") | |||
def search(pkg_name, pkg_path: File.join(CREW_PACKAGES_PATH, "#{pkg_name}.rb"), silent: false) |
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.
Why does this need to be a parameter? Keep it simple!
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.
Please read the reasons I gave in the PR description...
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.
Behavior changes:
Remove support for uploading without passing a package name.
This wasn't working anyways, and I can't conceive of a situation where you are uploading packages without knowing their names or having just built them.
I'm not sure why you think this wasn't working when I've been using it for over a month now without an issue.
If this functionality is still needed, I can write a bash harness to implement this functionality externally.
No, the whole purpose of adding this function was to remove the need for bash scripts and incorporate it as a crew command instead.
Remove support for uploading multiple architectures.
This functionality was working, but it would have dramatically complicated the code to continue to implement.
It was already written and simplifies the process for contributors. Because the code is complicated is not a valid reason for removing it altogether.
If this functionality is needed, just setting the ARCH environment variable should take care of things.
This functionality was added for a reason
Remove [options] from the docopt section for crew upload.
Same rationale as the last times I've done this.
Remove verbose argument.
Because of the refactor, the code that previously would have used this is now gone.
Then add it back. We'll want to control verbosity.
Refactoring changes:
Rework load_package in lib/package.rb to only take one argument, being the path to the package file.
How about rework to take one argument of the package name instead?
Derive the package name in the function itself, rather than the weird setup we had before with a default argument value (when would we ever want to pass a different value to that?).
Rework set_package in to only take one argument, , being the path to the package file.
All it was using the previous argument for was to unnecessarily pass it to load_package.
Nothing weird about passing the package name and having the function determine the path.
Rework search to accept a package name, path, and a value for silent.
No need for a path. Search should ONLY look for crew packages, not your local repo directory.
Use named parameters for the last two to save boilerplate.
Use a default value for pkg_path, as it is a named parameter rather than just being an optional one.
Again, package name makes more sense than package path.
Move the rubocop section that was previously in def upload to def copy_package.
Better to sanitize the package file earlier in the process.
Load the package file from CREW_LOCAL_REPO_ROOT when passing the package object to Command.upload, as this is the package file that we will be working with.
No need to do this at all.
Rework the way we look for GITLAB_TOKEN to not need a trailing if and .nil? by using a block in the fallback of ENV.fetch to abort if we can't find it.
Check no_zstd to find the extension of the newly built binaries and set the local variable binary_compression to that.
Since we just built the binary, we can be confident in the extension, as chromebrew will only use one of two compression programs.
Use net/http instead of curl to upload the binary.
Use .sub! and .gsub! instead of sed to update the package file.
We're not only substituting here. We're ADDING new lines if the section doesn't exist yet.
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'm not sure why you think this wasn't working when I've been using it for over a month now without an issue.
Probably because it's been broken whenever I tried to do it.
No, the whole purpose of adding this function was to remove the need for bash scripts and incorporate it as a crew command instead.
Again, I do not understand how you can be in a scenario where you don't know the names of the binaries you are uploading. I genuinely do not see a usecase for not passing a package name.
Then add it back. We'll want to control verbosity.
Because we aren't using system commands anymore, we can't just print the curl
command we are using. If it was possible to add this code back I would have.
It was already written and simplifies the process for contributors. Because the code is complicated is not a valid reason for removing it altogether.
This functionality was added for a reason
Again, what is the reason? When are you in a scenario where you aren't on the same architecture as the binaries you've built?
Again, package name makes more sense than package path
No need to do this at all.
Please see my other comment where I explained why this is not the case.
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.
Actually, I can probably re-implement some of the verbosity, I'll do that when I've got the time.
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.
Added back the verbosity that was practical to do.
args['<name>'].each do |name| | ||
search name | ||
upload name if @pkg.name | ||
search name, pkg_path: File.join(CREW_LOCAL_REPO_ROOT, 'packages', "#{name}.rb") |
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.
No need to pass the package path. Let the function figure it out from the predefined constant. Also, we do not want to use CREW_LOCAL_REPO_ROOT
. We should be using CREW_PACKAGES_PATH
.
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.
We want to use CREW_LOCAL_REPO_ROOT-- that is the location of the package file we will be editing once we have uploaded, so we want to get the values from that file.
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.
You have to copy the package from your local repo to the crew packages directory BEFORE you can even test it so I'm not sure why you think this needs a refactor. Also, please stop resolving conversations.
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.
git clone https://github.com/chromebrew/chromebrew.git
cd chromebrew
crew build packages/libnvme.rb
The package file never makes it to CREW_PACKAGES_PATH
.
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 NOT my workflow. This is harder than a simple crew build libnvme
and NOT requiring the path. The path is abstracted which is the whole point of why I wrote this originally.
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'm abstracting the path so if you are making changes to the package in your local repo, crew will detect that it differs from the crew repo package and offer to copy it over so it can run it inside crew. So simply running crew build/install/reinstall <package>
will enable you to test the package without needed to copy the package file over manually. My vision is for contributors to be able to do everything they need to do to create and update packages inside their own forked repo instead of working inside crew directly. This way changes are easier to manage and removes the potential human error element from the process. I know @satmandu has a different workflow and that is fine but I still think mine is easier. :)
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.
So your goal is that the user does all the changes in their local repository, but crew then copies it to the installation, works with that, then copies back any changes to the local repository?
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'll point out that the workflow I am enabling here does not require any manual copying, and in fact just removes the requirement for a package file to be inside the crew installation. (I'm also trying to reach an agreement on this because it will significantly affect how I refactor crew check
, which I'd like to get started on soon)
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 still don't think you fully understand my workflow. The way it currently works (by design) is any change you make in your local working repo will be prompted to copy to crew for installation (no manual copying). I don't think a refactor is necessary because it will over complicate the process and the package has to end up in crew anyway to test the install. You can always do a crew update to restore back to the original version if you are updating existing packages.
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.
The point of these changes to search
is to ensure that there is no need for any copying, whether automatic or manual. I'd argue that this simplifies the process, in fact.
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'm of the opinion we should only pass the package name to any function. The function itself should figure out the path. We also need to be consistent with the calls. Right now, some functions require the path and others just the package name. Let's just send the package name only.
I'm not entirely sure what you mean by this-- we only pass the package path to search, which loads the package file. |
file.sub!(/binary_compression.*/, "binary_compression '#{binary_compression}'") | ||
|
||
# Update the package file with the new binary_sha256 value. | ||
file.gsub!(pkg.binary_sha256[ARCH.to_sym], Digest::SHA256.hexdigest(File.read(pkg_tarfile_path))) |
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 handles updating the package if the sha256sum hash exists but what about new packages that don't have the section added yet?
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.
New packages will need a dummy section something like this one:
binary_sha256({
aarch64: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
armv7l: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
i686: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii',
x86_64: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
})
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.
All the code to not require this is already there. You are digressing the code and making the process harder instead of making it better.
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.
All the code to not require this is already there.
This code is broken, at least in my experience.
You are digressing the code and making the process harder instead of making it better.
Would you be open to the addition of something like a crew create
command which creates a package template file? My intention is not to make things more difficult, and I'd be happy to implement this functionality elsewhere where it is more suited.
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.
Sure, that sounds like a great idea. Maybe provide a few basic prompts like the package name, description, version, etc. It would be nice to search through all the packages to determine if there is a name conflict also.
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.
Sounds good! I'll mark this PR as draft until then because I don't want to remove this functionality until an option is available.
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.
See #9624.
d0b799c
to
5391b6f
Compare
336829d
to
f3b134e
Compare
@@ -364,7 +364,7 @@ | |||
crew test [-v|--verbose] [<name> ...] | |||
crew update [options] [-v|--verbose] [<compatible>] | |||
crew upgrade [options] [-k|--keep] [-s|--source] [-v|--verbose] [<name> ...] | |||
crew upload [options] [-v|--verbose] [<name> ...] | |||
crew upload <name> ... |
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 think we should keep the -v
option for debugging purposes.
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.
The old verbose option just printed the system commands being used-- no system commands are used anymore, so I wasn't sure how to re-implement it.
Split out
upload
command tocommands/upload.rb
.Behavior changes:
ARCH
environment variable should take care of things.[options]
from the docopt section forcrew upload
.Refactoring changes:
load_package
inlib/package.rb
to only take one argument, being the path to the package file.set_package
in to only take one argument, , being the path to the package file.load_package
.search
to accept a package name, path, and a value for silent.pkg_path
, as it is a named parameter rather than just being an optional one.def upload
todef copy_package
.CREW_LOCAL_REPO_ROOT
when passing the package object toCommand.upload
, as this is the package file that we will be working with.GITLAB_TOKEN
to not need a trailingif
and.nil?
by using a block in the fallback ofENV.fetch
to abort if we can't find it.no_zstd
to find the extension of the newly built binaries and set the local variablebinary_compression
to that.net/http
instead ofcurl
to upload the binary..sub!
and.gsub!
instead ofsed
to update the package file.Tested and working on all architectures.
Run the following to get this pull request's changes locally for testing.