BuildProfiles.pm 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. package Dpkg::BuildProfiles;
  16. use strict;
  17. use warnings;
  18. our $VERSION = '0.01';
  19. our @EXPORT_OK = qw(get_build_profiles set_build_profiles);
  20. use Exporter qw(import);
  21. use Dpkg::BuildEnv;
  22. my $cache_profiles;
  23. my @build_profiles;
  24. =encoding utf8
  25. =head1 NAME
  26. Dpkg::BuildProfiles - handle build profiles
  27. =head1 DESCRIPTION
  28. The Dpkg::BuildProfiles module provides functions to handle the build
  29. profiles.
  30. =head1 FUNCTIONS
  31. =over 4
  32. =item my @profiles = get_build_profiles()
  33. Get an array with the currently active build profiles, taken from
  34. the environment variable B<DEB_BUILD_PROFILES>.
  35. =cut
  36. sub get_build_profiles {
  37. return @build_profiles if $cache_profiles;
  38. if (Dpkg::BuildEnv::has('DEB_BUILD_PROFILES')) {
  39. @build_profiles = split / /, Dpkg::BuildEnv::get('DEB_BUILD_PROFILES');
  40. }
  41. $cache_profiles = 1;
  42. return @build_profiles;
  43. }
  44. =item set_build_profiles(@profiles)
  45. Set C<@profiles> as the current active build profiles, by setting
  46. the environment variable B<DEB_BUILD_PROFILES>.
  47. =cut
  48. sub set_build_profiles {
  49. my (@profiles) = @_;
  50. @build_profiles = @profiles;
  51. Dpkg::BuildEnv::set('DEB_BUILD_PROFILES', join ' ', @profiles);
  52. }
  53. =back
  54. =cut
  55. 1;