Skip to content
Snippets Groups Projects
debos-runtimes.yaml 8.78 KiB
Newer Older
{{- $apt_debug := or .apt_debug "" -}}
{{- $architecture := or .architecture "amd64" -}}
{{- $suite := or .suite "stretch" -}}
{{- $flatpak_arch := or .flatpak_arch $architecture -}}
{{- $packages := or .packages "" -}}
{{- $post_script := or .post_script "" -}}
{{- $sdk := or .sdk "" -}}
{{- $sdk_packages := or .sdk_packages "" -}}
{{- $sdk_post_script := or .sdk_post_script "" -}}
{{- $platform_post_script := or .platform_post_script "" -}}
{{- $strip_source_version_suffix := or .strip_source_version_suffix "" -}}
{{- $build_id := or .build_id "" -}}
{{- $variant := or .variant "" -}}
{{- $variant_id := or .variant_id "" -}}
{{- $ospack := or .ospack (printf "base-%s-%s.tar.gz" $suite $architecture) -}}
{{- $runtime := .runtime -}}
{{- $runtime_branch := or .runtime_branch "master" -}}
{{- $artifact_prefix := or .artifact_prefix (printf "%s-%s-%s" $runtime $flatpak_arch $runtime_branch) -}}
{{- $sysroot_prefix := or .sysroot_prefix (printf "%s-sysroot" $artifact_prefix) -}}
{{- $sysroot_tarball := or .sysroot_tarball "" -}}
{{- $ostree_prefix := or .ostree_prefix (printf "%s-runtime" $artifact_prefix) -}}
{{- $ostree_tarball := or .ostree_tarball (printf "%s.tar.gz" $ostree_prefix) -}}
{{- $sources_prefix := or .sources_prefix (printf "%s-sources" $artifact_prefix) -}}
{{- $sources_tarball := or .sources_tarball (printf "%s.tar.gz" $sources_prefix) -}}
{{- $debug_prefix := or .debug_prefix (printf "%s-debug" $artifact_prefix) -}}
{{- $debug_tarball := or .debug_tarball (printf "%s.tar.gz" $debug_prefix) -}}

architecture: {{ $architecture }}

actions:
  - action: unpack
    compression: gz
    file: {{ $ospack }}

  # TODO: This duplicates what we should have done in debos-base.yaml
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: disable-services
    chroot: false
    command: 'echo; "$RECIPEDIR/disable-services" "$ROOTDIR"'

  # TODO: This duplicates what we should have done in debos-base.yaml
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: clean-up-base
    chroot: false
    command: 'echo; "$RECIPEDIR/clean-up-base" "$ROOTDIR"'

  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: prepare-runtime
    chroot: false
    command: 'echo; "$RECIPEDIR/prepare-runtime" "$ROOTDIR"'

  {{ if $packages }}
Simon McVittie's avatar
Simon McVittie committed
    label: apt-install
    command: echo; $RECIPEDIR/apt-install {{ if $apt_debug }}--debug{{ end }} "$ROOTDIR" "$RECIPEDIR/runtimes/{{ $runtime }}/packages.yaml"

  # TODO: Everything before this step is common to the Platform and SDK

  # We do this as a separate step in case it involves removing any
  # of the common packages
  {{ if and $sdk $sdk_packages }}
Simon McVittie's avatar
Simon McVittie committed
    label: apt-install
    command: echo; $RECIPEDIR/apt-install {{ if $apt_debug }}--debug{{ end }} "$ROOTDIR" "$RECIPEDIR/runtimes/{{ $runtime }}/sdk_packages.yaml"

  {{ if not $sdk }}
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: platformize
    chroot: false
    command: 'echo; "$RECIPEDIR/platformize" "$ROOTDIR"'
  {{ end }}

Simon McVittie's avatar
Simon McVittie committed
    label: purge-conffiles
    command: 'echo; "$RECIPEDIR/purge-conffiles" "$ROOTDIR"'
  {{ if $post_script }}
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: post_script
    chroot: true
    script: '{{ $post_script }}'
  {{ end }}

  {{ if $sdk }}
  {{ if $sdk_post_script }}
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: sdk_post_script
    chroot: true
    script: '{{ $sdk_post_script }}'
  {{ end }}
  {{ else }}
  {{ if $platform_post_script }}
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: platform_post_script
    chroot: true
    script: '{{ $platform_post_script }}'
  {{ end }}
  {{ end }}

