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

Make chisel a build snap #464

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

linostar
Copy link
Collaborator

  • Have you signed the CLA?

Chisel isn't wanted to be embedded in rockcraft snap, so it is set to be a build-snap instead.

@linostar linostar force-pushed the ROCKS-936/make-rockcraft-pull-chisel-at-pack-time branch from b473145 to 6829757 Compare January 25, 2024 18:01
@linostar
Copy link
Collaborator Author

Here are successful examples of running rockcraft pack after this PR change:

  1. "Hello World" tutorial (rockcraft.yaml that has slices)
Starting rockcraft                                                                                                                                                                                        
Logging execution to '/root/.local/state/rockcraft/log/rockcraft-20240126-081459.767870.log'                                                                                                              
Launching managed ubuntu 22.04 instance...                                                                                                                                                                
Creating instance from base instance                                                                                                                                                                      
Starting instance                                                                                                                                                                                         
Starting rockcraft                                                                                                                                                                                        
Logging execution to '/tmp/rockcraft.log'                                                                                                                                                                 
Extracting bare:latest                                                                                                                                                                                    
Extracted bare:latest                                                                                                                                                                                     
Initialising lifecycle                                                                                                                                                                                    
Installing build-packages                                                                                                                                                                                 
Pulling hello                                                                                                                                                                                             
Fetching stage-packages                                                                                                                                                                                   
Pulling pebble                                                                                                                                                                                            
Overlaying hello                                                                                                                                                                                          
Overlaying pebble                                                                                                                                                                                         
Building hello                                                                                                                                                                                            
Building pebble                                                                                                                                                                                           
Staging hello                                                                                                                                                                                             
Staging pebble                                                                                                                                                                                            
Priming hello                                                                                                                                                                                             
Priming pebble                                                                                                                                                                                            
:: + craftctl default                                                                                                                                                                                     
:: + mkdir -p var/lib/pebble/default/layers                                                                                                                                                               
Packing...                                                                                                                                                                                                
Creating new layer                                                                                                                                                                                        
Created new layer                                                                                                                                                                                         
Adding Pebble entrypoint                                                                                                                                                                                  
Configuring entrypoint...                                                                                                                                                                                 
Entrypoint set to ['/bin/pebble', 'enter', '--verbose']                                                                                                                                                   
Adding metadata                                                                                                                                                                                           
Configuring labels and annotations...                                                                                                                                                                     
Labels and annotations set to ['org.opencontainers.image.version=1.0', 'org.opencontainers.image.title=hello', 'org.opencontainers.image.ref.name=hello', 'org.opencontainers.image.licenses=Apache-2.0', 'org.opencontainers.image.created=2024-01-26T08:16:08.731117+00:00', 'org.opencontainers.image.base.digest=08dd2aa57bdccd24cd3342b1a8b4f024bc63ce995411a189dbe9d9e9d0f954e5']                              
Setting the rock's control data                                                                                                                                                                           
Control data written                                                                                                                                                                                      
Metadata added                                                                                                                                                                                            
Exporting to OCI archive                                                                                                                                                                                  
Exported to OCI archive 'hello_1.0_amd64.rock'                                                                                                                                                            
Packed hello_1.0_amd64.rock 
  1. Node.js app tutorial (rockcraft.yaml without slices)
