Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
tox.ini: build/bin/write-dockerfile.sh: Instead matching TYPE_PATTERN…
Browse files Browse the repository at this point in the history
…, use "sage -package list $SAGE_PACKAGE_LIST_ARGS"
  • Loading branch information
Matthias Koeppe committed Nov 23, 2020
1 parent 0db7963 commit ef2ce1a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
32 changes: 13 additions & 19 deletions build/bin/write-dockerfile.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
#! /usr/bin/env bash
#! /usr/bin/env bash -x
## Write a Dockerfile to stdout that tests that the packages listed in the debian.txt/fedora.txt files of standard spkg exist
## and satisfy the requirements tested by spkg-configure.m4
## This is called by $SAGE_ROOT/tox.ini
set -e
SYSTEM="${1:-debian}"
shopt -s extglob
TYPE_PATTERN="${2:-standard}"
SAGE_PACKAGE_LIST_ARGS="${2:- --has-file=spkg-configure.m4 :standard:}"
WITH_SYSTEM_SPKG="${3:-yes}"
IGNORE_MISSING_SYSTEM_PACKAGES="${4:-no}"
#
STRIP_COMMENTS="sed s/#.*//;"
SAGE_ROOT=.
SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} $SAGE_ROOT/build/pkgs/$SYSTEM{,-bootstrap}.txt))
export PATH="$SAGE_ROOT"/build/bin:$PATH
SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} "$SAGE_ROOT"/build/pkgs/$SYSTEM{,-bootstrap}.txt))
CONFIGURE_ARGS="--enable-option-checking "
for PKG_SCRIPTS in build/pkgs/*; do
for PKG_BASE in $($SAGE_ROOT/sage -package list --has-file=distros/$SYSTEM.txt $SAGE_PACKAGE_LIST_ARGS); do
PKG_SCRIPTS="$SAGE_ROOT"/build/pkgs/$PKG_BASE
if [ -d $PKG_SCRIPTS ]; then
PKG_BASE=$(basename $PKG_SCRIPTS)
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/distros/$SYSTEM.txt
if [ -f $PKG_SCRIPTS/type -a -f $SYSTEM_PACKAGES_FILE -a -f $PKG_SCRIPTS/spkg-configure.m4 ]; then
PKG_TYPE=$(cat $PKG_SCRIPTS/type)
PKG_SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE))
if [ -n "PKG_SYSTEM_PACKAGES" ]; then
case "$PKG_TYPE" in
$TYPE_PATTERN)
SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES"
if [ -f $PKG_SCRIPTS/spkg-configure.m4 ]; then
CONFIGURE_ARGS+="--with-system-$PKG_BASE=${WITH_SYSTEM_SPKG} "
fi
;;
esac
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/distros/$SYSTEM.txt
PKG_SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE))
if [ -n "PKG_SYSTEM_PACKAGES" ]; then
SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES"
if [ -f $PKG_SCRIPTS/spkg-configure.m4 ]; then
CONFIGURE_ARGS+="--with-system-$PKG_BASE=${WITH_SYSTEM_SPKG} "
fi
fi
fi
fi
done
echo "# Automatically generated by SAGE_ROOT/build/bin/write-dockerfile.sh"
Expand Down
6 changes: 3 additions & 3 deletions src/doc/en/developer/portability_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ Generating Dockerfiles
Sage also provides a script for generating a ``Dockerfile``, which is
a recipe for automatically building a new image::

[mkoeppe@sage sage]$ build/bin/write-dockerfile.sh debian "@(standard|optional)" > Dockerfile
[mkoeppe@sage sage]$ build/bin/write-dockerfile.sh debian ":standard: :optional:" > Dockerfile

(The second argument is passed to ``sage -package list`` to find packages for the listed package types.)

(The second argument is a bash extglob pattern for the package type.)

.. this interface should be improved obviously. See #29146 - Refactor tox.ini and build/bin/write_dockerfile.sh
The ``Dockerfile`` instructs the command ``docker build`` to build a
Expand Down
9 changes: 4 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ setenv =
# and ignoring errors. We use that to take care of old versions of distributions.
IGNORE_MISSING_SYSTEM_PACKAGES=no
# What system packages should be installed. Default: All standard packages with spkg-configure.
# These are bash extglob patterns.
TYPE_PATTERN=standard
minimal: TYPE_PATTERN=minimal
maximal: TYPE_PATTERN=@(standard|optional)
SAGE_PACKAGE_LIST_ARGS=--has-file=spkg-configure.m4 :standard:
minimal: SAGE_PACKAGE_LIST_ARGS=_prereq _bootstrap _toolchain
maximal: SAGE_PACKAGE_LIST_ARGS=:standard: :optional:
# local envs need HOME set, also Docker 19.03 needs HOME
{local,docker}: HOME={envdir}
# for local envs we can guess the package system if it is not provided as a factor
Expand Down Expand Up @@ -427,7 +426,7 @@ commands =
local: bash -c 'if [ ! -d prefix -o -L prefix ]; then rm -f prefix; ln -sf {envdir}/local prefix; fi'

##commands =
docker: bash -c 'build/bin/write-dockerfile.sh {env:SYSTEM} "{env:TYPE_PATTERN:}" {env:WITH_SYSTEM_SPKG} {env:IGNORE_MISSING_SYSTEM_PACKAGES} > {envdir}/Dockerfile'
docker: bash -c 'build/bin/write-dockerfile.sh {env:SYSTEM} "{env:SAGE_PACKAGE_LIST_ARGS:}" {env:WITH_SYSTEM_SPKG} {env:IGNORE_MISSING_SYSTEM_PACKAGES} > {envdir}/Dockerfile'
# From https://hub.docker.com/r/multiarch/ubuntu-core/
# configure binfmt-support on the Docker host (works locally or remotely, i.e: using boot2docker)
docker-{arm64,armhf}: docker run --rm --privileged multiarch/qemu-user-static:register --reset
Expand Down

0 comments on commit ef2ce1a

Please sign in to comment.