aws / aws/aws-cli

Building from source: DESTDIR doesn't produce portable installation

Open
#8,467 6 comments 1 reaction 0 assignees View on GitHub
bug installation needs-reproduction p2
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the bug

In regard to building & installing the v2 CLI from source, the [recommended behaviour of the `DESTDIR` option][makedoc] isn't honored in several places:

* The `$prefix/bin/aws -> $prefix/lib/aws-cli/bin/aws` symlink (and likewise for `aws_completer`)

* The script interpreter of `$prefix/lib/aws-cli/bin/aws` (and likewise for `aws_completer`)

[makedoc]: https://www.gnu.org/software/make/manual/html_node/DESTDIR.html#DESTDIR

### Expected Behavior

* The symlink created at `$DESTDIR/$prefix/bin/aws` should point to `$prefix/lib/aws-cli/bin/aws`.

* The first line of `$DESTDIR/$prefix/lib/aws-cli/bin/aws` should be `#!$prefix/lib/aws-cli/bin/python`.

More generally, the contents of `$DESTDIR` should not themselves contain any references to `$DESTDIR`, so that it's possible to copy the contents of this directory to another machine's root filesystem (typically via a RPM/DEB/etc) and still end up with a working installation.

### Current Behavior

* `$DESTDIR/$prefix/bin/aws` points to `$DESTDIR/$prefix/lib/aws-cli/bin/aws`, so this will be a broken symlink if `$DESTDIR` contents are packaged up and installed onto another machine.

* `$DESTDIR/$prefix/lib/aws-cli/bin/aws`'s first line is `#!$DESTDIR/$prefix/...`, which won't exist if `$DESTDIR` contents are packaged up and installed onto another machine.

### Reproduction Steps

```
$ git checkout 2.15.6
$ ./configure --prefix=/usr/local --with-download-deps
...
$ make
...
$ make DESTDIR=$PWD/install_staging install
...
$ readlink ./install_staging/usr/local/bin/aws
/home/kdavis/checkouts/github/aws/aws-cli/install_staging/usr/local/lib/aws-cli/bin/aws
$ head -1 ./install_staging/usr/local/lib/aws-cli/bin/aws
#!/home/kdavis/checkouts/github/aws/aws-cli/install_staging/usr/local/lib/aws-cli/bin/python
```

### Possible Solution

Symlinks can be trivially fixed by making them relative.

The script interpreter must be an absolute path though, so this might require introducing more awareness of `MOCKDEST` into the build scripts.

### Additional Information/Context

_No response_

### CLI version used

2.15.6

### Environment details (OS name and version, etc.)

Linux - RHEL 9

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.