This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=584d2a5575627f34dd796b550b09c590d34a79ae

commit 584d2a5575627f34dd796b550b09c590d34a79ae
Author: Guillem Jover <[email protected]>
AuthorDate: Wed May 20 18:32:33 2020 +0200

    dpkg-realpath: Add new program
    
    This program will be used by dpkg-maintscript-helper and any maintainter
    script that needs a realpath that can handle pathnames relative to the
    dpkg root directory.
---
 debian/changelog                        |  3 ++
 debian/dpkg.manpages                    |  1 +
 man/Makefile.am                         |  2 +
 man/{dpkg.cfg.pod => dpkg-realpath.pod} | 44 +++++++++++++------
 man/po/po4a.cfg                         |  1 +
 scripts/.gitignore                      |  1 +
 scripts/Makefile.am                     |  2 +
 scripts/dpkg-realpath.sh                | 78 +++++++++++++++++++++++++++++++++
 t/shellcheck.t                          |  1 +
 9 files changed, 119 insertions(+), 14 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index bcdac083e..24fee9959 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -34,6 +34,9 @@ dpkg (1.20.1) UNRELEASED; urgency=medium
   * dpkg, dpkg-query: Document missing options in --help output.
   * Unify ellipsis formatting in programs --help output.
   * Add Protected field support.
+  * dpkg-realpath: New program, to be used by dpkg-maintscript-helper, and
+    any maintainer script that needs a realpath that can handle pathnames
+    relative to the dpkg root directory.
   * Portability:
     - libdpkg: When using uselocale(), include <xlocale.h> for locale_t if
       the header is available. Needed on BSDs.
diff --git a/debian/dpkg.manpages b/debian/dpkg.manpages
index 0188a25a1..669a0104a 100644
--- a/debian/dpkg.manpages
+++ b/debian/dpkg.manpages
@@ -2,6 +2,7 @@ usr/share/man/*/dpkg-deb.1
 usr/share/man/*/dpkg-divert.1
 usr/share/man/*/dpkg-maintscript-helper.1
 usr/share/man/*/dpkg-query.1
+usr/share/man/*/dpkg-realpath.1
 usr/share/man/*/dpkg-split.1
 usr/share/man/*/dpkg-statoverride.1
 usr/share/man/*/dpkg-trigger.1
diff --git a/man/Makefile.am b/man/Makefile.am
index cd7aa022c..795a2f1a0 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -42,6 +42,7 @@ man_MANS = \
        dpkg-name.1 \
        dpkg-parsechangelog.1 \
        dpkg-query.1 \
+       dpkg-realpath.1 \
        dpkg-scanpackages.1 \
        dpkg-scansources.1 \
        dpkg-shlibdeps.1 \
@@ -115,6 +116,7 @@ EXTRA_DIST = \
        dpkg-name.pod \
        dpkg-parsechangelog.pod \
        dpkg-query.pod \
+       dpkg-realpath.pod \
        dpkg-scanpackages.pod \
        dpkg-scansources.pod \
        dpkg-shlibdeps.pod \
diff --git a/man/dpkg.cfg.pod b/man/dpkg-realpath.pod
similarity index 52%
copy from man/dpkg.cfg.pod
copy to man/dpkg-realpath.pod
index 3c931d61c..ae093bfbf 100644
--- a/man/dpkg.cfg.pod
+++ b/man/dpkg-realpath.pod
@@ -1,7 +1,6 @@
-# dpkg manual page - dpkg.cfg(5)
+# dpkg manual page - dpkg-realpath(1)
 #
-# Copyright © 2002 Wichert Akkerman <[email protected]>
-# Copyright © 2009, 2013, 2015 Guillem Jover <[email protected]>
+# Copyright © 2020 Guillem Jover <[email protected]>
 #
 # This is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,24 +19,41 @@
 
 =head1 NAME
 
-dpkg.cfg - dpkg configuration file
+dpkg-realpath - print the resolved pathname
+
+=head1 SYNOPSIS
+
+B<dpkg-realpath> [I<option>...] I<pathname>
 
 =head1 DESCRIPTION
 
