File: create_container_package_list

package info (click to toggle)
obs-build 20210120-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,080 kB
  • sloc: perl: 11,428; sh: 3,340; ansic: 285; makefile: 172
file content (32 lines) | stat: -rwxr-xr-x 956 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

container="$1"

if test -z "$container" ; then
  echo "usage: create_container_package_list <container>"
  exit 1
fi
if ! test -s "$container" ; then
  echo "no such container: $container" >&2
  exit 1
fi

tmpdir=$(mktemp -d)
trap "rm -rf $tmpdir" EXIT

case "$container" in
  *.tar) cat < "$container" > $tmpdir/cont ;;
  *.tar.gz) gunzip < "$container" > $tmpdir/cont ;;
  *.tar.xz) xzdec < "$container" > $tmpdir/cont ;;
  *) echo "unsuppored container name $container" >&2 ; exit 1 ;;
esac

skopeo copy docker-archive:$tmpdir/cont oci:$tmpdir/image:latest >/dev/null
rm -f $tmpdir/cont
umoci unpack --image $tmpdir/image:latest $tmpdir/unpack >/dev/null
if test -x "$tmpdir/unpack/rootfs/usr/bin/rpm" ; then
    chroot $tmpdir/unpack/rootfs rpm -qa --qf '[%{NAME}|%{EPOCH}|%{VERSION}|%{RELEASE}|%{ARCH}|%{DISTURL}\n]'
else
    rpm --root "$tmpdir/unpack/rootfs" -qa --qf '[%{NAME}|%{EPOCH}|%{VERSION}|%{RELEASE}|%{ARCH}|%{DISTURL}\n]'
fi