Merge pull request #685 from rhansen/module-load
Improve loading of optional SHA1 and JSON modules
This commit is contained in:
commit
a486d4f976
2 changed files with 14 additions and 21 deletions
|
@ -15,6 +15,10 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
|
||||||
[5b104ad1](https://github.com/ddclient/ddclient/commit/5b104ad116c023c3760129cab6e141f04f72b406)
|
[5b104ad1](https://github.com/ddclient/ddclient/commit/5b104ad116c023c3760129cab6e141f04f72b406)
|
||||||
* All log messages are now written to STDERR, not a mix of STDOUT and STDERR.
|
* All log messages are now written to STDERR, not a mix of STDOUT and STDERR.
|
||||||
[#676](https://github.com/ddclient/ddclient/pull/676)
|
[#676](https://github.com/ddclient/ddclient/pull/676)
|
||||||
|
* For `--protocol=freedns` and `--protocol=nfsn`, the core module
|
||||||
|
`Digest::SHA` is now required. Previously, `Digest::SHA1` was used (if
|
||||||
|
available) as an alternative to `Digest::SHA`.
|
||||||
|
[#685](https://github.com/ddclient/ddclient/pull/685)
|
||||||
|
|
||||||
### New features
|
### New features
|
||||||
|
|
||||||
|
|
31
ddclient.in
31
ddclient.in
|
@ -2600,33 +2600,22 @@ sub encode_base64 ($;$) {
|
||||||
## load_sha1_support
|
## load_sha1_support
|
||||||
######################################################################
|
######################################################################
|
||||||
sub load_sha1_support {
|
sub load_sha1_support {
|
||||||
my $why = shift;
|
my ($protocol) = @_;
|
||||||
my $sha1_loaded = eval { require Digest::SHA1 };
|
eval { require Digest::SHA; } or fatal(<<"EOM");
|
||||||
my $sha_loaded = eval { require Digest::SHA };
|
Error loading the Perl module Digest::SHA needed for $protocol update.
|
||||||
unless ($sha1_loaded || $sha_loaded) {
|
On Debian, the package libdigest-sha-perl must be installed.
|
||||||
fatal("%s", <<"EOM");
|
|
||||||
Error loading the Perl module Digest::SHA1 or Digest::SHA needed for $why update.
|
|
||||||
On Debian, the package libdigest-sha1-perl or libdigest-sha-perl must be installed.
|
|
||||||
EOM
|
EOM
|
||||||
}
|
Digest::SHA->import(qw/sha1_hex/);
|
||||||
if ($sha1_loaded) {
|
|
||||||
import Digest::SHA1 (qw/sha1_hex/);
|
|
||||||
} elsif ($sha_loaded) {
|
|
||||||
import Digest::SHA (qw/sha1_hex/);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## load_json_support
|
## load_json_support
|
||||||
######################################################################
|
######################################################################
|
||||||
sub load_json_support {
|
sub load_json_support {
|
||||||
my $why = shift;
|
my ($protocol) = @_;
|
||||||
my $json_loaded = eval { require JSON::PP };
|
eval { require JSON::PP; }
|
||||||
unless ($json_loaded) {
|
or fatal("Error loading the Perl module JSON::PP needed for $protocol update.");
|
||||||
fatal("%s", <<"EOM");
|
JSON::PP->import(qw/decode_json encode_json/);
|
||||||
Error loading the Perl module JSON::PP needed for $why update.
|
|
||||||
EOM
|
|
||||||
}
|
|
||||||
import JSON::PP (qw/decode_json encode_json/);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue