Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sdh_install helper function to sage-dist-helpers #25039

Closed
embray opened this issue Mar 27, 2018 · 22 comments
Closed

Add sdh_install helper function to sage-dist-helpers #25039

embray opened this issue Mar 27, 2018 · 22 comments

Comments

@embray
Copy link
Contributor

embray commented Mar 27, 2018

Adds a new `sdh_install` helper function:

This is like a very simplified version of the `install` program, and is
intended for use by packages whose spkg-install just copies some files (or
more complex packages that copy some files as one of its steps).  The
majority of its functionality is just in ensuring that the full destination
path exists, and to provide some error checking.  This replaces some
patterns that occur frequently in some spkg-installs.

Also updates the mathjax and thebe packages as two examples of its usage (this implements #24024 for those packages).

Component: build

Keywords: destdir mathjax thebe

Author: Erik Bray

Branch/Commit: 0f848c3

Reviewer: Jeroen Demeyer

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

@embray embray added this to the sage-8.2 milestone Mar 27, 2018
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 27, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

330e618Introduce SAGE_DESTDIR_LOCAL variable
9d14972Don't install gcc as part of gfortran
5f8549eMerge branch 'u/jdemeyer/gfortran_breaks_parallel_build' into u/embray/build/sdh_install_files
22c3e9efix bug in handling of the -T flag--it was as if it was always set

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 27, 2018

Changed commit from 6a4e33a to 22c3e9e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 27, 2018

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

6c8bd46fix bug in handling of the -T flag--it was as if it was always set
6dcb880fix bug that can occur in repeated invocations of sdh_install in the same script

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 27, 2018

Changed commit from 22c3e9e to 6dcb880

@jdemeyer
Copy link

comment:4
  1. I don't really understand the point of
    if [ $# -eq 0 ]; then
        sdh_die "At least a source and destination file are required"
    fi

since it would fail anyway later and no error message would be given for sdh_install -T.

  1. It looks strange to put this in an else block, it's just part of the normal flow of execution:
    else
        dest="${SAGE_DESTDIR}$dest"
    fi
  1. I seem to recall that cp -R is more portable than cp -r. So unless you have a good reason for using cp -r, I recommend cp -R.

  2. For consistency, I would start all sdh_die messages with Error:

  3. echo "Installing files for ${PKG_NAME}:" looks like unneeded verbosity. I would drop that.

  4. If mkdir or cp fails, it already prints an error message, so I don't need that we need sdh_die for that. I would just write cp ... || exit $?.

@embray
Copy link
Contributor Author

embray commented Mar 28, 2018

comment:5

Replying to @jdemeyer:

  1. I don't really understand the point of
    if [ $# -eq 0 ]; then
        sdh_die "At least a source and destination file are required"
    fi

since it would fail anyway later and no error message would be given for sdh_install -T.

I mean, it will still fail for sdh_install -T because the $src variable will be empty. I thought an explicit check of "there are arguments" would enhance clarity but in retrospect I agree it's superfluous.

  1. It looks strange to put this in an else block, it's just part of the normal flow of execution:
    else
        dest="${SAGE_DESTDIR}$dest"
    fi

Yep. I think that was just the result of remolding of slightly different logic.

  1. I seem to recall that cp -R is more portable than cp -r. So unless you have a good reason for using cp -r, I recommend cp -R.

I suspect it's not really a problem for us since I've already seen cp -r in some of the spkg-installs I've used this in--including standard packages. If that were a problem for a platform we care about it would have come up by now. However, I seem to recall the same now that you mention it, so I could change it.

  1. For consistency, I would start all sdh_die messages with Error:

+1

  1. echo "Installing files for ${PKG_NAME}:" looks like unneeded verbosity. I would drop that.

+1 Some of the other sdh_ commands had some kind of message like this so I put it in for consistency. But after trying this on a few packages it hasn't been too helpful (especially in cases where there are multiple sdh_install calls in the package).

  1. If mkdir or cp fails, it already prints an error message, so I don't need that we need sdh_die for that. I would just write cp ... || exit $?.

A lot of the code this function is replacing was also adding its own error messages on top of mkdir and/or cp, so this was just carried over from that. In most cases those programs' error messages should be sufficient though.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 28, 2018

Changed commit from 6dcb880 to 42726a2

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 28, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

42726a2various minor review comments

@jdemeyer
Copy link

comment:8

Wait... did you actually agree with all my comments? :-)

@jdemeyer
Copy link

Reviewer: Jeroen Demeyer

@embray
Copy link
Contributor Author

embray commented Mar 29, 2018

comment:9

Replying to @jdemeyer:

Wait... did you actually agree with all my comments? :-)

Fair enough--but it's not like I set out to disagree with you. I thought they were all reasonable enough :)

@jdemeyer
Copy link

@jdemeyer
Copy link

New commits:

fa991casdh_install_files -> sdh_install in error messages

@jdemeyer
Copy link

Changed commit from 42726a2 to fa991ca

@embray
Copy link
Contributor Author

embray commented Apr 11, 2018

comment:12

Thanks for catching that. It was originally called sdh_install_files but I decided to shorten it later.

@embray
Copy link
Contributor Author

embray commented Apr 18, 2018

@embray
Copy link
Contributor Author

embray commented Apr 18, 2018

comment:13

Just rebased on current develop.


New commits:

27a44b4Adds a new sdh_install helper function:
0bbff00fix bug in handling of the -T flag--it was as if it was always set
7d09c66fix bug that can occur in repeated invocations of sdh_install in the same script
598112bvarious minor review comments
dbd9ca6sdh_install_files -> sdh_install in error messages

@embray
Copy link
Contributor Author

embray commented Apr 18, 2018

Changed commit from fa991ca to dbd9ca6

@embray embray removed this from the sage-8.2 milestone Apr 18, 2018
@embray embray added this to the sage-8.3 milestone Apr 18, 2018
@vbraun
Copy link
Member

vbraun commented May 9, 2018

comment:14

Merge conflict

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 17, 2018

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

b0b38c2Adds a new sdh_install helper function:
852cb5ffix bug in handling of the -T flag--it was as if it was always set
5f7cd30fix bug that can occur in repeated invocations of sdh_install in the same script
daa37d5various minor review comments
0f848c3sdh_install_files -> sdh_install in error messages

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 17, 2018

Changed commit from dbd9ca6 to 0f848c3

@vbraun
Copy link
Member

vbraun commented May 18, 2018

Changed branch from u/embray/build/sdh_install_files to 0f848c3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants