summaryrefslogtreecommitdiff
path: root/hack
diff options
context:
space:
mode:
Diffstat (limited to 'hack')
-rwxr-xr-xhack/apparmor_tag.sh2
-rwxr-xr-xhack/btrfs_installed_tag.sh2
-rwxr-xr-xhack/btrfs_tag.sh2
-rwxr-xr-xhack/check_root.sh2
-rwxr-xr-xhack/get_ci_vm.sh2
-rwxr-xr-xhack/get_release_info.sh2
-rwxr-xr-xhack/golangci-lint.sh3
-rwxr-xr-xhack/install_bats.sh2
-rwxr-xr-xhack/install_catatonit.sh3
-rwxr-xr-xhack/install_golangci.sh2
-rwxr-xr-xhack/libdm_tag.sh2
-rwxr-xr-xhack/man-page-checker2
-rwxr-xr-xhack/podman-commands.sh2
-rwxr-xr-xhack/podmanv2-retry2
-rwxr-xr-xhack/selinux_tag.sh2
-rwxr-xr-xhack/tree_status.sh2
-rwxr-xr-xhack/xref-helpmsgs-manpages138
17 files changed, 142 insertions, 30 deletions
diff --git a/hack/apparmor_tag.sh b/hack/apparmor_tag.sh
index 0fd222210..794370e79 100755
--- a/hack/apparmor_tag.sh
+++ b/hack/apparmor_tag.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
if pkg-config libapparmor 2> /dev/null ; then
echo apparmor
fi
diff --git a/hack/btrfs_installed_tag.sh b/hack/btrfs_installed_tag.sh
index 357f33b8b..c4d99f377 100755
--- a/hack/btrfs_installed_tag.sh
+++ b/hack/btrfs_installed_tag.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
cc -E - > /dev/null 2> /dev/null << EOF
#include <btrfs/ioctl.h>
EOF
diff --git a/hack/btrfs_tag.sh b/hack/btrfs_tag.sh
index cc48504ab..59cb969ad 100755
--- a/hack/btrfs_tag.sh
+++ b/hack/btrfs_tag.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
cc -E - > /dev/null 2> /dev/null << EOF
#include <btrfs/version.h>
EOF
diff --git a/hack/check_root.sh b/hack/check_root.sh
index 203eae9d3..1f53887ff 100755
--- a/hack/check_root.sh
+++ b/hack/check_root.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
if ! [ $(id -u) = 0 ]; then
echo "Please run as root! '$@' requires root privileges."
exit 1
diff --git a/hack/get_ci_vm.sh b/hack/get_ci_vm.sh
index 05b7a4a6d..b37dba508 100755
--- a/hack/get_ci_vm.sh
+++ b/hack/get_ci_vm.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
diff --git a/hack/get_release_info.sh b/hack/get_release_info.sh
index c1c694a44..69cf8cd57 100755
--- a/hack/get_release_info.sh
+++ b/hack/get_release_info.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# This script produces various bits of metadata needed by Makefile. Using
# a script allows uniform behavior across multiple environments and
diff --git a/hack/golangci-lint.sh b/hack/golangci-lint.sh
index 8c81a3743..03c29c89a 100755
--- a/hack/golangci-lint.sh
+++ b/hack/golangci-lint.sh
@@ -1,6 +1,7 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
# Need to run linter twice to cover all the build tags code paths
+set -e
declare -A BUILD_TAGS
# TODO: add systemd tag
diff --git a/hack/install_bats.sh b/hack/install_bats.sh
index 00ded07a9..d30e3daf8 100755
--- a/hack/install_bats.sh
+++ b/hack/install_bats.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
diff --git a/hack/install_catatonit.sh b/hack/install_catatonit.sh
index 7fd7592a9..8837db3a8 100755
--- a/hack/install_catatonit.sh
+++ b/hack/install_catatonit.sh
@@ -1,7 +1,8 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
BASE_PATH="/usr/libexec/podman"
CATATONIT_PATH="${BASE_PATH}/catatonit"
CATATONIT_VERSION="v0.1.4"
+set -e
if [ -f $CATATONIT_PATH ]; then
echo "skipping ... catatonit is already installed"
diff --git a/hack/install_golangci.sh b/hack/install_golangci.sh
index 6ef8ce823..57cdd2e4d 100755
--- a/hack/install_golangci.sh
+++ b/hack/install_golangci.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
diff --git a/hack/libdm_tag.sh b/hack/libdm_tag.sh
index d1f83ba10..d3668aab1 100755
--- a/hack/libdm_tag.sh
+++ b/hack/libdm_tag.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
tmpdir="$PWD/tmp.$RANDOM"
mkdir -p "$tmpdir"
trap 'rm -fr "$tmpdir"' EXIT
diff --git a/hack/man-page-checker b/hack/man-page-checker
index d2cc6c6e1..45f9edbd1 100755
--- a/hack/man-page-checker
+++ b/hack/man-page-checker
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
# man-page-checker - validate and cross-reference man page names
#
diff --git a/hack/podman-commands.sh b/hack/podman-commands.sh
index da4d446aa..587cac782 100755
--- a/hack/podman-commands.sh
+++ b/hack/podman-commands.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
# Compare commands listed by 'podman help' against those in 'man podman'.
# Recurse into subcommands as well.
diff --git a/hack/podmanv2-retry b/hack/podmanv2-retry
index ea77486ff..1f3be0731 100755
--- a/hack/podmanv2-retry
+++ b/hack/podmanv2-retry
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
# podman-try - try running a command via PODMAN1; use PODMAN2 as fallback
#
diff --git a/hack/selinux_tag.sh b/hack/selinux_tag.sh
index ff80fda04..993630ad6 100755
--- a/hack/selinux_tag.sh
+++ b/hack/selinux_tag.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
if pkg-config libselinux 2> /dev/null ; then
echo selinux
fi
diff --git a/hack/tree_status.sh b/hack/tree_status.sh
index ac874a347..2f56cdcd3 100755
--- a/hack/tree_status.sh
+++ b/hack/tree_status.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
SUGGESTION="${SUGGESTION:-sync the vendor.conf and commit all changes.}"
diff --git a/hack/xref-helpmsgs-manpages b/hack/xref-helpmsgs-manpages
index 16b596589..7b617eed7 100755
--- a/hack/xref-helpmsgs-manpages
+++ b/hack/xref-helpmsgs-manpages
@@ -26,8 +26,14 @@ $| = 1;
my $Default_Podman = './bin/podman';
my $PODMAN = $ENV{PODMAN} || $Default_Podman;
+# Path to all doc files, including .rst and (down one level) markdown
+my $Docs_Path = 'docs/source';
+
# Path to podman markdown source files (of the form podman-*.1.md)
-my $Markdown_Path = 'docs/source/markdown';
+my $Markdown_Path = "$Docs_Path/markdown";
+
+# Global error count
+my $Errs = 0;
# END user-customizable section
###############################################################################
@@ -96,35 +102,38 @@ sub main {
my $help = podman_help();
my $man = podman_man('podman');
+ my $rst = podman_rst();
+
+ xref_by_help($help, $man);
+ xref_by_man($help, $man);
- my $retval = xref_by_help($help, $man)
- + xref_by_man($help, $man);
+ xref_rst($help, $rst);
- exit !!$retval;
+ exit !!$Errs;
}
+###############################################################################
+# BEGIN cross-referencing
+
##################
# xref_by_help # Find keys in '--help' but not in man
##################
sub xref_by_help {
my ($help, $man, @subcommand) = @_;
- my $errs = 0;
for my $k (sort keys %$help) {
if (exists $man->{$k}) {
if (ref $help->{$k}) {
- $errs += xref_by_help($help->{$k}, $man->{$k}, @subcommand, $k);
+ xref_by_help($help->{$k}, $man->{$k}, @subcommand, $k);
}
# Otherwise, non-ref is leaf node such as a --option
}
else {
my $man = $man->{_path} || 'man';
warn "$ME: podman @subcommand --help lists $k, but $k not in $man\n";
- ++$errs;
+ ++$Errs;
}
}
-
- return $errs;
}
#################
@@ -137,13 +146,11 @@ sub xref_by_help {
sub xref_by_man {
my ($help, $man, @subcommand) = @_;
- my $errs = 0;
-
# FIXME: this generates way too much output
for my $k (grep { $_ ne '_path' } sort keys %$man) {
if (exists $help->{$k}) {
if (ref $man->{$k}) {
- $errs += xref_by_man($help->{$k}, $man->{$k}, @subcommand, $k);
+ xref_by_man($help->{$k}, $man->{$k}, @subcommand, $k);
}
}
elsif ($k ne '--help' && $k ne '-h') {
@@ -175,13 +182,38 @@ sub xref_by_man {
next if "@subcommand" eq 'system' && $k eq 'service';
warn "$ME: podman @subcommand: $k in $man, but not --help\n";
- ++$errs;
+ ++$Errs;
}
}
+}
- return $errs;
+##############
+# xref_rst # Cross-check *.rst files against help
+##############
+sub xref_rst {
+ my ($help, $rst, @subcommand) = @_;
+
+ # Cross-check against rst (but only subcommands, not options).
+ # We key on $help because that is Absolute Truth: anything in podman --help
+ # must be referenced in an rst (the converse is not true).
+ for my $k (sort grep { $_ !~ /^-/ } keys %$help) {
+ # Check for subcommands, if any (eg podman system -> connection -> add)
+ if (ref $help->{$k}) {
+ xref_rst($help->{$k}, $rst->{$k}, @subcommand, $k);
+ }
+
+ # Check that command is mentioned in at least one .rst file
+ if (! exists $rst->{$k}{_desc}) {
+ my @podman = ("podman", @subcommand, $k);
+ warn "$ME: no link in *.rst for @podman\n";
+ ++$Errs;
+ }
+ }
}
+# END cross-referencing
+###############################################################################
+# BEGIN data gathering
#################
# podman_help # Parse output of 'podman [subcommand] --help'
@@ -249,6 +281,7 @@ sub podman_man {
or die "$ME: Cannot read $manpath: $!\n";
my $section = '';
my @most_recent_flags;
+ my $previous_subcmd = '';
while (my $line = <$fh>) {
chomp $line;
next unless $line; # skip empty lines
@@ -278,6 +311,11 @@ sub podman_man {
elsif ($line =~ /^\|\s+(\S+)\s+\|\s+\[\S+\]\((\S+)\.1\.md\)/) {
# $1 will be changed by recursion _*BEFORE*_ left-hand assignment
my $subcmd = $1;
+ if ($previous_subcmd gt $subcmd) {
+ warn "$ME: $subpath: '$previous_subcmd' and '$subcmd' are out of order\n";
+ ++$Errs;
+ }
+ $previous_subcmd = $subcmd;
$man{$subcmd} = podman_man($2);
}
}
@@ -315,4 +353,76 @@ sub podman_man {
}
+################
+# podman_rst # Parse contents of docs/source/*.rst
+################
+sub podman_rst {
+ my %rst;
+
+ # Read all .rst files, looking for ":doc:`subcmd <target>` description"
+ for my $rst (glob "$Docs_Path/*.rst") {
+ open my $fh, '<', $rst
+ or die "$ME: Cannot read $rst: $!\n";
+
+ # The basename of foo.rst is usually, but not always, the name of
+ # a podman subcommand. There are a few special cases:
+ (my $command = $rst) =~ s!^.*/(.*)\.rst!$1!;
+
+ my $subcommand_href = \%rst;
+ if ($command eq 'Commands') {
+ ;
+ }
+ elsif ($command eq 'managecontainers') {
+ $subcommand_href = $rst{container} //= { };
+ }
+ elsif ($command eq 'connection') {
+ $subcommand_href = $rst{system}{connection} //= { };
+ }
+ else {
+ $subcommand_href = $rst{$command} //= { };
+ }
+
+ my $previous_subcommand = '';
+ while (my $line = <$fh>) {
+ if ($line =~ /^:doc:`(\S+)\s+<(.*?)>`\s+(.*)/) {
+ my ($subcommand, $target, $desc) = ($1, $2, $3);
+
+ # Check that entries are in alphabetical order
+ if ($subcommand lt $previous_subcommand) {
+ warn "$ME: $rst:$.: '$previous_subcommand' and '$subcommand' are out of order\n";
+ ++$Errs;
+ }
+ $previous_subcommand = $subcommand;
+
+ # Mark this subcommand as documented.
+ $subcommand_href->{$subcommand}{_desc} = $desc;
+
+ # Check for invalid links. These will be one of two forms:
+ # <markdown/foo.1> -> markdown/foo.1.md
+ # <foo> -> foo.rst
+ if ($target =~ m!^markdown/!) {
+ if (! -e "$Docs_Path/$target.md") {
+ warn "$ME: $rst:$.: '$subcommand' links to nonexistent $target\n";
+ ++$Errs;
+ }
+ }
+ else {
+ if (! -e "$Docs_Path/$target.rst") {
+ warn "$ME: $rst:$.: '$subcommand' links to nonexistent $target.rst\n";
+ }
+ }
+ }
+ }
+ close $fh;
+ }
+
+ # Special case: 'image trust set/show' are documented in image-trust.1
+ $rst{image}{trust}{$_} = { _desc => 'ok' } for (qw(set show));
+
+ return \%rst;
+}
+
+# END data gathering
+###############################################################################
+
1;