Skip to content

Commit

Permalink
Switch to --package-metadata linker option
Browse files Browse the repository at this point in the history
  • Loading branch information
bluca authored and keszybz committed Nov 28, 2022
1 parent 2e972aa commit 767e108
Show file tree
Hide file tree
Showing 35 changed files with 231 additions and 1,211 deletions.
1 change: 0 additions & 1 deletion .github/super-linter-links/dh/dh_package_notes.pl

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/linter.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/tests.yml

This file was deleted.

25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@ ELF Package Notes Reference Implementation

## Description

This repository provides a script to generate an ELF note that can be
linked into compiled binaries (programs and shared libraries) to provide
metadata about the package for which the binary was compiled.
This repository provides RPM and DEB packaging tools to generate an ELF note
that will be linked into compiled binaries (programs and shared libraries) to
provide metadata about the package for which the binary was compiled.

See [Package Metadata for Core Files](https://systemd.io/COREDUMP_PACKAGE_METADATA/)
See [Package Metadata for Core Files](https://systemd.io/ELF_PACKAGE_METADATA/)
for the overview and details.

We provide implementations in Python and POSIX shell, with compatible CLI
interfaces.
The new `--package-metadata` option provided by bfd, gold, mold and lld is used.

## Requirements

### generate-package-notes.py

* python3 (>= 3.5)
* python3-simplejson
* binutils (>= 2.38) [--readonly true]

### generate-package-notes.sh

* POSIX shell
* binutils (>= 2.38) [--readonly true]
* binutils (>= 2.39)
* mold (>= 1.3.0)
* lld (>= 15.0.0)
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package-notes (0.9) unstable; urgency=medium

* Switch to --package-metadata linker flag via specs file

-- Luca Boccassi <[email protected]> Sun, 27 Nov 2022 16:43:58 +0000

package-notes (0.8) unstable; urgency=medium

* use LONG instead of BYTEs for binary fields
Expand Down
13 changes: 6 additions & 7 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ Section: admin
Priority: optional
Rules-Requires-Root: no
Maintainer: Luca Boccassi <[email protected]>
Build-Depends: debhelper-compat (= 13), dh-exec,
Standards-Version: 4.6.0
Homepage: https://systemd.io/COREDUMP_PACKAGE_METADATA/
Build-Depends: debhelper-compat (= 13),
Standards-Version: 4.6.1
Homepage: https://systemd.io/ELF_PACKAGE_METADATA/
Vcs-Git: https://github.com/systemd/package-notes.git
Vcs-Browser: https://github.com/systemd/package-notes

Package: dh-package-notes
Architecture: all
Multi-Arch: foreign
Enhances: debhelper
Depends: ${misc:Depends}, ${perl:Depends}, debhelper,
Provides: dh-sequence-package-notes
Depends: ${misc:Depends}, debhelper,
Description: Debian Helper for adding package metadata to ELF binaries
Generate a linker script to add package metadata to the ELF binaries being
built. See: https://systemd.io/COREDUMP_PACKAGE_METADATA/
Provides a linker specs file to add package metadata to the ELF binaries being
built. See: https://systemd.io/ELF_PACKAGE_METADATA/
2 changes: 2 additions & 0 deletions debian/debian-package-notes.specs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*link:
+ --package-metadata={\"type\":\"deb\",\"os\":\"%:getenv(DEB_VENDOR \",\"name\":\"%:getenv(DEB_SOURCE_PACKAGE_NAME \",\"version\":\"%:getenv(DEB_SOURCE_PACKAGE_VERSION \",\"architecture\":\"%:getenv(DEB_HOST_ARCH \",\"debugInfoUrl\":\"%:getenv(DEBUGINFOD_URLS \"})))))
7 changes: 2 additions & 5 deletions debian/dh-package-notes.install
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/usr/bin/dh-exec
dh/dh_package_notes usr/bin
generate-package-notes.sh => usr/bin/generate-package-notes
dh/package_notes.pm usr/share/perl5/Debian/Debhelper/Sequence
dh/package-notes.mk usr/share/debhelper/dh_package_notes
debian/package-notes.mk usr/share/debhelper/dh_package_notes/
debian/debian-package-notes.specs usr/share/debhelper/dh_package_notes/
1 change: 0 additions & 1 deletion debian/dh-package-notes.manpages
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
debian/dh_package_notes.1
man/generate-package-notes.1
172 changes: 172 additions & 0 deletions debian/dh_package_notes.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "DH_PACKAGE_NOTES 1"
.TH DH_PACKAGE_NOTES 1 "2022-11-27"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
dh_package_notes \- Add package metadata to ELF header
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBdh_package_notes\fR
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fBdh_package_notes\fR provides a linker specs file to include package metadata in
\&\s-1ELF\s0 binaries built by packages.
.PP
The package metadata specification for \s-1ELF\s0 binaries can be found at
<https://systemd.io/ELF_PACKAGE_METADATA/>.
.PP
\&\fBdh_package_notes\fR provides a linker specs file at
\&\fB/usr/share/debhelper/dh_package_notes/debian\-package\-notes.specs\fR which can be
used by including \fB/usr/share/debhelper/dh_package_notes/debian\-package\-notes.mk\fR
at the dop of \fBdebian/rules\fR. This will export the right environment variables
that will result in a package note \s-1ELF\s0 section being added to all packaged \s-1ELF\s0
files, with the package type set to \fBdeb\fR, the package name and version set to
the source package name and version respectively, the \s-1OS\s0 set to \fBDebian\fR and
debuginfod \s-1URL\s0 set to \fBhttps://debuginfod.debian.net\fR. On Ubuntu, the \s-1OS\s0
will be set to \fBUbuntu\fR and debuginfod \s-1URL\s0 will be set to
\&\fBhttps://debuginfod.ubuntu.com\fR.
.PP
Note that it is not sufficient to build-depend on this package, the \fBinclude\fR
must be used at the top of \fBdebian/rules\fR for this to be enabled.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBdebhelper\fR\|(7)
.SH "AUTHOR"
.IX Header "AUTHOR"
Luca Boccassi <[email protected]>
16 changes: 16 additions & 0 deletions debian/package-notes.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: CC0-1.0
# Include from debian/rules to use with dh_package_notes.
# See dh_package_notes(1) for details
include /usr/share/dpkg/vendor.mk
ifeq (, $(filter nocheck, $(DEBUGINFOD_URLS)))
ifeq ($(DEB_VENDOR),Ubuntu)
export DEBUGINFOD_URLS=https://debuginfod.ubuntu.com
else
export DEBUGINFOD_URLS=https://debuginfod.debian.net
endif
endif
export DEB_SOURCE_PACKAGE_VERSION=$(shell dpkg-parsechangelog -S Version)
export DEB_SOURCE_PACKAGE_NAME=$(shell dpkg-parsechangelog -S Source)
export DEB_LDFLAGS_MAINT_APPEND+= -specs=/usr/share/debhelper/dh_package_notes/debian-package-notes.specs
export DEB_VENDOR

6 changes: 0 additions & 6 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,3 @@

%:
dh $@

execute_after_dh_auto_build:
pod2man $(CURDIR)/dh/dh_package_notes $(CURDIR)/debian/dh_package_notes.1

execute_after_dh_auto_clean:
rm -f $(CURDIR)/debian/dh_package_notes.1
Loading

0 comments on commit 767e108

Please sign in to comment.