canonical / rockcraft

Tool to create OCI Images using the language from Snapcraft and Charmcraft.
GNU General Public License v3.0
32 stars 41 forks source link

Broken Symlinks when Ubuntu 24.04 with Python plugin and `override-prime` is used #664

Open alithethird opened 1 month ago

alithethird commented 1 month ago

Bug Description

The fix for Ubuntu 24.04 with Python plugin doesn't work when override-prime is used. Doesn't even work when we use craftctl default in the override-prime.

To Reproduce

Write a rock with Ubuntu 24.04 and Python plugin and do something in override-prime.

Environment

Multipass Ubuntu 22.04 Rockcraft 1.5.3

rockcraft.yaml

# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

name: indico
summary: Indico rock
description: Indico OCI image for the Indico charm
version: "1.0"
base: ubuntu@24.04
build-base: ubuntu@24.04
license: Apache-2.0
platforms:
  amd64:
parts:
  add-user:
    plugin: nil
    overlay-script: |
      chmod 755 $CRAFT_OVERLAY/etc
      groupadd -R $CRAFT_OVERLAY --gid 2000 indico
      useradd -R $CRAFT_OVERLAY --system --gid 2000 --uid 2000 --home /srv/indico indico
  indico:
    plugin: python
    build-environment:
      - UWSGI_EMBED_PLUGINS: stats_pusher_statsd
    python-packages:
      - setuptools
      - wheel
      - indico==3.3.1
      - indico-plugin-payment-paypal==3.3
      - indico-plugin-piwik
      - indico-plugin-storage-s3
      - python3-saml
      - uwsgi
      - ./anonymize
      - ./autocreate
    source: plugins
    build-packages:
      - build-essential
      - libpq-dev
      - libsasl2-dev
      - libxmlsec1-dev
      - pkg-config
      - wget
    stage-packages:
      - python3-venv
      - python3-dev
      - build-essential
      - ca-certificates
      - git-core
      - libglib2.0-data
      - libpq-dev
      - libsasl2-dev
      - locales
      - logrotate
      - pkg-config
      - postgresql-client
      - shared-mime-info
      - texlive-fonts-recommended
      - texlive-plain-generic
      - texlive-xetex
      - libpangocairo-1.0-0 # required for python3.12
    overlay-packages:
      - libxmlsec1-dev
    stage-snaps:
      - celery-prometheus-exporter/latest/edge
      - gtrkiller-statsd-prometheus-exporter/latest/edge
    override-prime: |
      mkdir -p --mode=775 $CRAFT_PART_INSTALL/srv/indico/{archive,cache,custom,etc,log,tmp}
      cp $CRAFT_PART_INSTALL/lib/python3.12/site-packages/indico/web/indico.wsgi $CRAFT_PART_INSTALL/srv/indico/indico.wsgi
      cp -R $CRAFT_PART_INSTALL/lib/python3.12/site-packages/indico/web/static $CRAFT_PART_INSTALL/srv/indico/
      chown -R 2000:2000 $CRAFT_PART_INSTALL/srv/indico
      cp /etc/ssl/certs/ca-certificates.crt  $CRAFT_PART_INSTALL/etc/ssl/certs/ca-certificates.crt
      craftctl default
  copy-config:
    plugin: dump
    source: .
    organize:
      start-indico.sh: srv/indico/start-indico.sh
      etc/logrotate.conf: srv/indico/logrotate.conf
    permissions:
      - owner: 2000
        group: 2000
      - path: srv/indico/start-indico.sh
        mode: "544"
      - path: etc/
        mode: "755"
    prime:
      - etc/*
      - srv/indico/start-indico.sh
      - srv/indico/logrotate.conf

Relevant log output

.
tigarmo commented 1 month ago

It's an unfortunate limitation of override-prime today. However, your specific example is strange to me; it overrides prime to do manipulations on the part's install dir, which is used during the build. Is that intentional? Can you override build instead?

alithethird commented 1 month ago

We were using override-prime with Ubuntu 22.04 version so I tried to keep it same but it failed. When I used override-stage it worked but did not try with override-build.

tigarmo commented 1 month ago

My observation was more on the fact that I can't see how that project is working - for example, is /srv/indico/indico.wsgi really present on the final rock?