[1348] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Common functions for virtual environment
|
---|
[1528] | 4 | #
|
---|
| 5 | # Copyright B. Cornec 2007-2012
|
---|
| 6 | # Eric Anderson's changes are (c) Copyright 2012 Hewlett Packard
|
---|
| 7 | # Provided under the GPL v2
|
---|
[1348] | 8 | #
|
---|
| 9 | # $Id$
|
---|
| 10 | #
|
---|
| 11 |
|
---|
| 12 | package ProjectBuilder::VE;
|
---|
| 13 |
|
---|
| 14 | use strict;
|
---|
| 15 | use Data::Dumper;
|
---|
[1506] | 16 | use Carp 'confess';
|
---|
[1348] | 17 | use English;
|
---|
| 18 | use ProjectBuilder::Version;
|
---|
| 19 | use ProjectBuilder::Base;
|
---|
| 20 | use ProjectBuilder::Conf;
|
---|
[1350] | 21 | use ProjectBuilder::Distribution;
|
---|
[1348] | 22 |
|
---|
| 23 | # Global vars
|
---|
| 24 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
| 25 |
|
---|
| 26 | use vars qw($VERSION $REVISION @ISA @EXPORT);
|
---|
| 27 | use Exporter;
|
---|
| 28 |
|
---|
| 29 | # Export, by default, all the functions into the namespace of
|
---|
| 30 | # any code which uses this module.
|
---|
| 31 |
|
---|
| 32 | our @ISA = qw(Exporter);
|
---|
[1900] | 33 | our @EXPORT = qw(pb_ve_launch pb_ve_snap);
|
---|
[1348] | 34 |
|
---|
| 35 | ($VERSION,$REVISION) = pb_version_init();
|
---|
| 36 |
|
---|
| 37 | =pod
|
---|
| 38 |
|
---|
| 39 | =head1 NAME
|
---|
| 40 |
|
---|
| 41 | ProjectBuilder::VE, part of the project-builder.org - module dealing with Virtual Environment
|
---|
| 42 |
|
---|
| 43 | =head1 DESCRIPTION
|
---|
| 44 |
|
---|
[1900] | 45 | This modules provides functions to deal with Virtual Environements (VE), aka chroot/containers.
|
---|
[1348] | 46 |
|
---|
| 47 | =head1 SYNOPSIS
|
---|
| 48 |
|
---|
| 49 | use ProjectBuilder::VE;
|
---|
| 50 |
|
---|
| 51 | #
|
---|
| 52 | # Return information on the running distro
|
---|
| 53 | #
|
---|
| 54 | my $pbos = pb_ve_launch();
|
---|
| 55 |
|
---|
| 56 | =head1 USAGE
|
---|
| 57 |
|
---|
| 58 | =over 4
|
---|
| 59 |
|
---|
| 60 | =item B<pb_ve_launch>
|
---|
| 61 |
|
---|
[1900] | 62 | This function launches a VE, creating it if necessary using multiple external potential tools.
|
---|
[1348] | 63 |
|
---|
| 64 | =cut
|
---|
| 65 |
|
---|
| 66 | sub pb_ve_launch {
|
---|
| 67 |
|
---|
| 68 | my $v = shift || undef;
|
---|
| 69 | my $pbforce = shift || 0; # By default do not rebuild VE
|
---|
[1646] | 70 | my $locsnap = shift || 0; # By default do not snap VE
|
---|
[1900] | 71 | my $vetype = shift || undef; # By default no image
|
---|
| 72 | my $pbimage = shift || undef; # By default no image
|
---|
[1348] | 73 |
|
---|
[1900] | 74 | my $dockerregistry = undef;
|
---|
| 75 | my $docrepo = undef; # By default no repository for docker available
|
---|
| 76 |
|
---|
[1348] | 77 | # Get distro context
|
---|
| 78 | my $pbos = pb_distro_get_context($v);
|
---|
| 79 |
|
---|
| 80 | # Get VE context
|
---|
[1900] | 81 | if (not defined $vetype) {
|
---|
| 82 | my ($ptr) = pb_conf_get("vetype");
|
---|
| 83 | $vetype = $ptr->{$ENV{'PBPROJ'}};
|
---|
| 84 | }
|
---|
[1506] | 85 | confess "No vetype defined for $ENV{PBPROJ}" unless (defined $vetype);
|
---|
| 86 | pb_log(1, "Using vetype $vetype for $ENV{PBPROJ}\n");
|
---|
[1900] | 87 | my ($vepath) = pb_conf_get("vepath");
|
---|
[1506] | 88 |
|
---|
[1900] | 89 | if (($vetype eq "chroot") || ($vetype eq "schroot") || ($vetype eq "docker")) {
|
---|
[1348] | 90 |
|
---|
[1352] | 91 | # We need to avoid umask propagation to the VE
|
---|
| 92 | umask 0022;
|
---|
[1348] | 93 |
|
---|
[1352] | 94 | # We can probably only get those params now we have the distro context
|
---|
| 95 | my ($rbsb4pi,$rbspi,$vesnap,$oscodename,$osmindep,$verebuild,$rbsmirrorsrv) = pb_conf_get_if("rbsb4pi","rbspi","vesnap","oscodename","osmindep","verebuild","rbsmirrorsrv");
|
---|
[1900] | 96 | if ($vetype eq "docker") {
|
---|
| 97 | # Check acces to registry
|
---|
| 98 | ($dockerregistry) = pb_conf_get("dockerregistry");
|
---|
| 99 | if ((defined $dockerregistry) && (defined $dockerregistry->{$ENV{'PBPROJ'}})) {
|
---|
| 100 | pb_ve_docker_registry($dockerregistry->{$ENV{'PBPROJ'}});
|
---|
| 101 | } else {
|
---|
| 102 | die "When using docker you need to declare a dockerregistry parameter. Read the man page"
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
[1348] | 105 |
|
---|
| 106 | # Architecture consistency
|
---|
[1352] | 107 | my $arch = pb_get_arch();
|
---|
[1348] | 108 | if ($arch ne $pbos->{'arch'}) {
|
---|
[1506] | 109 | die "Unable to launch a VE of architecture $pbos->{'arch'} on a $arch platform" unless (($pbos->{'arch'} =~ /i?86/o) && ($arch eq "x86_64"));
|
---|
[1348] | 110 | }
|
---|
| 111 |
|
---|
[1352] | 112 | # If we are already root (from pbmkbm e.g.) don't use sudo, just call the command
|
---|
| 113 | my $sudocmd="";
|
---|
[1527] | 114 | if ($EFFECTIVE_USER_ID != 0) {
|
---|
| 115 | $sudocmd ="sudo ";
|
---|
[1900] | 116 | foreach my $proxy (qw/http_proxy ftp_proxy/) {
|
---|
[1527] | 117 | if (defined $ENV{$proxy}) {
|
---|
[1530] | 118 | open(CMD,"sudo sh -c 'echo \$$proxy' |") or die "can't run sudo sh?: $!";
|
---|
[1527] | 119 | $_ = <CMD>;
|
---|
| 120 | chomp();
|
---|
| 121 | die "sudo not passing through env var $proxy; '$ENV{$proxy}' != '$_'\nAdd line Defaults:`whoami` env_keep += \"$proxy\" to sudoers file?" unless $_ eq $ENV{$proxy};
|
---|
[1530] | 122 | close(CMD);
|
---|
[1527] | 123 | }
|
---|
| 124 | }
|
---|
[1530] | 125 | }
|
---|
[1564] | 126 |
|
---|
[1519] | 127 | # Handle cross arch on Intel based platforms
|
---|
[1564] | 128 | $sudocmd = "setarch i386 $sudocmd" if (($pbos->{'arch'} =~ /i[3456]86/) && ($arch eq 'x86_64'));
|
---|
[1348] | 129 |
|
---|
[1506] | 130 | my $root = pb_path_expand($vepath->{$ENV{PBPROJ}});
|
---|
[1900] | 131 |
|
---|
| 132 | if (((((defined $verebuild) && ($verebuild->{$ENV{'PBPROJ'}} =~ /true/i)) || ($pbforce == 1)) && ($vetype ne "docker"))
|
---|
| 133 | # For docker we may have a reference image that we'll use
|
---|
| 134 | || (((not defined $pbimage) || ($pbimage eq "")) && ($vetype eq "docker"))) {
|
---|
| 135 |
|
---|
[1352] | 136 | my ($verpmtype,$vedebtype) = pb_conf_get("verpmtype","vedebtype");
|
---|
| 137 | my ($rbsopt1) = pb_conf_get_if("rbsopt");
|
---|
| 138 |
|
---|
[1348] | 139 | # We have to rebuild the chroot
|
---|
| 140 | if ($pbos->{'type'} eq "rpm") {
|
---|
| 141 |
|
---|
| 142 | # Which tool is used
|
---|
| 143 | my $verpmstyle = $verpmtype->{$ENV{'PBPROJ'}};
|
---|
[1517] | 144 | die "No verpmtype defined for $ENV{PBPROJ}" unless (defined $verpmstyle);
|
---|
[1348] | 145 |
|
---|
| 146 | # Get potential rbs option
|
---|
| 147 | my $rbsopt = "";
|
---|
| 148 | if (defined $rbsopt1) {
|
---|
| 149 | if (defined $rbsopt1->{$verpmstyle}) {
|
---|
| 150 | $rbsopt = $rbsopt1->{$verpmstyle};
|
---|
| 151 | } elsif (defined $rbsopt1->{$ENV{'PBPROJ'}}) {
|
---|
| 152 | $rbsopt = $rbsopt1->{$ENV{'PBPROJ'}};
|
---|
| 153 | } else {
|
---|
| 154 | $rbsopt = "";
|
---|
| 155 | }
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | my $postinstall = pb_ve_get_postinstall($pbos,$rbspi,$verpmstyle);
|
---|
| 159 | if ($verpmstyle eq "rinse") {
|
---|
| 160 | # Need to reshape the mirrors generated with local before-post-install script
|
---|
| 161 | my $b4post = "--before-post-install ";
|
---|
| 162 | my $postparam = pb_distro_get_param($pbos,$rbsb4pi);
|
---|
| 163 | if ($postparam eq "") {
|
---|
| 164 | $b4post = "";
|
---|
| 165 | } else {
|
---|
| 166 | $b4post .= $postparam;
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | # Need to reshape the package list for pb
|
---|
| 170 | my $addpkgs;
|
---|
| 171 | $postparam = "";
|
---|
| 172 | $postparam .= pb_distro_get_param($pbos,$osmindep);
|
---|
| 173 | if ($postparam eq "") {
|
---|
| 174 | $addpkgs = "";
|
---|
| 175 | } else {
|
---|
| 176 | my $pkgfile = "$ENV{'PBTMP'}/addpkgs.lis";
|
---|
| 177 | open(PKG,"> $pkgfile") || die "Unable to create $pkgfile";
|
---|
| 178 | foreach my $p (split(/,/,$postparam)) {
|
---|
| 179 | print PKG "$p\n";
|
---|
| 180 | }
|
---|
| 181 | close(PKG);
|
---|
| 182 | $addpkgs = "--add-pkg-list $pkgfile";
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | my $rinseverb = "";
|
---|
| 186 | $rinseverb = "--verbose" if ($pbdebug gt 0);
|
---|
| 187 | my ($rbsconf) = pb_conf_get("rbsconf");
|
---|
| 188 |
|
---|
| 189 | my $command = pb_check_req("rinse",0);
|
---|
[1506] | 190 | pb_system("$sudocmd $command --directory \"$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" --arch \"$pbos->{'arch'}\" --distribution \"$pbos->{'name'}-$pbos->{'version'}\" --config \"$rbsconf->{$ENV{'PBPROJ'}}\" $b4post $postinstall $rbsopt $addpkgs $rinseverb","Creating the rinse VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose");
|
---|
[1348] | 191 | } elsif ($verpmstyle eq "rpmbootstrap") {
|
---|
| 192 | my $rbsverb = "";
|
---|
| 193 | foreach my $i (1..$pbdebug) {
|
---|
| 194 | $rbsverb .= " -v";
|
---|
| 195 | }
|
---|
| 196 | my $addpkgs = "";
|
---|
| 197 | my $postparam = "";
|
---|
| 198 | $postparam .= pb_distro_get_param($pbos,$osmindep);
|
---|
| 199 | if ($postparam eq "") {
|
---|
| 200 | $addpkgs = "";
|
---|
| 201 | } else {
|
---|
| 202 | $addpkgs = "-a $postparam";
|
---|
| 203 | }
|
---|
| 204 | my $command = pb_check_req("rpmbootstrap",0);
|
---|
| 205 | pb_system("$sudocmd $command $rbsopt $postinstall $addpkgs $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} $rbsverb","Creating the rpmbootstrap VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose");
|
---|
[1596] | 206 | pb_system("$sudocmd /bin/umount $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/proc","Umounting stale /proc","mayfail") if (-f "$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/proc/cpuinfo");
|
---|
[1348] | 207 | } elsif ($verpmstyle eq "mock") {
|
---|
| 208 | my ($rbsconf) = pb_conf_get("rbsconf");
|
---|
| 209 | my $command = pb_check_req("mock",0);
|
---|
| 210 | pb_system("$sudocmd $command --init --resultdir=\"/tmp\" --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v $rbsopt","Creating the mock VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})");
|
---|
| 211 | # Once setup we need to install some packages, the pb account, ...
|
---|
| 212 | pb_system("$sudocmd $command --install --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v su","Configuring the mock VE");
|
---|
| 213 | } else {
|
---|
| 214 | die "Unknown verpmtype type $verpmstyle. Report to dev team";
|
---|
| 215 | }
|
---|
| 216 | } elsif ($pbos->{'type'} eq "deb") {
|
---|
| 217 | my $vedebstyle = $vedebtype->{$ENV{'PBPROJ'}};
|
---|
| 218 |
|
---|
| 219 | my $codename = pb_distro_get_param($pbos,$oscodename);
|
---|
| 220 | my $postparam = "";
|
---|
| 221 | my $addpkgs;
|
---|
| 222 | $postparam .= pb_distro_get_param($pbos,$osmindep);
|
---|
| 223 | if ($postparam eq "") {
|
---|
| 224 | $addpkgs = "";
|
---|
| 225 | } else {
|
---|
| 226 | $addpkgs = "--include $postparam";
|
---|
| 227 | }
|
---|
| 228 | my $debmir = "";
|
---|
| 229 | $debmir .= pb_distro_get_param($pbos,$rbsmirrorsrv);
|
---|
| 230 |
|
---|
| 231 | # Get potential rbs option
|
---|
| 232 | my $rbsopt = "";
|
---|
| 233 | if (defined $rbsopt1) {
|
---|
| 234 | if (defined $rbsopt1->{$vedebstyle}) {
|
---|
| 235 | $rbsopt = $rbsopt1->{$vedebstyle};
|
---|
| 236 | } elsif (defined $rbsopt1->{$ENV{'PBPROJ'}}) {
|
---|
| 237 | $rbsopt = $rbsopt1->{$ENV{'PBPROJ'}};
|
---|
| 238 | } else {
|
---|
| 239 | $rbsopt = "";
|
---|
| 240 | }
|
---|
| 241 | }
|
---|
| 242 |
|
---|
| 243 | # debootstrap works with amd64 not x86_64
|
---|
| 244 | my $debarch = $pbos->{'arch'};
|
---|
| 245 | $debarch = "amd64" if ($pbos->{'arch'} eq "x86_64");
|
---|
| 246 | if ($vedebstyle eq "debootstrap") {
|
---|
| 247 | my $dbsverb = "";
|
---|
| 248 | $dbsverb = "--verbose" if ($pbdebug gt 0);
|
---|
| 249 |
|
---|
| 250 | # Some perl modules are in Universe on Ubuntu
|
---|
| 251 | $rbsopt .= " --components=main,universe" if ($pbos->{'name'} eq "ubuntu");
|
---|
| 252 |
|
---|
[1588] | 253 | my $cmd1 = pb_check_req("mkdir",0);
|
---|
| 254 | my $cmd2 = pb_check_req("debootstrap",0);
|
---|
| 255 | pb_system("$sudocmd $cmd1 -p $root/$pbos->{name}/$pbos->{version}/$pbos->{arch} ; $sudocmd $cmd2 $dbsverb $rbsopt --arch=$debarch $addpkgs $codename \"$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" $debmir","Creating the debootstrap VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose");
|
---|
[1348] | 256 | # debootstrap doesn't create an /etc/hosts file
|
---|
[1506] | 257 | if (! -f "$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts" ) {
|
---|
[1588] | 258 | my $cmd = pb_check_req("cp",0);
|
---|
| 259 | pb_system("$sudocmd $cmd /etc/hosts $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts");
|
---|
[1348] | 260 | }
|
---|
| 261 | } else {
|
---|
| 262 | die "Unknown vedebtype type $vedebstyle. Report to dev team";
|
---|
| 263 | }
|
---|
| 264 | } elsif ($pbos->{'type'} eq "ebuild") {
|
---|
| 265 | die "Please teach the dev team how to build gentoo chroot";
|
---|
| 266 | } else {
|
---|
| 267 | die "Unknown distribution type $pbos->{'type'}. Report to dev team";
|
---|
| 268 | }
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 | # Test if an existing snapshot exists and use it if appropriate
|
---|
[1900] | 272 | # And also use it if no local extracted VE is present
|
---|
[1506] | 273 | if ((-f "$root/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz") &&
|
---|
[1348] | 274 | (((defined $vesnap->{$v}) && ($vesnap->{$v} =~ /true/i)) ||
|
---|
[1646] | 275 | ((defined $vesnap->{$ENV{'PBPROJ'}}) && ($vesnap->{$ENV{'PBPROJ'}} =~ /true/i))) &&
|
---|
| 276 | ($locsnap eq 1) &&
|
---|
| 277 | (! -d "$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}")) {
|
---|
[1588] | 278 | my $cmd1 = pb_check_req("rm",0);
|
---|
| 279 | my $cmd2 = pb_check_req("mkdir",0);
|
---|
| 280 | my $cmd3 = pb_check_req("tar",0);
|
---|
| 281 | pb_system("$sudocmd $cmd1 -rf $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; $sudocmd $cmd2 -p $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; $sudocmd $cmd3 xz -C $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} -f $root/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz","Extracting snapshot of $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz under $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}");
|
---|
[1348] | 282 | }
|
---|
[1597] | 283 |
|
---|
| 284 | # Fix modes to allow access to the VE for pb user
|
---|
| 285 | my $command = pb_check_req("chmod",0);
|
---|
| 286 | pb_system("$sudocmd $command 755 $root/$pbos->{'name'} $root/$pbos->{'name'}/$pbos->{'version'} $root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}","Fixing permissions");
|
---|
| 287 |
|
---|
[1900] | 288 | # If docker, create the image and remove the now temp dir except if we had one already
|
---|
| 289 | if ($vetype eq "docker") {
|
---|
| 290 | if ((not defined $pbimage) || ($pbimage eq "")) {
|
---|
| 291 | # Snaphot the VE to serve as an input for docker
|
---|
| 292 | pb_ve_snap($pbos,$root);
|
---|
| 293 | # Create the docker image from the previous bootstrap
|
---|
| 294 | my $cmd1 = pb_check_req("docker",0);
|
---|
| 295 | $docrepo = pb_ve_docker_repo($dockerregistry->{$ENV{'PBPROJ'}});
|
---|
| 296 | pb_system("$cmd1 import - $docrepo:$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} < $root/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz");
|
---|
| 297 | pb_system("$cmd1 push $docrepo:$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}");
|
---|
| 298 | #} else {
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
| 301 |
|
---|
[1348] | 302 | # Nothing more to do for VE. No real launch
|
---|
| 303 | } else {
|
---|
| 304 | die "VE of type $vetype not supported. Report to the dev team";
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 |
|
---|
| 308 | #
|
---|
| 309 | # Return the postinstall line if needed
|
---|
| 310 | #
|
---|
| 311 |
|
---|
| 312 | sub pb_ve_get_postinstall {
|
---|
| 313 |
|
---|
| 314 | my $pbos = shift;
|
---|
| 315 | my $rbspi = shift;
|
---|
| 316 | my $vestyle = shift;
|
---|
| 317 | my $post = "";
|
---|
| 318 |
|
---|
| 319 | # Do we have a local post-install script
|
---|
| 320 | if ($vestyle eq "rinse") {
|
---|
| 321 | $post = "--post-install ";
|
---|
| 322 | } elsif ($vestyle eq "rpmbootstrap") {
|
---|
| 323 | $post = "-s ";
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | my $postparam = pb_distro_get_param($pbos,$rbspi);
|
---|
| 327 | if ($postparam eq "") {
|
---|
| 328 | $post = "";
|
---|
| 329 | } else {
|
---|
| 330 | $post .= $postparam;
|
---|
| 331 | }
|
---|
| 332 | return($post);
|
---|
| 333 | }
|
---|
| 334 |
|
---|
[1900] | 335 | # Snapshot the VE
|
---|
| 336 | sub pb_ve_snap {
|
---|
[1348] | 337 |
|
---|
[1900] | 338 | my $pbos = shift;
|
---|
| 339 | my $root = shift;
|
---|
| 340 | my $tpdir = "$root/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}";
|
---|
| 341 | pb_system("sudo tar cz -C $tpdir -f $root/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz .","Creating a snapshot of $tpdir");
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 | # Returns the docker registry to interact with
|
---|
| 345 | sub pb_ve_docker_registry {
|
---|
| 346 |
|
---|
| 347 | my $dockerreg = shift || undef;
|
---|
| 348 | my $wget = pb_check_req("wget",0);
|
---|
| 349 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($dockerreg);
|
---|
| 350 | my $docreg = $scheme."://";
|
---|
| 351 | $docreg .= $account."@" if ((defined $account) && ($account ne ""));
|
---|
| 352 | $docreg .= $host;
|
---|
| 353 | $docreg .= ":$port" if ((defined $port) && ($port ne ""));
|
---|
| 354 | open(FD,"$wget $docreg -q -O -|") || die "Unable to talk to the docker registry $docreg";
|
---|
| 355 | my $found = undef;
|
---|
| 356 | while (<FD>) {
|
---|
| 357 | $found = 1 if (/docker-registry/);
|
---|
| 358 | }
|
---|
| 359 | close(FD);
|
---|
| 360 | die "No correct docker-registry answering at $docreg. Please check your configuration" if (not defined $found);
|
---|
| 361 | #
|
---|
| 362 | return($docreg);
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | # Returns the docker repository to interact with
|
---|
| 366 | sub pb_ve_docker_repo {
|
---|
| 367 |
|
---|
| 368 | my $dockerreg = shift || undef;
|
---|
| 369 | my $docrepo = "";
|
---|
| 370 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($dockerreg);
|
---|
| 371 | $docrepo .= $host;
|
---|
| 372 | $docrepo .= ":$port" if ((defined $port) && ($port ne ""));
|
---|
| 373 | $docrepo .= "$path";
|
---|
| 374 | return($docrepo);
|
---|
| 375 | }
|
---|
| 376 |
|
---|
[1348] | 377 | =head1 WEB SITES
|
---|
| 378 |
|
---|
| 379 | The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>.
|
---|
| 380 |
|
---|
| 381 | =head1 USER MAILING LIST
|
---|
| 382 |
|
---|
| 383 | None exists for the moment.
|
---|
| 384 |
|
---|
| 385 | =head1 AUTHORS
|
---|
| 386 |
|
---|
| 387 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 388 |
|
---|
| 389 | =head1 COPYRIGHT
|
---|
| 390 |
|
---|
| 391 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 392 | described in the file C<COPYING> included with the distribution.
|
---|
| 393 |
|
---|
| 394 | =cut
|
---|
| 395 |
|
---|
| 396 |
|
---|
| 397 | 1;
|
---|