@@ -380,6 +380,49 @@ runs:
380380 # - name: Setup tmate session
381381 # uses: mxschmitt/action-tmate@v3
382382
383+ - name : List installed packages in ${{ env.IMAGE_FILE }} cloud image
384+ if : ${{ ! contains(inputs.type, 'vagrant') }}
385+ shell : bash
386+ run : |
387+ # List installed packages in ${{ env.IMAGE_FILE }} image
388+ partition=4
389+ case ${{ inputs.type }} in
390+ oci|gencloud|opennebula) format=qcow2 ;;
391+ azure) format=raw ;;
392+ *) false ;;
393+ esac
394+ rootfs_path=/mnt/rootfs
395+ sudo mkdir -p ${rootfs_path}
396+
397+ # Install qemu-utils
398+ sudo ${{ env.runner_os == 'ubuntu' && 'apt-get' || 'dnf -q' }} \
399+ -y install \
400+ ${{ env.runner_os == 'ubuntu' && 'qemu-utils' || 'qemu-img' }}
401+
402+ # Load nbd kernel module
403+ sudo modprobe nbd max_part=8
404+
405+ # Make a copy of the image file
406+ sudo cp ${{ env.IMAGE_FILE }} $(dirname ${rootfs_path})
407+
408+ # Attach the image file to the nbd device
409+ sudo qemu-nbd \
410+ --read-only \
411+ --format=${format} \
412+ --connect=/dev/nbd0 \
413+ $(dirname ${rootfs_path})/$(basename ${{ env.IMAGE_FILE }})
414+
415+ # Mount need partition
416+ sudo fdisk -l /dev/nbd0
417+ sudo mount /dev/nbd0p${partition} ${rootfs_path}
418+
419+ # Get installed packages list
420+ sudo sh -c "rpm --dbpath=${rootfs_path}/var/lib/rpm -qa --queryformat '%{NAME}\n' | sort > ${{ env.IMAGE_FILE }}.txt"
421+
422+ [ -f ${{ env.IMAGE_FILE }}.txt ] \
423+ && echo "got_pkgs_list=true" >> $GITHUB_ENV \
424+ || echo "got_pkgs_list=false" >> $GITHUB_ENV
425+
383426 - name : Test ${{ inputs.type }} ${{ inputs.variant }} image
384427 if : inputs.run_test == 'true'
385428 shell : bash
0 commit comments