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

build: add and use TARNAME instead of NAME for paths #5310

Merged
merged 5 commits into from
Aug 14, 2022

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented Aug 12, 2022

PACKAGE_TARNAME is the same as PACKAGE_NAME but normalized, so it should
be safer to use in paths. For example, on a downstream project, if
spaces or shell metacharacters are added to the package name, a path
that uses PACKAGE_TARNAME should keep working.

From the manual of GNU Autoconf (version 2.69):

-- Macro: AC_INIT (PACKAGE, VERSION, [BUG-REPORT], [TARNAME], [URL])
Process any command-line arguments and perform initialization and
verification.

 Set the name of the PACKAGE and its VERSION.  These are typically
 used in '--version' support, including that of 'configure'.  The
 optional argument BUG-REPORT should be the email to which users
 should send bug reports.  The package TARNAME differs from
 PACKAGE: the latter designates the full package name (e.g., 'GNU
 Autoconf'), while the former is meant for distribution tar ball
 names (e.g., 'autoconf').  It defaults to PACKAGE with 'GNU '
 stripped, lower-cased, and all characters other than
 alphanumerics and underscores are changed to '-'.

Note also that by default (on autoconf v2.69), DOCDIR=@docdir@ in
config.mk.in expands to the following in config.mk:

DOCDIR=${datarootdir}/doc/${PACKAGE_TARNAME}

@kmk3 kmk3 marked this pull request as draft August 12, 2022 20:39
Move it to the bottom, near other compilation-related flags.
Move up the variables that are defined in the `AC_INIT` call on
configure.ac.

And put VERSION last, to match the usual `$(NAME)-$(VERSION)` usage.
To match other similar variables, such as datarootdir and mandir.
That expands to `@PACKAGE_TARNAME@`, similar to the existing
PACKAGE_TARNAME variable.

To make it easier to use (and read) and to be more consistent with the
surrounding variables (NAME and VERSION).

Note that the original PACKAGE_TARNAME is still needed, as by default
(on autoconf v2.69) `docdir=@DocDir@` in config.mk.in expands to the
following in config.mk:

    docdir=${datarootdir}/doc/${PACKAGE_TARNAME}
PACKAGE_TARNAME is the same as PACKAGE_NAME but normalized, so it should
be safer to use in paths.  For example, on a downstream project, if
spaces or shell metacharacters are added to the package name, a path
that uses PACKAGE_TARNAME should keep working.

From the manual of GNU Autoconf (version 2.69):

>  -- Macro: AC_INIT (PACKAGE, VERSION, [BUG-REPORT], [TARNAME], [URL])
>      Process any command-line arguments and perform initialization and
>      verification.
>
>      Set the name of the PACKAGE and its VERSION.  These are typically
>      used in '--version' support, including that of 'configure'.  The
>      optional argument BUG-REPORT should be the email to which users
>      should send bug reports.  The package TARNAME differs from
>      PACKAGE: the latter designates the full package name (e.g., 'GNU
>      Autoconf'), while the former is meant for distribution tar ball
>      names (e.g., 'autoconf').  It defaults to PACKAGE with 'GNU '
>      stripped, lower-cased, and all characters other than
>      alphanumerics and underscores are changed to '-'.

Note also that by default (on autoconf v2.69), `docdir=@DocDir@` in
config.mk.in expands to the following in config.mk:

    docdir=${datarootdir}/doc/${PACKAGE_TARNAME}
@kmk3
Copy link
Collaborator Author

kmk3 commented Aug 14, 2022

Partial error log of build_and_test from
https://github.com/netblue30/firejail/runs/7801934320:

cd sysutils && ./sysutils.sh 2>&1 | tee sysutils.log
[...]
/usr/bin/tar
TESTING: tar
spawn /bin/bash
firejail /bin/tar -cjvf firejail_t2 /usr/share/doc/firejail
runner@fv-az357-462:~/work/firejail/firejail/test/sysutils$ 
< /bin/tar -cjvf firejail_t2 /usr/share/doc/firejail        ��������
/bin/tar: Removing leading `/' from member names
/bin/tar: /usr/share/doc/firejail: Cannot stat: No such file or directory
/bin/tar: Exiting with failure status due to previous errors
runner@fv-az357-462:~/work/firejail/firejail/test/sysutils$ TESTING ERROR 1.1

[...]

cd sysutils && grep -a TESTING sysutils.log && ! grep -a -q "TESTING ERROR" sysutils.log
TESTING: cpio
TESTING: gzip
TESTING: xzdec
TESTING: xz
TESTING: less
Press RETURN to continue TESTING SKIP 1.2
TESTING: file
TESTING: tar
runner@fv-az357-462:~/work/firejail/firejail/test/sysutils$ TESTING ERROR 1.1
TESTING: ping
TESTING SKIP: no internet connection
make[1]: *** [Makefile:6: sysutils] Error 1
make: *** [Makefile:266: test-sysutils] Error 2
make[1]: Leaving directory '/home/runner/work/firejail/firejail/test'
##[error]Process completed with exit code 2.
Post job cleanup.

Likely reason: @docdir@ references ${PACKAGE_TARNAME}, so the
PACKAGE_TARNAME variable cannot simply be renamed to TARNAME.

Updated and force-pushed.

@kmk3 kmk3 changed the title build: use TARNAME instead of NAME for paths build: add and use TARNAME instead of NAME for paths Aug 14, 2022
@kmk3 kmk3 marked this pull request as ready for review August 14, 2022 05:28
@netblue30 netblue30 merged commit 11e06fb into netblue30:master Aug 14, 2022
@netblue30
Copy link
Owner

all in, thanks!

@kmk3 kmk3 deleted the build-use-tarname branch August 15, 2022 02:51
kmk3 added a commit that referenced this pull request Aug 18, 2022
@kmk3
Copy link
Collaborator Author

kmk3 commented Aug 20, 2022

$ git show --pretty='%s%n%n%b---' 3bb8064

config.mk.in: move basic variables to the top

Move up the variables that are defined in the `AC_INIT` call on
configure.ac.

And put VERSION last, to match the usual `$(NAME)-$(VERSION)` usage.
---

diff --git a/config.mk.in b/config.mk.in
index fdab92cb5..2f02c42eb 100644
--- a/config.mk.in
+++ b/config.mk.in
@@ -7,6 +7,10 @@
 # up overriding the includer's intended default target (which by default is the
 # first target encountered).
 
+NAME=@PACKAGE_NAME@
+PACKAGE_TARNAME=@PACKAGE_TARNAME@
+VERSION=@PACKAGE_VERSION@
+
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
@@ -15,9 +19,6 @@ datarootdir=@datarootdir@
 mandir=@mandir@
 sysconfdir=@sysconfdir@
 
-VERSION=@PACKAGE_VERSION@
-NAME=@PACKAGE_NAME@
-PACKAGE_TARNAME=@PACKAGE_TARNAME@
 DOCDIR=@docdir@
 HAVE_APPARMOR=@HAVE_APPARMOR@
 HAVE_CONTRIB_INSTALL=@HAVE_CONTRIB_INSTALL@

Misc: I noticed that this is also the same order that ./configure uses:

# Identity of this package.
PACKAGE_NAME='firejail'
PACKAGE_TARNAME='firejail'
PACKAGE_VERSION='0.9.71'
PACKAGE_STRING='firejail 0.9.71'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done (on RELNOTES)
Development

Successfully merging this pull request may close these issues.

2 participants