merged -r 1920..1922 from lp:~donkult/apt/sid
authorMichael Vogt <michael.vogt@ubuntu.com>
Thu, 10 Dec 2009 20:48:54 +0000 (21:48 +0100)
committerMichael Vogt <michael.vogt@ubuntu.com>
Thu, 10 Dec 2009 20:48:54 +0000 (21:48 +0100)
debian/changelog
doc/apt-ftparchive.1.xml
ftparchive/writer.cc
ftparchive/writer.h
test/libapt/run-tests.sh [new file with mode: 0755]

index c4a6d07..0696541 100644 (file)
@@ -83,6 +83,8 @@ apt (0.7.25) UNRELEASED; urgency=low
       thanks Carl Chenet! (Closes: #521289)
     - print an error and exit if python-apt is not installed,
       thanks Carl Chenet! (Closes: #521284)
+  * ftparchive/writer.{cc,h}:
+    - add APT::FTPArchive::LongDescription to be able to disable them
 
   [ Chris Leick ]
   * doc/ various manpages:
index d4d77c6..d47df95 100644 (file)
@@ -15,7 +15,7 @@
    &apt-email;
    &apt-product;
    <!-- The last update date -->
-   <date>29 February 2004</date>
+   <date>17 August 2009</date>
  </refentryinfo>
  
  <refmeta>
@@ -543,7 +543,16 @@ for i in Sections do
      Make the caching databases read only. 
      Configuration Item: <literal>APT::FTPArchive::ReadOnlyDB</literal>.</para></listitem>
      </varlistentry>   
-   
+
+     <varlistentry><term><option>APT::FTPArchive::LongDescription</option></term>
+     <listitem><para>
+     This configuration option defaults to "<literal>true</literal>" and should only be set to
+     <literal>"false"</literal> if the Archive generated with &apt-ftparchive; also provides
+     <filename>Translation</filename> files. Note that it is currently not possible to create these
+     files with <command>apt-ftparchive</command>.
+     </para></listitem>
+     </varlistentry>
+
      &apt-commonoptions;
      
    </variablelist>
index 293e851..b2ebdca 100644 (file)
@@ -308,6 +308,7 @@ PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides,
    DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
    DoContents = _config->FindB("APT::FTPArchive::Contents",true);
    NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false);
+   LongDescription = _config->FindB("APT::FTPArchive::LongDescription",true);
 
    if (Db.Loaded() == false)
       DoContents = false;
@@ -414,10 +415,18 @@ bool PackagesWriter::DoPackage(string FileName)
       NewFileName = FileName;
    if (PathPrefix.empty() == false)
       NewFileName = flCombine(PathPrefix,NewFileName);
-          
+
+   /* Configuration says we don't want to include the long Description
+      in the package file - instead we want to ship a separated file */
+   string desc;
+   if (LongDescription == false) {
+      desc = Tags.FindS("Description").append("\n");
+      OverItem->FieldOverride["Description"] = desc.substr(0, desc.find('\n')).c_str();
+   }
+
    // This lists all the changes to the fields we are going to make.
    // (7 hardcoded + maintainer + suggests + end marker)
-   TFRewriteData Changes[6+2+OverItem->FieldOverride.size()+1];
+   TFRewriteData Changes[6+2+OverItem->FieldOverride.size()+1+1];
 
    unsigned int End = 0;
    SetTFRewriteData(Changes[End++], "Size", Size);
@@ -429,6 +438,14 @@ bool PackagesWriter::DoPackage(string FileName)
    SetTFRewriteData(Changes[End++], "Status", 0);
    SetTFRewriteData(Changes[End++], "Optional", 0);
 
+   string DescriptionMd5;
+   if (LongDescription == false) {
+      MD5Summation descmd5;
+      descmd5.Add(desc.c_str());
+      DescriptionMd5 = descmd5.Result().Value();
+      SetTFRewriteData(Changes[End++], "Description-md5", DescriptionMd5.c_str());
+   }
+
    // Rewrite the maintainer field if necessary
    bool MaintFailed;
    string NewMaint = OverItem->SwapMaint(Tags.FindS("Maintainer"),MaintFailed);
index 6e161c7..e764389 100644 (file)
@@ -86,6 +86,7 @@ class PackagesWriter : public FTWScanner
    bool DoSHA256;
    bool NoOverride;
    bool DoContents;
+   bool LongDescription;
 
    // General options
    string PathPrefix;
diff --git a/test/libapt/run-tests.sh b/test/libapt/run-tests.sh
new file mode 100755 (executable)
index 0000000..365bbe2
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+echo "Compiling the tests ..."
+make
+echo "Running all testcases ..."
+PATH=$(pwd)/../../build/bin
+for testapp in $(/bin/ls ${PATH}/*_libapt_test)
+do
+       echo -n "Testing with \033[1;35m$(/usr/bin/basename ${testapp})\033[0m ... "
+       LD_LIBRARY_PATH=${PATH} ${testapp} && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m"
+done