]> granicus.if.org Git - fortune-mod/blob - scripts/debian-packaging/docker-test.pl
update the code - to build debian pkg . not tested
[fortune-mod] / scripts / debian-packaging / docker-test.pl
1 #! /usr/bin/env perl
2 #
3 # Short description for docker-test.pl
4 #
5 # Author Shlomi Fish <shlomif@cpan.org>
6 # Version 0.0.1
7 # Copyright (C) 2019 Shlomi Fish <shlomif@cpan.org>
8 #
9 use strict;
10 use warnings;
11 use 5.014;
12 use autodie;
13
14 use Path::Tiny qw/ path tempdir tempfile cwd /;
15
16 sub do_system
17 {
18     my ($args) = @_;
19
20     my $cmd = $args->{cmd};
21     print "Running [@$cmd]\n";
22     if ( system(@$cmd) )
23     {
24         die "Running [@$cmd] failed!";
25     }
26 }
27
28 my @deps;    #= map { /^BuildRequires:\s*(\S+)/ ? ("'$1'") : () }
29
30 # path("freecell-solver.spec.in")->lines_utf8;
31 my $SYS       = "debian:sid";
32 my $CONTAINER = "fortune-mod--deb--test-build";
33 do_system( { cmd => [ 'docker', 'pull', $SYS ] } );
34 do_system(
35     { cmd => [ 'docker', 'run', "-t", "-d", "--name", $CONTAINER, $SYS, ] } );
36 my $REPO = 'fortune-mod';
37 my $URL  = "https://salsa.debian.org/shlomif-guest/$REPO";
38 if ( !-e $REPO )
39 {
40     do_system( { cmd => [ "git", "clone", $URL, ] } );
41 }
42 my $cwd = cwd;
43 chdir "./$REPO";
44 do_system( { cmd => [ "git", "pull", "--ff-only", ] } );
45 chdir $cwd;
46 do_system( { cmd => [ 'docker', 'cp', "./$REPO", "$CONTAINER:$REPO", ] } );
47
48 my $LOG_FN = "git-buildpackage-log.txt";
49
50 # do_system( { cmd => [ 'docker', 'cp', "../scripts", "fcsfed:scripts", ] } );
51 my $script = <<"EOSCRIPTTTTTTT";
52 set -e -x
53 sudo apt -y install build-essential cmake git-buildpackage perl
54 cd "$REPO"
55 git clean -dxf .
56 gbp buildpackage 2>&1 | tee ~/"$LOG_FN"
57 EOSCRIPTTTTTTT
58
59 do_system(
60     { cmd => [ 'docker', 'exec', $CONTAINER, 'bash', '-c', $script, ] } );
61 do_system( { cmd => [ 'docker', 'cp', "$CONTAINER:$LOG_FN", $LOG_FN, ] } );
62
63 do_system( { cmd => [ 'docker', 'stop', $CONTAINER, ] } );
64 do_system( { cmd => [ 'docker', 'rm',   $CONTAINER, ] } );
65
66 __END__
67
68 =head1 COPYRIGHT & LICENSE
69
70 Copyright 2019 by Shlomi Fish
71
72 This program is distributed under the MIT / Expat License:
73 L<http://www.opensource.org/licenses/mit-license.php>
74
75 Permission is hereby granted, free of charge, to any person
76 obtaining a copy of this software and associated documentation
77 files (the "Software"), to deal in the Software without
78 restriction, including without limitation the rights to use,
79 copy, modify, merge, publish, distribute, sublicense, and/or sell
80 copies of the Software, and to permit persons to whom the
81 Software is furnished to do so, subject to the following
82 conditions:
83
84 The above copyright notice and this permission notice shall be
85 included in all copies or substantial portions of the Software.
86
87 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
88 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
89 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
90 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
91 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
92 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
93 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
94 OTHER DEALINGS IN THE SOFTWARE.
95
96 =cut