Skip to content

Commit

Permalink
Merge pull request #18 from maxmind/horgh/man-pages
Browse files Browse the repository at this point in the history
Build man pages
  • Loading branch information
oschwald authored Jan 17, 2019
2 parents d8e430f + f8aa25e commit 8e0822e
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ install:
- go get -t ./...
- "if [[ $RUN_SNYK && $SNYK_TOKEN ]]; then snyk test --org=maxmind; fi"

script: go test -v ./...

after_success:
- "if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' && $RUN_SNYK && $SNYK_TOKEN ]]; then snyk monitor --org=maxmind --project-name=maxmind/geoipupdate2; fi"

Expand Down
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
8 changes: 8 additions & 0 deletions README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
[here](https://github.com/settings/tokens/new).
* If we're not using Go modules yet, the release might fail depending on
your `GO111MODULE` setting. Consider setting it to `off` if necessary.

Then release to our PPA:

* Switch to the ubuntu-ppa branch. Merge master into it.
* Set up to release to launchpad. You can see some information about
prerequisites for this
[here](https://github.com/maxmind/libmaxminddb/blob/master/README.dev.md).
* Run `dev-bin/ppa-release.sh`
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ After you install geoipupdate, please refer to our
about configuration.

If you're upgrading from geoipupdate 3.x, please see our [upgrade
guide](https://dev.maxmind.com/geoip/geoipupdate/upgrading-to-geoipupdate-4-x/).
guide](https://dev.maxmind.com/geoip/geoipupdate/upgrading-to-geoip-update-4-x/).

### Installing on Linux via the tarball

Expand All @@ -35,6 +35,22 @@ geoipupdate_4.0.0_linux_amd64/geoipupdate /usr/local/bin`.
`geoipupdate` looks for the config file `/usr/local/etc/GeoIP.conf` by
default.

### Installing on Ubuntu via PPA

MaxMind provides a PPA for recent versions of Ubuntu. To add the PPA to
your sources, run:

```
$ sudo add-apt-repository ppa:maxmind/ppa
```

Then install `geoipupdate` by running:

```
$ sudo apt update
$ sudo apt install geoipupdate
```

### Installing on Ubuntu or Debian via the deb

You can also use the tarball.
Expand Down
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 and
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 [[email protected]](mailto:[email protected]).

## 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 8e0822e

Please sign in to comment.