PERL   66

docker wml debian perl

Guest on 30th April 2022 09:14:45 AM

  1. #! /usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use 5.014;
  6. use autodie;
  7.  
  8. use Path::Tiny qw/ cwd /;
  9. use Docker::CLI::Wrapper::Container v0.0.4 ();
  10.  
  11. my $obj = Docker::CLI::Wrapper::Container->new(
  12.     { container => "wml--deb--test-build", sys => "docker.io/debian:sid", } );
  13. if (0)
  14. {
  15.     print $obj->docker_cmd_line_prefix;
  16.  
  17.     # unshift @{ $obj->{docker_cmd_line_prefix} }, 'sudo';
  18.     print $obj->docker_cmd_line_prefix;
  19. }
  20. my $USER    = "mygbp";
  21. my $HOMEDIR = "/home/$USER";
  22.  
  23. $obj->clean_up();
  24. $obj->run_docker();
  25. my $REPO = 'wml';
  26. my $URL  = "https://salsa.debian.org/debian/$REPO";
  27.  
  28. my $BRANCH = "2.20.4-pkg-incomplete";
  29. if ( !-e $REPO )
  30. {
  31.     $obj->do_system( { cmd => [ "git", "clone", '-b', $BRANCH, $URL, ] } );
  32. }
  33. my $cwd = cwd;
  34. chdir "./$REPO";
  35. $obj->do_system( { cmd => [ "git", "pull", "--ff-only", ] } );
  36. chdir $cwd;
  37.  
  38. my @DEPS = qw/
  39.     eperl
  40.     freetable
  41.     libbit-vector-perl
  42.     libcarp-always-perl
  43.     libcode-tidyall-perl
  44.     libgd-gd2-perl
  45.     libhtml-clean-perl
  46.     libimage-size-perl
  47.     libio-all-perl
  48.     libperl-critic-perl
  49.     linklint
  50.     lynx
  51.     mp4h
  52.     slice
  53.     txt2html
  54.     weblint-perl
  55.     zlib1g-dev
  56.     /;
  57.  
  58. my $LOG_FN = "git-buildpackage-log.txt";
  59.  
  60. my $BASH_SAFETY = "set -e -x ; set -o pipefail ; ";
  61.  
  62. # $obj->docker( { cmd => [  'cp', "../scripts", "fcsfed:scripts", ] } );
  63. my $script = <<"EOSCRIPTTTTTTT";
  64. $BASH_SAFETY
  65. apt-get -y update
  66. apt-get -y install eatmydata sudo
  67. sudo eatmydata apt -y install build-essential chrpath cmake git-buildpackage librecode-dev perl recode @DEPS
  68. sudo adduser --disabled-password --gecos '' "$USER"
  69. sudo usermod -a -G sudo "$USER"
  70. echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
  71. EOSCRIPTTTTTTT
  72.  
  73. $obj->exe_bash_code( { code => $script, } );
  74.  
  75. $obj->docker(
  76.     { cmd => [ 'cp', "./$REPO", $obj->container() . ":$HOMEDIR/$REPO", ] } );
  77. $obj->exe_bash_code(
  78.     {
  79.         code => "$BASH_SAFETY chown -R $USER:$USER $HOMEDIR",
  80.     }
  81. );
  82.  
  83. $script = <<"EOSCRIPTTTTTTT";
  84. $BASH_SAFETY
  85. cd "$HOMEDIR/$REPO"
  86. git clean -dxf .
  87. gbp buildpackage --git-debian-branch="$BRANCH" 2>&1 | tee ~/"$LOG_FN"
  88. EOSCRIPTTTTTTT
  89.  
  90. $obj->exe_bash_code(
  91.     {
  92.         user => $USER,
  93.         code => $script,
  94.     }
  95. );
  96. $obj->docker(
  97.     { cmd => [ 'cp', $obj->container() . ":$HOMEDIR/$LOG_FN", $LOG_FN, ] } );
  98.  
  99. $obj->clean_up();
  100.  
  101. __END__
  102.  
  103. =head1 COPYRIGHT & LICENSE
  104.  
  105. Copyright 2019 by Shlomi Fish
  106.  
  107. This program is distributed under the MIT / Expat License:
  108. L<http://www.opensource.org/licenses/mit-license.php>
  109.  
  110. Permission is hereby granted, free of charge, to any person
  111. obtaining a copy of this software and associated documentation
  112. files (the "Software"), to deal in the Software without
  113. restriction, including without limitation the rights to use,
  114. copy, modify, merge, publish, distribute, sublicense, and/or sell
  115. copies of the Software, and to permit persons to whom the
  116. Software is furnished to do so, subject to the following
  117. conditions:
  118.  
  119. The above copyright notice and this permission notice shall be
  120. included in all copies or substantial portions of the Software.
  121.  
  122. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  123. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  124. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  125. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  126. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  127. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  128. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  129. OTHER DEALINGS IN THE SOFTWARE.
  130.  
  131. =cut

Raw Paste


Login or Register to edit or fork this paste. It's free.