canonical / pc-gadget

The gadget snap for Personal Computers using 64bit Intel or AMD processors
GNU General Public License v3.0
31 stars 73 forks source link

snap on `classic` branch can't be built #103

Open dilyn-corner opened 1 year ago

dilyn-corner commented 1 year ago

https://github.com/snapcore/pc-gadget/blob/f604792d13d7e0cbb0f42d18c333ff654247a311/snapcraft.yaml#L17C63-L17C63

This line should reference ${SNAPCRAFT_PROJECT_DIR}/gadget-${SNAPCRAFT_TARGET_ARCH}.yaml -- ${SNAPCRAFT_PROJECT_DIR} is actually a different location depending on if you're building with --destructive-mode so the file path needs to be explicit.

Build log:

dilyn@Ares:~/work/canonical/pc-gadget -> snapcraft               
Starting Snapcraft 7.5.2.post73+git48bd0632                                                                                                            
Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20230829-132113.589633.log'                                                     
Running on amd64 for amd64                                                                                                                             
Launching instance...                                                                                                                                  
Starting instance                                                                                                                                      
Starting Snapcraft 7.5.2.post73+git48bd0632                                                                                                            
Logging execution to '/tmp/snapcraft.log'                                                                                                              
Running on amd64 for amd64                                                                                                                             
Initializing parts lifecycle                                                                                                                           
Executing parts lifecycle...                                                                                                                           
Installing build-packages                                                                                                                              
Installing build-snaps                                                                                                                                 
Executing parts lifecycle: skip pull gadget-yaml (already ran)                                                                                         
Executing action                                                                                                                                       
Executed: skip pull gadget-yaml (already ran)                                                                                                          
Executing parts lifecycle: skip pull grub-prepare (already ran)                                                                                        
Executing action                                                                                                                                       
Executed: skip pull grub-prepare (already ran)                                                                                                         
Executing parts lifecycle: update sources for grub (source changed)                                                                                    
Executing action                                                                                                                                       
Executed: update sources for grub (source changed)                                                                                                     
Executing parts lifecycle: build gadget-yaml                                                                                                           
Executing action                                                                                                                                       
:: + install -m 644 gadget-amd64.yaml /root/project/gadget.yaml                                                                                        
:: install: cannot stat 'gadget-amd64.yaml': No such file or directory                                                                                 
'override-build' in part 'gadget-yaml' failed with code 1.
Review the scriptlet and make sure it's correct.                                            
Failed to execute pack in instance.                                                                                                                    
Full execution log: '/home/dilyn/.local/state/snapcraft/log/snapcraft-20230829-132113.589633.log'    
dilyn-corner commented 1 year ago

Additionally, the ln and cp in the Makefile's install: target should use -f to avoid file collision problems:

{snip}
:: mkdir -p /root/parts/grub/install/meta                                                                                                              
:: ln gadget-amd64.yaml gadget.yaml                                                                                                                    
:: ln: failed to create hard link 'gadget.yaml': File exists                                                                                           
:: make: *** [Makefile:170: install] Error 1                                                                                                           
Failed to run the build script for part 'grub'.                                                                                                        
Failed to execute pack in instance.                                                                                                                    
Full execution log: '/home/dilyn/.local/state/snapcraft/log/snapcraft-20230829-151724.771742.log'    

It probably also wouldn't hurt to run make clean after everything is finished to make sure we don't dirty the current working directory once we've finished building the snap.