[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Profile support in apt



Hi,

On Tue, Jan 29, 2013 at 10:40:53PM +0100, David Kalnischkies wrote:
> Expect the myriad of environment settings which need to be parsed for
> support of each and every possible language setup [I know of].
> (apt-pkg/aptconfiguration.cc – APT::Configuration::getLanguages)
> 
> I would go with a similar setup here, just less complicated by taking
> the first thing which exists:
> - APT::Build-Profile "foo,bar";
> - APT::Build-Profile { "foo"; "bar"; };
> - DEB_BUILD_PROFILE=foo,bar
> Maybe go fancy in supporting a special "environment" name which
> extends to whatever is in the environment variable, so you could do
> silly configs like APT::Build-Profile { "nodocs"; "environment"; } and
> DEB_BUILD_PROFILE="cross" apt-config dump APT::Build-Profile
> would produce: APT::Build-Profile { "nodocs"; "cross"; };
> (I just used "environment" here as it is used by languages – it is just
>  to unlikely to be a valid language code – use whatever fits best)
> 
> I think I would be against including the environment always in the list
> as it is against how the other lists are handled, yet, there are only
> two (Acquire::Languages, APT::Architectures) and both are from me,
> so I might be biased (and others like Acquire::CompressionTypes
>  behaves a bit differently too, so just choose something which fits and
>  write some documentation to convince everyone).

As wookey already stated in his email, lets keep things simple for now
and let sbuild pass -o APT::Build-Profile=stage1 to apt.

> Yet, I haven't seen the final syntax yet, just various proposals so be
> prepared that at least I will be not in favor of merging something which
> isn't supported in an uploaded mainline-debian dpkg yet – and feedback
> might be sparse for the moment as we have still items open for wheezy
> so jessie topics might not be that interesting just yet.

Sure, it's very understandable that it is too early to have such a patch
in the next apt release. I attached the patch anyways so that you guys
can have a look and tell us what you would like to be different in build
profile handling in apt. This way we can maintain a patch to apt until a
final decision has been made. I think if somebody proposes a shiny new
feature, it is always best to also supply the code for it (talk is
cheap, show me the code!). Even more so when the patch is actually this
tiny. So find attached my latest attempt to implement this for apt.
Comments welcome :)

The current two proposals for build profiles are using <!stage1> syntax
[1] or extending the architecture syntax [2]. The patch implements the
former. If you have arguments for/against either, please voice them on
debian-devel [2] so that we can have a decision about that soon-ish. :)

Thanks!

cheers, josch

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661538#131
[2] https://lists.debian.org/debian-devel/2013/01/msg00366.html
=== modified file 'apt-pkg/deb/deblistparser.cc'
--- apt-pkg/deb/deblistparser.cc	2013-01-08 15:35:57 +0000
+++ apt-pkg/deb/deblistparser.cc	2013-01-30 07:59:52 +0000
@@ -473,6 +473,7 @@
 const char *debListParser::ParseDepends(const char *Start,const char *Stop,
 					string &Package,string &Ver,
 					unsigned int &Op, bool const &ParseArchFlags,
+					bool const &ParseProfileFlags,
 					bool const &StripMultiArch)
 {
    // Strip off leading space
@@ -481,7 +482,8 @@
    // Parse off the package name
    const char *I = Start;
    for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
-	*I != ',' && *I != '|' && *I != '[' && *I != ']'; I++);
+	*I != ',' && *I != '|' && *I != '[' && *I != ']' &&
+	*I != '<' && *I != '>'; I++);
    
    // Malformed, no '('
    if (I != Stop && *I == ')')
@@ -598,6 +600,75 @@
       for (;I != Stop && isspace(*I) != 0; I++);
    }
 
+   if (ParseProfileFlags == true)
+   {
+       std::vector<string> profiles;
+
+       // accept non-list order as override setting
+       string const overrideProfile = _config->Find("APT::Build-Profile", "");
+
+       if (overrideProfile.empty() == false)
+           profiles.push_back(overrideProfile);
+
+       std::vector<string> p = _config->FindVector("APT::Build-Profile");
+       profiles.insert(profiles.end(), p.begin(), p.end());
+
+       // Parse a build profile
+       if (I != Stop && *I == '<')
+       {
+           ++I;
+           // malformed
+           if (unlikely(I == Stop))
+               return 0;
+
+           const char *End = I;
+           bool Found = false;
+           bool NegProfile = false;
+           while (I != Stop)
+           {
+               // look for whitespace or ending '>'
+               for (;End != Stop && !isspace(*End) && *End != '>'; ++End);
+
+               if (unlikely(End == Stop))
+                   return 0;
+
+               if (*I == '!')
+               {
+                   NegProfile = true;
+                   ++I;
+               }
+
+               std::string profile(I, End);
+               if (profile.empty() == false && profiles.empty() == false &&
+                      std::find(profiles.begin(), profiles.end(), profile) != profiles.end())
+               {
+                   Found = true;
+                   if (I[-1] != '!')
+                       NegProfile = false;
+                   // we found a match, so fast-forward to the end of the wildcards
+                   for (; End != Stop && *End != '>'; ++End);
+               }
+
+               if (*End++ == '>') {
+                   I = End;
+                   break;
+               }
+
+               I = End;
+               for (;I != Stop && isspace(*I) != 0; I++);
+           }
+
+           if (NegProfile == true)
+               Found = !Found;
+
+           if (Found == false)
+               Package = ""; /* not for this profile */
+       }
+
+       // Skip whitespace
+       for (;I != Stop && isspace(*I) != 0; I++);
+   }
+
    if (I != Stop && *I == '|')
       Op |= pkgCache::Dep::Or;
    
@@ -631,7 +702,7 @@
       string Version;
       unsigned int Op;
 
-      Start = ParseDepends(Start,Stop,Package,Version,Op,false,!MultiArchEnabled);
+      Start = ParseDepends(Start,Stop,Package,Version,Op,false,false,!MultiArchEnabled);
       if (Start == 0)
 	 return _error->Error("Problem parsing dependency %s",Tag);
       size_t const found = Package.rfind(':');

=== modified file 'apt-pkg/deb/deblistparser.h'
--- apt-pkg/deb/deblistparser.h	2011-12-13 00:22:38 +0000
+++ apt-pkg/deb/deblistparser.h	2013-01-30 07:51:56 +0000
@@ -76,6 +76,7 @@
    static const char *ParseDepends(const char *Start,const char *Stop,
 			    std::string &Package,std::string &Ver,unsigned int &Op,
 			    bool const &ParseArchFlags = false,
+			    bool const &ParseProfileFlags = false,
 			    bool const &StripMultiArch = true);
    static const char *ConvertRelation(const char *I,unsigned int &Op);
 

=== modified file 'apt-pkg/deb/debsrcrecords.cc'
--- apt-pkg/deb/debsrcrecords.cc	2011-09-21 17:31:03 +0000
+++ apt-pkg/deb/debsrcrecords.cc	2013-01-30 07:38:50 +0000
@@ -90,7 +90,7 @@
       while (1)
       {
          Start = debListParser::ParseDepends(Start, Stop, 
-		     rec.Package,rec.Version,rec.Op,true, StripMultiArch);
+		     rec.Package,rec.Version,rec.Op,true,true, StripMultiArch);
 	 
          if (Start == 0) 
             return _error->Error("Problem parsing dependency: %s", fields[I]);


Reply to: