OLD | NEW |
| (Empty) |
1 # Copyright © 2013 Guillem Jover <guillem@debian.org> | |
2 # | |
3 # This program is free software; you can redistribute it and/or modify | |
4 # it under the terms of the GNU General Public License as published by | |
5 # the Free Software Foundation; either version 2 of the License, or | |
6 # (at your option) any later version. | |
7 # | |
8 # This program is distributed in the hope that it will be useful, | |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 # GNU General Public License for more details. | |
12 # | |
13 # You should have received a copy of the GNU General Public License | |
14 # along with this program. If not, see <https://www.gnu.org/licenses/>. | |
15 | |
16 package Dpkg::BuildProfiles; | |
17 | |
18 use strict; | |
19 use warnings; | |
20 | |
21 our $VERSION = '0.01'; | |
22 our @EXPORT_OK = qw(get_build_profiles set_build_profiles); | |
23 | |
24 use Exporter qw(import); | |
25 | |
26 use Dpkg::BuildEnv; | |
27 | |
28 my $cache_profiles; | |
29 my @build_profiles; | |
30 | |
31 =encoding utf8 | |
32 | |
33 =head1 NAME | |
34 | |
35 Dpkg::BuildProfiles - handle build profiles | |
36 | |
37 =head1 DESCRIPTION | |
38 | |
39 The Dpkg::BuildProfiles module provides functions to handle the build | |
40 profiles. | |
41 | |
42 =head1 FUNCTIONS | |
43 | |
44 =over 4 | |
45 | |
46 =item my @profiles = get_build_profiles() | |
47 | |
48 Get an array with the currently active build profiles, taken from | |
49 the environment variable B<DEB_BUILD_PROFILES>. | |
50 | |
51 =cut | |
52 | |
53 sub get_build_profiles { | |
54 return @build_profiles if $cache_profiles; | |
55 | |
56 if (Dpkg::BuildEnv::has('DEB_BUILD_PROFILES')) { | |
57 @build_profiles = split / /, Dpkg::BuildEnv::get('DEB_BUILD_PROFILES'); | |
58 } | |
59 $cache_profiles = 1; | |
60 | |
61 return @build_profiles; | |
62 } | |
63 | |
64 =item set_build_profiles(@profiles) | |
65 | |
66 Set C<@profiles> as the current active build profiles, by setting | |
67 the environment variable B<DEB_BUILD_PROFILES>. | |
68 | |
69 =cut | |
70 | |
71 sub set_build_profiles { | |
72 my (@profiles) = @_; | |
73 | |
74 @build_profiles = @profiles; | |
75 Dpkg::BuildEnv::set('DEB_BUILD_PROFILES', join ' ', @profiles); | |
76 } | |
77 | |
78 =back | |
79 | |
80 =cut | |
81 | |
82 1; | |
OLD | NEW |