View | Details | Raw Unified | Return to bug 8402
Collapse All | Expand All

(-)a/install_misc/build-pkg-file.pl (-1 / +105 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright (C) 2013 KohaAloha, NZ
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=pod
21
a script to build the ./install_misc/debian.packages file from ./debian.control
22
23
script must be run with -f/--force arg, to execute
24
25
=cut
26
27
use Modern::Perl;
28
use Data::Printer;
29
use Data::Dumper;
30
31
use Parse::Deb::Control;
32
33
use Getopt::Long;
34
my $force,;
35
my $result = GetOptions(
36
    'f|force' => \$force,
37
38
);
39
40
if ( not $force ) {
41
    print_usage();
42
    exit 0;
43
}
44
45
my $parser = Parse::Deb::Control->new('./debian/control');
46
47
my $header = <<EOF;
48
#  WARNING! This file is manually generated from executing
49
#  the './install_misc/build-pkg-file.pl script
50
#
51
#  Do not manually edit this file - you risk losing your changes
52
EOF
53
54
my $para;
55
56
foreach my $entry ( $parser->get_keys('Package') ) {
57
    my $ss = ${ $entry->{'value'} };
58
    $para = $entry if $ss =~ m/koha-common/;
59
}
60
61
my $source;
62
foreach my $entry ( $parser->get_keys('Source') ) {
63
    my $ss = ${ $entry->{'value'} };
64
    $source = $entry if $ss =~ m/koha/;
65
}
66
67
my $dep  = $para->{'para'}->{'Depends'};
68
my $bdep = $source->{'para'}->{'Build-Depends'};
69
my $a    = $dep . $bdep;
70
71
my @moo;
72
push @moo, $header;
73
74
foreach my $aa ( split '\n', $a ) {
75
    next if $aa =~ qr/\$/;
76
77
    $aa =~ s/,//;
78
    $aa =~ s/.//;
79
    $aa =~ s/^[ \t]+|[ \t]+$//g;
80
    $aa =~ s/\s.*$//;
81
82
    $aa =~ s/$/ install/;
83
    $aa .= "\n";
84
85
    push @moo, $aa if $aa !~ /\$/;
86
}
87
88
my $file = './install_misc/debian.packages';
89
open( my $fh, '>', $file );
90
91
print $fh (@moo);
92
close $fh;
93
94
sub print_usage {
95
    print <<_USAGE_;
96
a script to build the ./install_misc/debian.packages file from ./debian.control
97
98
script must be run with -f/--force arg, to execute
99
100
Parameters:
101
    --force or -f           run this script
102
_USAGE_
103
}
104
105
1;

Return to bug 8402