OSDN Git Service

Establish mapping from release tarname to source tarname.
[mingw/mingw-get.git] / src / pkgreqs.cpp
index 0a585e8..d71397d 100644 (file)
@@ -327,6 +327,16 @@ enum inherit_mode
   INHERIT_ALL          /* "%" matches the entire version string      */
 };
 
+static inline
+bool inherited_requirement( const char *field )
+{
+  /* Local helper function to identify a template field which is
+   * specified exactly as "%", and therefore must inherit its value
+   * from the referring package specification.
+   */
+  return ((field != NULL) && (field[0] == '%') && (field[1] == '\0'));
+}
+
 static
 enum inherit_mode inherited( const char *ver, const char *bld )
 {
@@ -341,7 +351,7 @@ enum inherit_mode inherited( const char *ver, const char *bld )
   /* Noting that the "%" wildcard must represent the respective part
    * of the version specification in its entirety...
    */
-  if( (ver != NULL) && (ver[0] == '%') && (ver[1] == '\0') )
+  if( inherited_requirement( ver ) )
     /*
      * ...flag a match on the "major.minor.patch" specification.
      */
@@ -434,6 +444,18 @@ const char *requirement( const char *wanted, pkgSpecs *dep )
      */
     id.SetSubSystemBuild( dep->GetSubSystemBuild() );
 
+  /* To establish association between source and binary package names,
+   * we may also need to propagate archive and compression type fields...
+   */
+  if( inherited_requirement( id.GetPackageFormat()) )
+  {
+    id.SetPackageFormat( dep->GetPackageFormat() );
+    if( id.GetCompressionType() == NULL )
+      id.SetCompressionType( dep->GetCompressionType() );
+  }
+  else if( inherited_requirement( id.GetCompressionType()) )
+    id.SetCompressionType( dep->GetCompressionType() );
+
   /* Finally, reconstitute the canonical tarname representation of the
    * specification, from its decomposed representation; (as a side effect,
    * this automatically places the return string on the heap).
@@ -507,4 +529,14 @@ const char * pkgActionItem::SetRequirements( pkgXmlNode *req, pkgSpecs *dep )
   return (min_wanted == NULL) ? max_wanted : min_wanted;
 }
 
+EXTERN_C const char *pkgAssociateName( const char *map, const char *from )
+{
+  /* Public function for derivation of the name of an associate package,
+   * such as a source package, from the name of the primary package, based
+   * on the relationship specified by the template passed via "map".
+   */
+  pkgSpecs ref( from );
+  return requirement( map, &ref );
+}
+
 /* $RCSfile$: end of file */