No description
- Perl 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| lib/AdyxaxOrg | ||
| .yamllint | ||
| CHANGELOG.md | ||
| init.pl | ||
| LICENSE | ||
| make.pl | ||
| README.md | ||
Perl library
Shared perl modules backing the make.pl scripts of the adyxax.org
repositories.
Contents
- Requirements
- Ready-made command lines
- Fully custom make.pl example
- Usage from Forgejo actions
- Modules
Requirements
- perl >= 5.36 with its core modules,
IO::Socket::SSLfor HTTPS, the only non-core dependency:libio-socket-ssl-perl(Debian),perl-IO-Socket-SSL(RHEL),security/p5-IO-Socket-SSL(FreeBSD, withsecurity/ca_root_nss),curlandgitfor the bootstrap.
Ready-made command lines
Repositories of the same kind can use the AdyxaxOrg::CLI::* modules. For
example, the make.pl of an ansible repository is:
#!/usr/bin/env perl
use v5.36;
use FindBin qw($RealBin);
chdir $RealBin or die "chdir $RealBin: $!\n";
BEGIN {
$ENV{PERL_LIBRARY_VERSION} = 'main';
$ENV{PERL_LIBRARY_DIR} = "$ENV{HOME}/.cache/adyxax.org/perl-library-$ENV{PERL_LIBRARY_VERSION}";
unless (grep { /\A(?:--no-update\z|-[hv]*n)/ } @ARGV) {
require File::Temp;
my $url = "https://git.adyxax.org/api/v1/repos/adyxax.org/perl-library/raw/init.pl?ref=$ENV{PERL_LIBRARY_VERSION}";
my $init = File::Temp->new(SUFFIX => '.pl');
system('curl', '-fsSL', '-o', "$init", $url) == 0
or die "perl library bootstrap: failed to download $url\n";
system($^X, "$init") == 0 or die "perl library bootstrap failed\n";
}
}
use lib "$ENV{PERL_LIBRARY_DIR}/lib";
use AdyxaxOrg::CLI::Ansible qw(ansible_main);
ansible_main(@ARGV);
Fully custom make.pl example
#!/usr/bin/env perl
use v5.36;
use FindBin qw($RealBin);
use Getopt::Long qw(:config bundling no_ignore_case);
chdir $RealBin or die "chdir $RealBin: $!\n";
BEGIN {
$ENV{PERL_LIBRARY_VERSION} = 'main';
$ENV{PERL_LIBRARY_DIR} = "$ENV{HOME}/.cache/adyxax.org/perl-library-$ENV{PERL_LIBRARY_VERSION}";
unless (grep { /\A(?:--no-update\z|-[hv]*n)/ } @ARGV) {
require File::Temp;
my $url = "https://git.adyxax.org/api/v1/repos/adyxax.org/perl-library/raw/init.pl?ref=$ENV{PERL_LIBRARY_VERSION}";
my $init = File::Temp->new(SUFFIX => '.pl');
system('curl', '-fsSL', '-o', "$init", $url) == 0
or die "perl library bootstrap: failed to download $url\n";
system($^X, "$init") == 0 or die "perl library bootstrap failed\n";
}
}
use lib "$ENV{PERL_LIBRARY_DIR}/lib";
use AdyxaxOrg::Check qw(check_perl check_shell);
use AdyxaxOrg::Podman qw(podman_push);
use AdyxaxOrg::Shell qw(capture run);
my $build_id = capture(qw(git rev-parse --short HEAD));
sub usage($error = undef) {
say STDERR $error if defined $error;
print STDERR <<"EOF";
Usage:
$0 build # build the container image.
$0 check # lint the scripts and this make.pl.
$0 push [-t] # push the image to the registry.
Global options:
-h show this help message
-n do not update the perl library
-v verbose mode, trace every command on stderr
Command options:
-t also push the built image to latest
EOF
exit(defined $error ? 1 : 0);
}
my %opts;
GetOptions(\%opts, 't', 'n', 'h' => sub { usage() },
'v' => \$AdyxaxOrg::Shell::VERBOSE) or usage('Invalid options');
my $action = shift @ARGV // usage('Missing action');
my %actions = (
build => sub { run(qw(buildah build ...)) },
check => sub { check_shell(); check_perl() },
push => sub { podman_push('quay.io', 'adyxax', 'example', $build_id, $opts{t}) },
);
my $code = $actions{$action} // usage("Unknown action: $action");
$code->(@ARGV);
Usage from Forgejo Actions
steps:
- uses: "https://git.adyxax.org/adyxax.org/action-checkout@1.0.0"
- name: 'Bootstrap the perl library'
run: './make.pl -h'
- name: 'Check and lint everything'
run: './make.pl -n check'
Modules
| Module | Functions |
|---|---|
AdyxaxOrg::Assert |
assert_commands <command>... |
AdyxaxOrg::Check |
check_ansible [requirements] |
check_perl |
|
check_shell |
|
check_tofu [directory] |
|
check_yaml |
|
AdyxaxOrg::CLI::Ansible |
ansible_main [\%config] @ARGV, ansible_options \%opts |
AdyxaxOrg::CLI::AnsibleRole |
ansible_role_main [\%config] @ARGV |
AdyxaxOrg::CLI::ForgejoAction |
forgejo_action_main [\%config] @ARGV |
AdyxaxOrg::Shell |
capture [\%options] <command>..., |
run <command>..., |
|
run_ok <command>..., |
|
which <command> |
|
AdyxaxOrg::Utils |
ansible_galaxy_install <requirements> [upgrade], |
ensure_uv [requirements], |
|
find_files <regex> [directory] |