Skip to content

Commit

Permalink
Build man pages
Browse files Browse the repository at this point in the history
  • Loading branch information
horgh committed Jan 16, 2019
1 parent d8e430f commit 982849f
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 14 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ all: \
data: \
$(BUILDDIR)/GeoIP.conf \
$(BUILDDIR)/GeoIP.conf.md \
$(BUILDDIR)/geoipupdate.md
$(BUILDDIR)/geoipupdate.md \
$(BUILDDIR)/GeoIP.conf.5 \
$(BUILDDIR)/geoipupdate.1

$(BUILDDIR):
mkdir -p $(BUILDDIR)
Expand All @@ -43,8 +45,16 @@ $(BUILDDIR)/GeoIP.conf.md: $(BUILDDIR) doc/GeoIP.conf.md
$(BUILDDIR)/geoipupdate.md: $(BUILDDIR) doc/geoipupdate.md
sed -e 's|CONFFILE|$(CONFFILE)|g' -e 's|DATADIR|$(DATADIR)|g' doc/geoipupdate.md > $(BUILDDIR)/geoipupdate.md

$(BUILDDIR)/GeoIP.conf.5:
dev-bin/make-man-pages.pl

$(BUILDDIR)/geoipupdate.1:
dev-bin/make-man-pages.pl

clean:
rm -rf $(BUILDDIR)/GeoIP.conf \
$(BUILDDIR)/GeoIP.conf.md \
$(BUILDDIR)/geoipupdate \
$(BUILDDIR)/geoipupdate.md
$(BUILDDIR)/geoipupdate.md \
$(BUILDDIR)/GeoIP.conf.5 \
$(BUILDDIR)/geoipupdate.1
60 changes: 60 additions & 0 deletions dev-bin/make-man-pages.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env perl
use strict;
use warnings;

sub main {
_make_man(
'geoipupdate',
1,
'build/geoipupdate.md',
'build/geoipupdate.1',
);
_make_man(
'GeoIP.conf',
5,
'build/GeoIP.conf.md',
'build/GeoIP.conf.5',
);
return 1;
}

sub _make_man {
my ($name, $section, $input, $output) = @_;

my $tmp = 'build/tmp';
open my $fh, '>', $tmp or die $!;
binmode $fh or die $!;
print { $fh } "% $name($section)\n\n" or die $!;
my $contents = _read($input);
print { $fh } $contents or die $!;
close $fh or die $!;

system(
'pandoc',
'-s',
'-f', 'markdown',
'-t', 'man',
$tmp,
'-o', $output,
) == 0 or die 'pandoc failed';

unlink $tmp or die $!;

return;
}

sub _read {
my ($file) = @_;
open my $fh, '<', $file or die $!;
binmode $fh or die $!;
my $contents = '';
while (!eof($fh)) {
my $line = <$fh>;
die 'error reading' unless defined $line;
$contents .= $line;
}
close $fh or die $!;
return $contents;
}

exit(main() ? 0 : 1);
5 changes: 2 additions & 3 deletions doc/GeoIP.conf.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ The following are deprecated and will be ignored if present:

## FILES

* [`GeoIP.conf`](../conf/GeoIP.conf.default) - Default `geoipupdate`
configuration file.
* `GeoIP.conf` - Default `geoipupdate` configuration file.

## SEE ALSO

[geoipupdate](geoipupdate.md)
`geoipupdate`(1)
17 changes: 8 additions & 9 deletions doc/geoipupdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ open.
* `-d`, `--database-directory` - Install databases to a custom directory.
This is optional. If provided, it overrides any `DatabaseDirectory` set
in the configuration file.
* `-f`, `--config-file` - The configuration file to use. See
[GeoIP.conf](GeoIP.conf.md) for more information. This is optional. It
defaults to CONFFILE.
* `-f`, `--config-file` - The configuration file to use. See GeoIP.conf an
its documentation for more information. This is optional. It defaults to
CONFFILE.
* `-h`, `--help` - Display help and exit.
* `--stack-trace` - Show a stack trace on any error message. This is
primarily useful for debugging.
Expand Down Expand Up @@ -63,7 +63,7 @@ variable.
## FILES

* `GeoIP.conf` - Configuration file for GeoIP Update. See the
[`GeoIP.conf` documentation](GeoIP.conf.md) for more information.
`GeoIP.conf` documentation for more information.

## AUTHOR

Expand All @@ -75,11 +75,10 @@ Report bugs to [support@maxmind.com](mailto:support@maxmind.com).

## COPYRIGHT

This software is Copyright (c) 2018 by MaxMind, Inc.
This software is Copyright (c) 2018-2019 by MaxMind, Inc.

This is free software, licensed under the [Apache License, Version
2.0](../LICENSE-APACHE) or the [MIT License](../LICENSE-MIT), at your
option.
This is free software, licensed under the Apache License, Version 2.0 or
the MIT License, at your option.

## MORE INFORMATION

Expand All @@ -89,4 +88,4 @@ for a subscription.

## SEE ALSO

[`GeoIP.conf`](GeoIP.conf.md)
`GeoIP.conf`(5)

0 comments on commit 982849f

Please sign in to comment.