github.com/containers/podman/v5@v5.1.0-rc1/test/system/build-systemd-image (about)

     1  #!/bin/bash
     2  #
     3  # build-systemd-image - script for producing a test image with systemd
     4  #
     5  # Based on the build-testimage script. This script builds a fedora-based
     6  # image with systemd in it, for use in systemd-based tests.
     7  #
     8  
     9  # Podman binary to use
    10  PODMAN=${PODMAN:-$(pwd)/bin/podman}
    11  
    12  # Tag for this new image
    13  YMD=$(date +%Y%m%d)
    14  
    15  # git-relative path to this script
    16  create_script=$(cd $(dirname $0) && git ls-files --full-name $(basename $0))
    17  if [ -z "$create_script" ]; then
    18      create_script=$0
    19  fi
    20  create_script_rev=$(git describe --tags)
    21  
    22  # Creation timestamp, Zulu time
    23  create_time_t=$(date +%s)
    24  create_time_z=$(env TZ=UTC date --date=@$create_time_t +'%Y-%m-%dT%H:%M:%SZ')
    25  
    26  set -e
    27  
    28  # We'll need to create a Containerfile plus various other files to add in
    29  tmpdir=$(mktemp -t -d $(basename $0).tmp.XXXXXXX)
    30  cd $tmpdir
    31  echo $YMD >testimage-id
    32  
    33  cat >Containerfile <<EOF
    34  FROM registry.fedoraproject.org/fedora-minimal:39
    35  LABEL created_by="$create_script @ $create_script_rev"
    36  LABEL created_at=$create_time_z
    37  RUN microdnf install -y systemd tzdata && microdnf clean all && sed -i -e 's/.*LogColor.*/LogColor=no/' /etc/systemd/system.conf
    38  ADD testimage-id /home/podman/
    39  WORKDIR /home/podman
    40  CMD ["/bin/echo", "This image is intended for podman CI testing"]
    41  EOF
    42  
    43  # Start from scratch
    44  testimg_base=quay.io/libpod/systemd-image
    45  testimg=${testimg_base}:$YMD
    46  $PODMAN manifest rm $testimg &> /dev/null || true
    47  $PODMAN rmi -f $testimg &> /dev/null || true
    48  
    49  # Arch emulation on Fedora requires the qemu-user-static package.
    50  declare -a arches=(amd64 arm64 ppc64le s390x)
    51  n_arches=${#arches[*]}
    52  i=0
    53  while [[ $i -lt $n_arches ]]; do
    54      arch=${arches[$i]}
    55      i=$((i+1))
    56      echo
    57      echo "Building: $arch ($i of $n_arches)"
    58      $PODMAN build \
    59              --arch=$arch \
    60              --squash-all \
    61              --timestamp=$create_time_t \
    62              --manifest=$testimg \
    63              .
    64  done
    65  
    66  # Clean up
    67  cd /tmp
    68  rm -rf $tmpdir
    69  
    70  # Tag image and push (all arches) to quay.
    71  cat <<EOF
    72  
    73  If you're happy with this image, run:
    74  
    75     podman manifest push --all  ${testimg} docker://${testimg}
    76  EOF