Starting rockcraft
Logging execution to '/root/.local/state/rockcraft/log/rockcraft-20240126-082323.896225.log'
Launching managed ubuntu 22.04 instance...
Creating instance from base instance
Starting instance
Starting rockcraft
Logging execution to '/tmp/rockcraft.log'
Retrieving base [email protected] for amd64
Retrieved base [email protected] for amd64
Extracting ubuntu:22.04
Extracted ubuntu:22.04
Initialising lifecycle
Installing build-packages
Pulling app
Pulling pebble
Overlaying app
Overlaying pebble
Building app
:: + '[' '!' -f /root/parts/app/install/bin/node ']'
:: + curl -s https://nodejs.org/dist/v21.1.0/node-v21.1.0-linux-x64.tar.gz
:: + tar xzf - -C /root/parts/app/install/ --no-same-owner --strip-components=1
:: ++ npm pack .
:: ++ tail -1
:: npm notice
:: npm notice 📦  [email protected]
:: npm notice === Tarball Details ===                                                                                                                                                                     
:: npm notice name:          node_web_app                                                                                                                                                                 
:: npm notice version:       1.0.0                                                                                                                                                                        
:: npm notice filename:      node_web_app-1.0.0.tgz                                                                                                                                                       
:: npm notice package size:  458 B                                                                                                                                                                        
:: npm notice unpacked size: 569 B                                                                                                                                                                        
:: npm notice shasum:        4b08267096e1706a4e4b686641c5d6abc72e3cd9                                                                                                                                     
:: npm notice integrity:     sha512-grSoUXqxxCaAi[...]fILWatiXa/Q9g==                                                                                                                                     
:: npm notice total files:   2                                                                                                                                                                            
:: npm notice                                                                                                                                                                                             
:: + npm install -g --prefix /root/parts/app/install node_web_app-1.0.0.tgz                                                                                                                               
::                                                                                                                                                                                                        
:: added 63 packages in 3s                                                                                                                                                                                
::                                                                                                                                                                                                        
:: 11 packages are looking for funding                                                                                                                                                                    
::   run `npm fund` for details                                                                                                                                                                           
:: npm notice                                                                                                                                                                                             
:: npm notice New minor version of npm available! 10.2.0 -> 10.4.0                                                                                                                                        
:: npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.4.0>                                                                                                                                
:: npm notice Run `npm install -g [email protected]` to update!                                                                                                                                                  
:: npm notice                                                                                                                                                                                             
Building pebble                                                                                                                                                                                           
Staging app                                                                                                                                                                                               
Staging pebble                                                                                                                                                                                            
Priming app                                                                                                                                                                                               
Priming pebble                                                                                                                                                                                            
:: + craftctl default                                                                                                                                                                                     
:: + mkdir -p var/lib/pebble/default/layers                                                                                                                                                               
Packing...                                                                                                                                                                                                
Creating new layer                                                                                                                                                                                        
Created new layer                                                                                                                                                                                         
Adding Pebble entrypoint                                                                                                                                                                                  
Configuring entrypoint...                                                                                                                                                                                 
Entrypoint set to ['/bin/pebble', 'enter', '--verbose']                                                                                                                                                   
Configuring Pebble services app                                                                                                                                                                           
Found 0 Pebble layers in the base's root filesystem                                                                                                                                                       
Preparing new Pebble layer file 001-my-node-app.yaml                                                                                                                                                      
Writing new Pebble layer file                                                                                                                                                                             
Adding metadata                                                                                                                                                                                           
Configuring labels and annotations...                                                                                                                                                                     
Labels and annotations set to ['org.opencontainers.image.version=1.0', 'org.opencontainers.image.title=my-node-app', 'org.opencontainers.image.ref.name=my-node-app', 'org.opencontainers.image.licenses=GPL-3.0', 'org.opencontainers.image.created=2024-01-26T08:25:04.369867+00:00', 'org.opencontainers.image.base.digest=1ea0c67060c5054fa74789f089d27f01442588e8874159de1c7aa61fb6bf70fc']                     
Setting the rock's control data                                                                                                                                                                           
Control data written                                                                                                                                                                                      
Metadata added                                                                                                                                                                                            
Exporting to OCI archive                                                                                                                                                                                  
Exported to OCI archive 'my-node-app_1.0_amd64.rock'                                                                                                                                                      
Packed my-node-app_1.0_amd64.rock

@linostar
Copy link
Collaborator Author

@cjdcordeiro @tigarmo This is ready for review. See examples of running it above.

Before merging this, PR #637 needs to be merged first, and function part_has_slices need to be removed from rockcraft afterwards in the current PR.

@linostar linostar marked this pull request as ready for review January 26, 2024 08:39
@linostar linostar force-pushed the ROCKS-936/make-rockcraft-pull-chisel-at-pack-time branch from cfddc15 to 4248878 Compare January 26, 2024 08:58
Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

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

Nice. Short and sweet. I'm adding a label to be explicit that canonical/craft-parts#637 should be merged first

Comment on lines +48 to +52
# this will be removed once part_has_slices is added to craft-parts
def part_has_slices(data: dict[str, Any]) -> bool:
stage_packages = data.get("stage-packages", [])
return any(name for name in stage_packages if "_" in name)

Copy link
Collaborator

Choose a reason for hiding this comment

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

still within this PR right? Since we're waiting for canonical/craft-parts#637

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes


services = cast(RockcraftServiceFactory, self._services)
image_service = services.image
image_info = image_service.obtain_image()
needs_chisel = any(part for part in parts if part_has_slices(parts[part]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this will also slightly change after canonical/craft-parts#637

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, it will become craft_parts.part_has_slices instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can move detection and chisel installing to craft-parts, it already does that with other tools such as git.


if needs_chisel:
self._manager_kwargs.update(
extra_build_snaps=["chisel/latest/candidate"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit worried about using a "dynamic" candidate snap here. Is there a plan/timeline for stable chisel?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not before 13th of Feb, but most likely towards the end of that month.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had a discussion with Cris about this, and he said it's ok if we wait until chisel stable is released before we merge this one.

@clay-lake
Copy link
Contributor

Hey everyone. I wanted to check in on this PR; I'm worried its getting a little stale.
Should we keep it open?

🦇

@linostar
Copy link
Collaborator Author

Hey everyone. I wanted to check in on this PR; I'm worried its getting a little stale. Should we keep it open?

🦇

We're still waiting for chisel to release its first stable release, so I guess let's keep it open until then.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants