lima icon indicating copy to clipboard operation
lima copied to clipboard

add opensuse-tumbleweed for aarch64

Open replicajune opened this issue 3 years ago • 6 comments

Description

Hello,

After some digging and copy pasting stuff around, I was able to make tumbleweed working on aarch64 using the following yaml config file:

images:
- location: http://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.qcow2
  arch: "aarch64"
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
provision:
- mode: system
  script: |
    #!/bin/bash
    set -eux -o pipefail
    zypper refresh
    zypper install -y sshfs
    for FILE in fuse fuse3; do echo 'user_allow_other' >> "/etc/${FILE}.conf"; done

is it something I can propose a merge request in /examples/experimental/opensuse-tumbleweed.yaml ?

I would:

  • add the new aarch64 location
  • setup the script to have the requirement for mount point in place
  • keep the comments in place from the original file

However as I don't own a x64 mac machine I wouldn't be able to make sure that the script properly runs on x86_64. Maybe someone could review it and test it ? :)

replicajune avatar Aug 06 '22 15:08 replicajune

Thanks, yes, PR is appreciated but the script should be placed in here: https://github.com/lima-vm/lima/blob/9daf5851ae9f0fcd739c7e260f3367268b5dda96/pkg/cidata/cidata.TEMPLATE.d/boot/30-install-packages.sh#L148

AkihiroSuda avatar Aug 07 '22 15:08 AkihiroSuda

I'm not yet certain why but the script should already pick up the needed dependencies (sshfs, setting user_allow_other).

If I look at the logs, it seems the script is triggered a little bit too early in the process because refreshing the repository metadata is failing (apt can't resolve download.opensuse.org). If I use apt-get myself later in the process, it works (I'm also noticing that the network is reporting as online, which add a little to my confusion):

[...]
[  OK  ] Started OpenSSH Daemon.                                                                                                                                                                                                                                                                                                                                          
[  OK  ] Reached target Multi-User System.                                                                                                                                                                                                                                                                                                                                
[  OK  ] Reached target Graphical Interface.                                                                                                                                                                                                                                                                                                                              
[  OK  ] Finished Network Manager Wait Online.                                                                                                                                                                                                                                                                                                                            
[  OK  ] Reached target Network is Online.                                                                                                                                                                                                                                                                                                                                
         Starting Apply the settings specified in cloud-config...                                                                                                                                                                                                                                                                                                         
[    9.340622] cloud-init[1026]: Cloud-init v. 21.4-2.2 running 'modules:config' at Sun, 07 Aug 2022 18:24:42 +0000. Up 9.31 seconds.                                                                                                                                                                                                                                     
[  OK  ] Finished Apply the settings specified in cloud-config.                                                                                                                                                                                                                                                                                                           
         Starting Execute cloud user/final scripts...                                                                                                                                                                                                                                                                                                                     
