github.com/canonical/ubuntu-image@v0.0.0-20240430122802-2202fe98b290/tests/amd64/classic/task.yaml (about)

     1  summary: Build classic Ubuntu server image
     2  
     3  kill-timeout: 3h
     4  
     5  systems: [-ubuntu-18.04-64]
     6  
     7  execute: |
     8      mkdir -p /tmp/${IMG}/{workdir,mount}
     9      IMG_DEF_PATH=/home/ubuntu-image/ubuntu-images/${IMG}.yaml
    10      ubuntu-image classic --debug --workdir /tmp/${IMG}/workdir $IMG_DEF_PATH
    11  
    12      IMG_NAME=$(cat $IMG_DEF_PATH | yq '.artifacts.img.[0].name')
    13      losetup --find --show --partscan /tmp/${IMG}/workdir/$IMG_NAME
    14      losetup -a | grep $IMG_NAME |cut -f1 -d: >> loop.txt
    15      LOOP="$(cat loop.txt)"
    16  
    17      for l in `ls -d "$LOOP"p*`
    18      do 
    19          p=${l#"$LOOP"}
    20          mkdir /tmp/${IMG}/mount/$p
    21          mount $l /tmp/${IMG}/mount/$p || true
    22          ls /tmp/${IMG}/mount/$p/ || true
    23      done
    24  
    25  restore: |
    26      if [ -f loop.txt ]; then
    27          LOOP="$(cat loop.txt)"
    28  
    29          for l in `ls -d "$LOOP"p*`
    30          do 
    31              p=${l#"$LOOP"}
    32              mount --make-rprivate /tmp/${IMG}/mount/$p || true
    33              umount --recursive /tmp/${IMG}/mount/$p || true
    34          done
    35  
    36          losetup -d "$LOOP"
    37          sync
    38          losetup -l | NOMATCH "$LOOP"
    39          rm loop.txt
    40      fi
    41  
    42      rm -rf /tmp/${IMG}/
    43  
    44  debug: |
    45      df -h
    46      du -h -d 1 /tmp/
    47      mount  -l
    48      if [ -f loop.txt ]; then
    49          cat loop.txt
    50      fi
    51      losetup -l