-This file contains default options for dpkg. Each line contains a
-single option which is exactly the same as a normal command line
-option for dpkg except for the leading hyphens which are not used
-here. Quotes surrounding option values are stripped. Comments are
-allowed by starting a line with a hash sign (‘B<#>’).
+B<dpkg-realpath> is a tool to resolve a pathname.
+
+=head1 OPTIONS
+
+=over
+
+=item B<-?>, B<--help>
+
+Show the usage message and exit.
+
+=item B<--version>
+
+Show the version and exit.
+
+=back
+
+=head1 ENVIRONMENT
 
-=head1 FILES
+=over
 
-I<%PKGCONFDIR%/dpkg.cfg.d/[0-9a-zA-Z_-]*>
+=item B<DPKG_COLORS>
 
-I<%PKGCONFDIR%/dpkg.cfg>
+Sets the color mode.
+The currently accepted values are: B<auto> (default), B<always> and B<never>.
 
-I<~/.dpkg.cfg>
+=back
 
 =head1 SEE ALSO
 
-B<dpkg>(1).
+L<realpath(1)>.
diff --git a/man/po/po4a.cfg b/man/po/po4a.cfg
index 5cfc72f25..7379940fa 100644
--- a/man/po/po4a.cfg
+++ b/man/po/po4a.cfg
@@ -48,6 +48,7 @@
 [type:pod] dpkg-name.pod $lang:$lang/dpkg-name.pod
 [type:pod] dpkg-parsechangelog.pod $lang:$lang/dpkg-parsechangelog.pod
 [type:pod] dpkg-query.pod $lang:$lang/dpkg-query.pod
+[type:pod] dpkg-realpath.pod $lang:$lang/dpkg-realpath.pod
 [type:pod] dpkg-scanpackages.pod $lang:$lang/dpkg-scanpackages.pod
 [type:pod] dpkg-scansources.pod $lang:$lang/dpkg-scansources.pod
 [type:pod] dpkg-shlibdeps.pod $lang:$lang/dpkg-shlibdeps.pod
diff --git a/scripts/.gitignore b/scripts/.gitignore
index a93412826..f10602c23 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -12,6 +12,7 @@ dpkg-maintscript-helper
 dpkg-mergechangelogs
 dpkg-name
 dpkg-parsechangelog
+dpkg-realpath
 dpkg-scanpackages
 dpkg-scansources
 dpkg-shlibdeps
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index b43a2e4ee..b5679305f 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -16,6 +16,7 @@ bin_SCRIPTS = \
        dpkg-mergechangelogs \
        dpkg-name \
        dpkg-parsechangelog \
+       dpkg-realpath \
        dpkg-scanpackages \
        dpkg-scansources \
        dpkg-shlibdeps \
@@ -36,6 +37,7 @@ EXTRA_DIST = \
        dpkg-mergechangelogs.pl \
        dpkg-name.pl \
        dpkg-parsechangelog.pl \
+       dpkg-realpath.sh \
        dpkg-scanpackages.pl \
        dpkg-scansources.pl \
        dpkg-shlibdeps.pl \
diff --git a/scripts/dpkg-realpath.sh b/scripts/dpkg-realpath.sh
new file mode 100755
index 000000000..e150bdba1
--- /dev/null
+++ b/scripts/dpkg-realpath.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# Copyright © 2020 Guillem Jover <[email protected]>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+set -e
+
+PROGNAME=$(basename "$0")
+version="unknown"
+
+PKGDATADIR=scripts/sh
+
+. "$PKGDATADIR/dpkg-error.sh"
+
+show_version()
+{
+  cat <<END
+Debian $PROGNAME version $version.
+
+This is free software; see the GNU General Public License version 2 or
+later for copying conditions. There is NO warranty.
+END
+}
+
+show_usage()
+{
+  cat <<END
+Usage: $PROGNAME [<option>...] <pathname>
+
+Options:
+       --version      Show the version.
+  -?,  --help         Show this help message.
+END
+}
+
+setup_colors
+
+[ $# -eq 1 ] || badusage "missing pathname"
+
+while [ $# -ne 0 ]; do
+  case "$1" in
+  --version)
+    show_version
+    exit 0
+    ;;
+  --help|-\?)
+    show_usage
+    exit 0
+    ;;
+  --)
+    shift
+    pathname="$1"
+    ;;
+  --*)
+    badusage "unknown option: $1"
+    ;;
+  *)
+    pathname="$1"
+    ;;
+  esac
+  shift
+done
+
+realpath "$pathname"
+
+exit 0
diff --git a/t/shellcheck.t b/t/shellcheck.t
index 9428eac69..6872ea95d 100644
--- a/t/shellcheck.t
+++ b/t/shellcheck.t
@@ -38,6 +38,7 @@ my @files = qw(
     debian/dpkg.cron.daily
     debian/dpkg.postrm
     scripts/dpkg-maintscript-helper.sh
+    scripts/dpkg-realpath.sh
 );
 my @shellcheck_opts = (
     '--exclude=SC1090', # Allow non-constant source.

-- 
Dpkg.Org's dpkg

Reply via email to