Simon McVittie's avatar
Simon McVittie committed
    label: purge-conffiles again
    command: 'echo; "$RECIPEDIR/purge-conffiles" "$ROOTDIR"'
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: write-manifest
    chroot: false
      "$RECIPEDIR/write-manifest" "$ROOTDIR"
      cp "$ROOTDIR/usr/manifest.dpkg" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.dpkg"
      cp "$ROOTDIR/usr/manifest.dpkg.built-using" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.dpkg.built-using"
      cp "$ROOTDIR/usr/manifest.deb822.gz" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.deb822.gz"

      if test -e "$ROOTDIR/usr/lib/os-release"; then
        sed -i -e '/^BUILD_ID=/d' -e '/^VARIANT=/d' -e '/^VARIANT_ID=/d' "$ROOTDIR/usr/lib/os-release"

        if test -n "{{ $build_id }}"; then
          echo 'BUILD_ID="{{ $build_id }}"' >> "$ROOTDIR/usr/lib/os-release"
        fi

        if test -n "{{ $variant }}"; then
          echo 'VARIANT="{{ $variant }}"' >> "$ROOTDIR/usr/lib/os-release"
        fi

        if test -n "{{ $variant_id }}"; then
          echo 'VARIANT_ID="{{ $variant_id }}"' >> "$ROOTDIR/usr/lib/os-release"
        fi

        cp "$ROOTDIR/usr/lib/os-release" "$ARTIFACTDIR/{{ $artifact_prefix }}.os-release.txt"
      fi

  {{ if $sdk }}
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: copy manifest from platform
    chroot: false
    command: 'echo; cp "$RECIPEDIR/manifest.dpkg.platform" "$ROOTDIR/usr"'
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: copy manifest from platform
    chroot: false
    command: 'echo; cp "$RECIPEDIR/manifest.dpkg.built-using.platform" "$ROOTDIR/usr"'
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: copy manifest from platform
    chroot: false
    command: 'echo; cp "$RECIPEDIR/manifest.platform.deb822.gz" "$ROOTDIR/usr"'
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: collect-source-code
    chroot: false
    command: 'echo; "$RECIPEDIR/collect-source-code" --strip-source-version-suffix="{{ $strip_source_version_suffix }}" "$ROOTDIR"'
  {{ else }}
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: copy manifest for SDK
    chroot: false
    command: 'echo; cp "$ROOTDIR/usr/manifest.dpkg" "$RECIPEDIR/manifest.dpkg.platform"'
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: copy manifest for SDK
    chroot: false
    command: 'echo; cp "$ROOTDIR/usr/manifest.dpkg.built-using" "$RECIPEDIR/manifest.dpkg.built-using.platform"'
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: copy manifest for SDK
    chroot: false
    command: 'echo; mv "$ROOTDIR/usr/manifest.deb822.gz" "$RECIPEDIR/manifest.platform.deb822.gz"'
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: dpkg --purge dpkg
    chroot: true
    command: 'echo; dpkg --purge --force-remove-essential --force-depends dpkg'
  {{ end }}

  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: usrmerge
    chroot: false
    command: 'echo; "$RECIPEDIR/usrmerge" "$ROOTDIR"'
  - action: overlay
    source: runtimes/{{ $runtime }}/overlay

  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: put-ldconfig-in-path
    chroot: true
    script: put-ldconfig-in-path

  - action: run
    label: clean-up-before-pack
    chroot: false
    command: 'echo; "$RECIPEDIR/clean-up-before-pack" "$ROOTDIR"'
  - action: run
    label: check uid/gid mapping
    chroot: true
    command: |
      set -e
      cd "$ROOTDIR"
      if test -n "$(find . -xdev -path ./script -prune -o '(' -uid +99 -o -gid +99 ')' -print)"; then
        echo "Warning: these files have a dynamically-allocated UID/GID"
        echo "         which could cause problems for schroot:"
        find . -xdev -path ./script -prune -o '(' -uid +99 -o -gid +99 ')' -ls
      fi

  - action: run
    label: pack sysroot tarball
    chroot: false
    command: >
      echo;
      tar -zcf "$ARTIFACTDIR/{{ $sysroot_tarball }}"
      --numeric-owner
      --sort=name
      -C "$ROOTDIR"
      --exclude="./script"
      --exclude="./src"
    label: symlink-alternatives
    script: symlink-alternatives
  {{ if $sdk }}
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: make-flatpak-friendly --sdk
    chroot: false
    command: 'echo; "$RECIPEDIR/make-flatpak-friendly" --sdk "$ROOTDIR"'
  {{ else }}
  - action: run
Simon McVittie's avatar
Simon McVittie committed
    label: make-flatpak-friendly
    chroot: false
    command: 'echo; "$RECIPEDIR/make-flatpak-friendly" "$ROOTDIR"'
  # TODO: Move zoneinfo, locales into extensions
  # TODO: Hook point for GL, instead of just Mesa
  # TODO: GStreamer extension
  # TODO: Icon theme, Gtk theme extension
  # TODO: VAAPI extension
  # TODO: SDK extension
  # TODO: ca-certificates extension to get newer certs?

  - action: run
    label: pack ostree tarball
    chroot: false
    command: >
      echo;
      tar -zcf "$ARTIFACTDIR/{{ $ostree_tarball }}"
      --numeric-owner
      --sort=name
      -C "$ROOTDIR"
      files metadata

  {{ if $sdk }}
  - action: run
    label: pack source code
    chroot: false
    command: >
      echo;
      tar -zcf "$ARTIFACTDIR/{{ $sources_tarball }}"
      --numeric-owner
      --sort=name
      --transform="s,^./,,"
      -C "$ROOTDIR/src"
      .

  - action: run
    label: pack debug symbols
    chroot: false
    command: >
      echo;
      tar -zcf "$ARTIFACTDIR/{{ $debug_tarball }}"
      --numeric-owner
      --sort=name
      --transform="s,^./,,"
      -C "$ROOTDIR/debug"
      .

  - action: run
    label: list of missing source code
    chroot: false
    command: >
      test ! -e "$ROOTDIR/src/MISSING.txt" ||
      cp -v "$ROOTDIR/src/MISSING.txt"
      "$ARTIFACTDIR/{{ $sources_prefix }}.MISSING.txt"
  {{ end }}