Add a tool for updating the vendored libaries.

This commit is contained in:
Sadie Powell 2020-01-17 22:45:56 +00:00
parent 1158a67676
commit 47fe6c5540
3 changed files with 153 additions and 13 deletions

26
vendor/README.md vendored
View File

@ -4,50 +4,50 @@ This directory contains vendored dependencies that are shipped with InspIRCd to
## bcrypt
**Author** — Solar Designer <solar@openwall.com>
**Last Updated** — 2018-08-14 (v1.3)
**Author** — [Solar Designer](mailto:solar@openwall.com)
**License** — Public Domain
**Version** — v1.3
**Website** — [https://www.openwall.com/crypt/](https://www.openwall.com/crypt/)
## http_parser
**Author** — Joyent, Inc. and other Node contributors
**Last Updated** — 2019-04-25 (v2.9.2)
**License** — MIT License
**Version** — v2.9.2
**Website** — [https://github.com/nodejs/http-parser](https://github.com/nodejs/http-parser)
## sha256
## sha2
**Author** — Olivier Gay <olivier.gay@a3.epfl.ch>
**Last Updated** — 2018-09-06 (2007-02-02)
**Author** — [Olivier Gay](mailto:olivier.gay@a3.epfl.ch)
**License** — 3-clause BSD License
**Version** — 2007-02-02
**Website** — [http://www.ouah.org/ogay/sha2/](http://www.ouah.org/ogay/sha2/)
## utfcpp
**Author** — Nemanja Trifunovic
**Last Updated** — 2019-08-02 (v3.1)
**License** — Boost Software License
**Version** — v3.1
**Website** — [https://github.com/nemtrif/utfcpp](https://github.com/nemtrif/utfcpp)
## ya_getopt
**Author** — Kubo Takehiro
**Last Updated** — 2019-12-08 (6ce431085b81d9bb8639ed2f858c4f4fbc3ab988)
**License** — 2-clause BSD License
**Version** — 6ce4310
**Website** — [https://github.com/kubo/ya_getopt](https://github.com/kubo/ya_getopt)

104
vendor/update vendored Executable file
View File

@ -0,0 +1,104 @@
#!/usr/bin/env perl
#
# InspIRCd -- Internet Relay Chat Daemon
#
# Copyright (C) 2020 Sadie Powell <sadie@witchery.services>
#
# This file is part of InspIRCd. InspIRCd 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, version 2.
#
# 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 <http://www.gnu.org/licenses/>.
#
BEGIN {
require 5.10.0;
unless (-f 'configure') {
print "Error: $0 must be run from the main source directory!\n";
exit 1;
}
}
use feature ':5.10';
use strict;
use warnings FATAL => qw(all);
use File::Basename qw(basename dirname);
use File::Copy qw(move);
use File::Spec::Functions qw(abs2rel catdir catfile);
use File::Temp qw(tempdir);
use FindBin qw($RealDir);
use POSIX qw(strftime);
use TOML qw(from_toml);
use lib dirname $RealDir;
use make::common;
use make::console;
my $config = catfile $RealDir, 'update.toml';
open(my $fh, $config) or print_error "unable to read $config: $!";
my $contents = do { local $/; <$fh> };
close $fh;
my ($data, $error) = from_toml $contents;
print_error "unable to parse $config: $!" if $error;
while (my ($name, $info) = each $data) {
print_format "Updating <|GREEN $name|> ...\n";
my $unpackdir = File::Temp->newdir;
my $vendordir = catdir $RealDir, $name;
my $success = 0;
if (defined $info->{git}) {
$success ||= system 'git', 'clone', $info->{git}, $unpackdir;
chomp(my $tag = `git -C $unpackdir describe --abbrev=0 --tags HEAD 2>/dev/null`) unless $success;
$success ||= system 'git', '-C', $unpackdir, 'checkout', $tag if $tag;
chomp($info->{version} = `git -C $unpackdir describe --always --tags HEAD 2>/dev/null`);
} elsif (defined $info->{tarball}) {
my $tarball = catfile $unpackdir, basename $info->{tarball};
$success ||= system 'wget', '--output-document', $tarball, $info->{tarball};
$success ||= system 'tar', 'fx', $tarball, '-C', $unpackdir, '--strip-components', 1;
} else {
print_error "unable to update $name; no git or tarball specified!";
}
print_error "unable to update $name: download failed!" if $success;
unlink $vendordir;
my $glob = $info->{files} or print_error "unable to update $name: no file glob specified!";
for my $file (glob catfile $unpackdir, $glob) {
my $pathname = abs2rel $file, $unpackdir;
for (my $i = 0; $i < ($info->{depth} // 0); ++$i) {
$pathname =~ s/[^\/]+\///;
}
my $filename = catfile $vendordir, $pathname;
my $dirname = dirname $filename;
create_directory $dirname, 0750;
move $file, $filename;
}
}
my $readme = catfile $RealDir, 'README.md';
open($fh, $readme) or print_error "unable to read $readme: $!";
$contents = do { local $/; <$fh> };
close $fh;
open($fh, '>', $readme) or print_error "unable to write $readme: $!";
print $fh $contents =~ s/\n\#\#.*//rs;
for my $name (sort keys $data) {
my $info = $data->{$name};
printf $fh "\n## %s\n\n", $name;
printf $fh "**Author** &mdash; [%s](mailto:%s)\n\n", $info->{author}, $info->{email} if $info->{email};
printf $fh "**Author** &mdash; %s\n\n", $info->{author} unless $info->{email};
printf $fh "**License** &mdash; %s\n\n", $info->{license};
printf $fh "**Version** &mdash; %s\n\n", $info->{version};
my $website = $info->{website} // $info->{git};
printf $fh "**Website** &mdash; [%s](%s)\n", $website, $website;
}
close $fh;

36
vendor/update.toml vendored Normal file
View File

@ -0,0 +1,36 @@
[bcrypt]
author = "Solar Designer"
email = "solar@openwall.com"
files = "crypt_blowfish.[ch]"
license = "Public Domain"
tarball = "https://www.openwall.com/crypt/crypt_blowfish-1.3.tar.gz"
version = "v1.3"
website = "https://www.openwall.com/crypt/"
[http_parser]
author = "Joyent, Inc. and other Node contributors"
files = "http_parser.[ch]"
git = "https://github.com/nodejs/http-parser"
license = "MIT License"
[sha2]
author = "Olivier Gay"
email = "olivier.gay@a3.epfl.ch"
files = "sha2.[ch]"
license = "3-clause BSD License"
tarball = "http://www.ouah.org/ogay/sha2/sha2.tar.gz"
version = "2007-02-02"
website = "http://www.ouah.org/ogay/sha2/"
[utfcpp]
author = "Nemanja Trifunovic"
depth = 1
files = "source/{**/*,*}.h"
git = "https://github.com/nemtrif/utfcpp"
license = "Boost Software License"
[ya_getopt]
author = "Kubo Takehiro"
files = "ya_getopt.[ch]"
git = "https://github.com/kubo/ya_getopt"
license = "2-clause BSD License"