[    9.606469] cloud-init[1030]: Cloud-init v. 21.4-2.2 running 'modules:final' at Sun, 07 Aug 2022 18:24:42 +0000. Up 9.57 seconds.                                                                                                                                                                                                                                      
[    9.665476] cloud-init[1030]: + LIMA_CIDATA_MNT=/mnt/lima-cidata                                                                                                                                                                                                                                                                                                       
[    9.666248] cloud-init[1030]: + LIMA_CIDATA_DEV=/dev/disk/by-label/cidata                                                                                                                                                                                                                                                                                              
[...]
[   10.805500] cloud-init[1030]: + command -v newuidmap                                                                                                                                                                                                                                                                                                                   
[   10.805850] cloud-init[1030]: + '[' -n ' sshfs iptables' ']'                                                                                                                                                                                                                                                                                                           
[   10.806245] cloud-init[1030]: + DEBIAN_FRONTEND=noninteractive                                                                                                                                                                                                                                                                                                         
[   10.806659] cloud-init[1030]: + export DEBIAN_FRONTEND                                                                                                                                                                                                                                                                                                                 
[   10.807139] cloud-init[1030]: + apt-get update                                                                                                                                                                                                                                                                                                                         
[   11.009632] cloud-init[1030]: Retrieving repository 'openSUSE-Tumbleweed-Oss' metadata [.error]                                                                                                                                                                                                                                                                        
[   11.012289] cloud-init[1030]: Repository 'openSUSE-Tumbleweed-Oss' is invalid.                                                                                                                                                                                                                                                                                         
[   11.013394] cloud-init[1030]: [repo-oss|http://download.opensuse.org/ports/aarch64/tumbleweed/repo/oss/] Valid metadata not found at specified URL                                                                                                                                                                                                                     
[   11.015084] cloud-init[1030]: History:                                                                                                                                                                                                                                                                                                                                 
[   11.015377] cloud-init[1030]:  - [|] Error trying to read from 'http://download.opensuse.org/ports/aarch64/tumbleweed/repo/oss/'                                                                                                                                                                                                                                       
[   11.016288] cloud-init[1030]:  - Download (curl) error for 'http://download.opensuse.org/ports/aarch64/tumbleweed/repo/oss/content':                                                                                                                                                                                                                                   
[   11.017101] cloud-init[1030]:    Error code: Connection failed                                                                                                                                                                                                                                                                                                         
[   11.017629] cloud-init[1030]:    Error message: Could not resolve host: download.opensuse.org                                                                                                                                                                                                                                                                          
[   11.018249] cloud-init[1030]: Please check if the URIs defined for this repository are pointing to a valid repository.                                                                                                                                                                                                                                                 
[   11.018964] cloud-init[1030]: Skipping repository 'openSUSE-Tumbleweed-Oss' because of the above error.                                                                                                                                                                                                                                                                
[   12.222609] cloud-init[1030]: Retrieving repository 'openSUSE-Tumbleweed-Update' metadata [..done]                                                                                                                                                                                                                                                                     
[   12.231709] cloud-init[1030]: Building repository 'openSUSE-Tumbleweed-Update' cache [....done]                                                                                                                                                                                                                                                                        
[   12.233464] cloud-init[1030]: Some of the repositories have not been refreshed because of an error.                                                                                                                                                                                                                                                                    
[   12.235067] cloud-init[1030]: LIMA| WARNING: Failed to execute /mnt/lima-cidata/boot/30-install-packages.sh                                                                                                                                                                                                                                                            
[   12.236109] cloud-init[1030]: LIMA| Executing /mnt/lima-cidata/boot/40-install-containerd.sh                                                                                                                                                                                                                                                                           
[   12.237412] cloud-init[1030]: + '[' '' '!=' 1 ']'                                                                                                                                                                                                                                                                                                                      
[...]
[   28.489731] cloud-init[1030]: ###  END  ###                                                                                                                                                                                                                                                                                                                            
[   28.491324] cloud-init[1030]: [INFO] Set `export CONTAINERD_SNAPSHOTTER="stargz"` to use the stargz snapshotter.                                                                                                                                                                                                                                                       
[   28.493044] cloud-init[1030]: + '[' -n '' ']'                                                                                                                                                                                                                                                                                                                          
[   28.493625] cloud-init[1030]: LIMA| Executing /mnt/lima-cidata/provision.system/00000000                                                                                                                                                                                                                                                                               
[   28.494901] cloud-init[1030]: + apt-get update                                                                                                                                                                                                                                                                                                                         
[   44.173262] cloud-init[1030]: Retrieving repository 'openSUSE-Tumbleweed-Oss' metadata [................done]                                                                                                                                                                                                                                                          
[   46.760536] cloud-init[1030]: Building repository 'openSUSE-Tumbleweed-Oss' cache [....done]                                                                                                                                                                                                                                                                           
[   47.326412] cloud-init[1030]: Repository 'openSUSE-Tumbleweed-Update' is up to date.                                                                                                                                                                                                                                                                                   
[   47.329462] cloud-init[1030]: All repositories have been refreshed.                                                                                                                                                                                                                                                                                                    
[   47.334325] cloud-init[1030]: + apt-get install -y sshfs                                                                                                                                                                                                                                                                                                               
[   47.387235] cloud-init[1030]: Loading repository data...                                                                                                                                                                                                                                                                                                               
[   47.471899] cloud-init[1030]: Reading installed packages...                                                                                                                                                                                                                                                                                                            
[   47.659290] cloud-init[1030]: Resolving package dependencies...                                                                                                                                                                                                                                                                                                        
[   47.704372] cloud-init[1030]: The following 3 NEW packages are going to be installed:                                                                                                                                                                                                                                                                                  
[   47.705049] cloud-init[1030]:   fuse3 libfuse3-3 sshfs                                                                                                                                                                                                                                                                                                                 
[   47.705500] cloud-init[1030]: 3 new packages to install.                                                                                                                                                                                                                                                                                                               
[   47.705842] cloud-init[1030]: Overall download size: 191.9 KiB. Already cached: 0 B. After the operation, additional 625.4 KiB will be used.                                                                                                                                                                                                                           
[   47.706670] cloud-init[1030]: Continue? [y/n/v/...? shows all options] (y): y                                                                                                                                                                                                                                                                                          
[   47.753928] cloud-init[1030]: Retrieving package libfuse3-3-3.11.0-1.3.aarch64 (1/3),  80.8 KiB (258.2 KiB unpacked)                                                                                                                                                                                                                                                   
[   48.617389] cloud-init[1030]: Retrieving: libfuse3-3-3.11.0-1.3.aarch64.rpm [done]                                                                                                                                                                                                                                                                                     
[   48.619382] cloud-init[1030]: Retrieving package fuse3-3.11.0-1.3.aarch64 (2/3),  58.6 KiB (214.4 KiB unpacked)                                                                                                                                                                                                                                                        
[...]

so technically the script part in the yaml file is useless, as it would be to add a specific bit in 30-install-packages.sh since it technically should already be doing that but is currently failing to do so

I'll try to see if I can understand why this happens

replicajune avatar Aug 07 '22 18:08 replicajune

so the available version of apt-get in opensuse is a wrapper around zypper written in perl. As is, it doesn't seem to work with some of the options usually set for it. Even if the script is able to refresh the repository metadata, actually installing the requirement are failing because this option cause the apt wrapper to fail:

lima-tw:/mnt/lima-cidata/boot # ./30-install-packages.sh 
+ INSTALL_IPTABLES=0
+ '[' '' = 1 ']'
+ '[' 1 = 1 ']'
+ INSTALL_IPTABLES=1
+ '[' 56526 -ne 0 ']'
+ INSTALL_IPTABLES=1
+ command -v apt-get
+ pkgs=
+ '[' reverse-sshfs = reverse-sshfs ']'
+ '[' 2 -gt 0 ']'
+ command -v sshfs
+ pkgs=' sshfs'
+ '[' 1 = 1 ']'
+ '[' '!' -e /usr/sbin/iptables ']'
+ pkgs=' sshfs iptables'
+ '[' 1 = 1 ']'
+ command -v newuidmap
+ '[' -n ' sshfs iptables' ']'
+ DEBIAN_FRONTEND=noninteractive
+ export DEBIAN_FRONTEND
+ apt-get update
Repository 'openSUSE-Tumbleweed-Oss' is up to date.                                                                                                                                  
Repository 'openSUSE-Tumbleweed-Update' is up to date.                                                                                                                               
All repositories have been refreshed.
+ apt-get install -y --no-upgrade --no-install-recommends -q sshfs iptables
The flag --no-upgrade is not known.
lima-tw:/mnt/lima-cidata/boot # 

Going with the same iterative approach, I'm able to get apt working if I remove --no-upgrade, --no-install-recommends and -q options.

to complete my test I have to re-export LIMA_CIDATA_MNT manually and the script works then:

lima-tw:/mnt/lima-cidata/boot # export LIMA_CIDATA_MNT=/mnt/lima-cidata
lima-tw:/mnt/lima-cidata/boot # /tmp/30-install-packages.sh 
+ INSTALL_IPTABLES=0
+ '[' '' = 1 ']'
+ '[' 1 = 1 ']'
+ INSTALL_IPTABLES=1
+ '[' 56526 -ne 0 ']'
+ INSTALL_IPTABLES=1
+ command -v apt-get
+ pkgs=
+ '[' reverse-sshfs = reverse-sshfs ']'
+ '[' 2 -gt 0 ']'
+ command -v sshfs
+ '[' 1 = 1 ']'
[...] [previous tests installed sshfs] [...]
+ /mnt/lima-cidata/boot/09-host-dns-setup.sh
[...] [doing a bunch of iptable things here] [...]
+ '[' reverse-sshfs = reverse-sshfs ']'
+ update_fuse_conf
+ '[' 2 -gt 0 ']'
+ fuse_conf=/etc/fuse.conf
+ '[' -e /etc/fuse3.conf ']'
+ fuse_conf=/etc/fuse3.conf
+ grep -q '^user_allow_other' /etc/fuse3.conf
+ echo user_allow_other
lima-tw:/mnt/lima-cidata/boot # 

Reading some other issues seem to indicate that detecting package managers by querying their existence is done purposefully. I feel like the easiest way for a fix would be to remove the above mentioned problematic options but I also guess they're here rightfully for debian-like systems to avoid un-necessary dependencies and to get a clean output.

I think I can keep the same spirit but I'd need to change the detection for apt-get to this: hexdump -C -n 4 "$(command -v apt-get)" | grep -qF 'ELF'

it would fail on opensuse:

julien@lima-tw:/Users/julien> hexdump -C -n 4 "$(command -v apt-get)" | grep -qF 'ELF'
julien@lima-tw:/Users/julien> echo $?
1

and it would success on ubuntu:

julien@lima-default:/Users/julien$ hexdump -C -n 4 "$(command -v apt-get)" | grep -qF 'ELF'
julien@lima-default:/Users/julien$ echo $?
0

debian would also be ok :

julien@lima-debian:/Users/julien$ hexdump -C -n 4 "$(command -v apt-get)" | grep -qF 'ELF'
julien@lima-debian:/Users/julien$ echo $?
0

what do you think ?

replicajune avatar Aug 07 '22 22:08 replicajune

The suggestion was to just look for "and not zypper", but then it was complicated by distribution

  • #983

afbjorklund avatar Aug 08 '22 14:08 afbjorklund

damn I should have read your issue more throughfully since we basically got into the same issues and steps to identify the root cause :)

I would agree to switch to system detection and infer package management from that. it's usually how it's done. but in thecurrent situation I took for granted that the solution had to be done with package manager detection, hence why I'm trying to dig a little deeper and see if the version of apt or apt-get is indeed legit or not. I think it would practically solve our issues while keeping the current approach as is, and it would leave the room open for discution on switching to a different detection method later

replicajune avatar Aug 08 '22 16:08 replicajune

Seems weird of opensuse to also provide "apt-get" in the first place, but maybe it's a feature (muscle memory, and all that)

But I don't have any idea, don't even know why a tumbleweed is better than a leap - I guess it is some kind of "rawhide"

afbjorklund avatar Aug 08 '22 16:08 afbjorklund