Skip to content

Add a library of common helper functions for use in spkg-install #23160

@embray

Description

@embray

This idea has come up before but not been implemented. My implementation simply adds a collection of shell functions with names prefixed by sdh_ for Sage distribution helpers (this is somewhat inspired by, but much simpler than, the dh_ programs from the debhelper package in Debian).

These functions are exported by sage-spkg, and so are immediately usable by any spkg-build, spkg-install, or similar scripts executed from sage-spkg (these are still not required to be shell scripts, but as most are having such a library is convenient).

One piece of boilerplate I replaced with a function is the check in most spkg-installs for $SAGE_LOCAL. A downside to this is that if the script is run outside the correct environment, then rather than getting a useful error message we just get that sdh_check_vars is undefined. I have two thoughts on this:

  1. In general these scripts shouldn't be run directly in the first place. In the case that they are (such as testing) the person developing the package should have some awareness of the fact that these scripts are being run from sage-spkg and assume sage-env has been sourced.

  2. Most of the time these scripts are run, it's after they've been copied to a temporary build directory for the package. If nothing else, sage-spkg could create a wrapper around these scripts that automatically sets some default assumptions (such as sourcing sage-env and the new sage-dist-helpers).

In general, though, I think having a library of helper functions will be a big improvement to the consistency and legibility of theses scripts.

This ticket also updates the spkg-install for patch for demonstration purposes only. I don't intend with this to go on a mass rewriting of install scripts, but having this will be helpful for some other work (e.g. #22509, #22510).

Depends on #23179

Component: build

Author: Erik Bray

Branch/Commit: 48fe6ac

Reviewer: Jeroen Demeyer

Issue created by migration from https://trac.sagemath.org/ticket/23160

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions