Просмотр исходного кода

Dpkg::BuildProfiles: Add new parse_build_profile()

Use it everywhere instead of inline code.
Guillem Jover лет назад: 11
Родитель
Сommit
1eb338d799
3 измененных файлов с 22 добавлено и 4 удалено
  1. 13 1
      scripts/Dpkg/BuildProfiles.pm
  2. 2 1
      scripts/Dpkg/Deps.pm
  3. 7 2
      scripts/t/Dpkg_BuildProfiles.t

+ 13 - 1
scripts/Dpkg/BuildProfiles.pm

@@ -19,7 +19,7 @@ use strict;
 use warnings;
 
 our $VERSION = '0.01';
-our @EXPORT_OK = qw(get_build_profiles set_build_profiles);
+our @EXPORT_OK = qw(get_build_profiles set_build_profiles parse_build_profiles);
 
 use Exporter qw(import);
 
@@ -75,6 +75,18 @@ sub set_build_profiles {
     Dpkg::BuildEnv::set('DEB_BUILD_PROFILES', join ' ', @profiles);
 }
 
+=item my @profiles = parse_build_profiles($string)
+
+Parses a build profiles specification, into an array.
+
+=cut
+
+sub parse_build_profiles {
+    my $string = shift;
+
+    return map { lc } split /\s+/, $string;
+}
+
 =back
 
 =cut

+ 2 - 1
scripts/Dpkg/Deps.pm

@@ -541,6 +541,7 @@ use warnings;
 use Carp;
 
 use Dpkg::Arch qw(debarch_is);
+use Dpkg::BuildProfiles qw(parse_build_profiles);
 use Dpkg::Version;
 use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
@@ -618,7 +619,7 @@ sub parse_string {
 	$self->{arches} = [ split(/\s+/, $5) ];
     }
     if (defined($6)) {
-	$self->{restrictions} = [ map { lc } split /\s+/, $6 ];
+	$self->{restrictions} = [ parse_build_profiles($6) ];
     }
 }
 

+ 7 - 2
scripts/t/Dpkg_BuildProfiles.t

@@ -16,12 +16,17 @@
 use strict;
 use warnings;
 
-use Test::More tests => 1;
+use Test::More tests => 2;
 
 BEGIN {
-    use_ok('Dpkg::BuildProfiles');
+    use_ok('Dpkg::BuildProfiles', qw(parse_build_profiles));
 }
 
 # TODO: Add actual test cases.
 
+my @build_profiles = qw(nocheck nodoc stage1);
+
+is(parse_build_profiles('nocheck nodoc stage1'), @build_profiles,
+   'parse build profiles');
+
 1;