typedef vector<pkgIndexFile *>::iterator FileIterator;
template <typename Iter> std::vector<Iter*> pkgCacheGenerator::Dynamic<Iter>::toReMap;
+bool IsDuplicateDescription(pkgCache::DescIterator Desc,
+ MD5SumValue const &CurMd5, std::string const &CurLang);
+
// CacheGenerator::pkgCacheGenerator - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* We set the dirty flag and make sure that is written to the disk */
bool pkgCacheGenerator::MergeListGroup(ListParser &List, std::string const &GrpName)
{
pkgCache::GrpIterator Grp = Cache.FindGrp(GrpName);
+ // a group has no data on it's own, only packages have it but these
+ // stanzas like this come from Translation- files to add descriptions,
+ // but without a version we don't need a description for it…
if (Grp.end() == true)
- return _error->Error("Information merge for non-existent group %s requested", GrpName.c_str());
+ return true;
Dynamic<pkgCache::GrpIterator> DynGrp(Grp);
pkgCache::PkgIterator Pkg;
// Find the right version to write the description
MD5SumValue CurMd5 = List.Description_md5();
+ std::string CurLang = List.DescriptionLanguage();
for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver)
{
Dynamic<pkgCache::DescIterator> DynDesc(Desc);
map_ptrloc *LastDesc = &Ver->DescriptionList;
-
// don't add a new description if we have one for the given
// md5 && language
- bool duplicate = false;
- for ( ; Desc.end() == false; ++Desc)
- if (MD5SumValue(Desc.md5()) == CurMd5 &&
- Desc.LanguageCode() == List.DescriptionLanguage())
- duplicate=true;
- if (duplicate == true)
+ if (IsDuplicateDescription(Desc, CurMd5, CurLang) == true)
continue;
for (Desc = Ver.DescriptionList();
// Add new description
void const * const oldMap = Map.Data();
- map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
+ map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc);
if (oldMap != Map.Data())
LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
*LastDesc = descindex;
return true;
}
- /* Record the Description data. Description data always exist in
- Packages and Translation-* files. */
+ /* Record the Description (it is not translated) */
+ MD5SumValue CurMd5 = List.Description_md5();
+ if (CurMd5.Value().empty() == true)
+ return true;
+ std::string CurLang = List.DescriptionLanguage();
+
+ /* Before we add a new description we first search in the group for
+ a version with a description of the same MD5 - if so we reuse this
+ description group instead of creating our own for this version */
+ pkgCache::GrpIterator Grp = Pkg.Group();
+ for (pkgCache::PkgIterator P = Grp.PackageList();
+ P.end() == false; P = Grp.NextPkg(P))
+ {
+ for (pkgCache::VerIterator V = P.VersionList();
+ V.end() == false; ++V)
+ {
+ if (IsDuplicateDescription(V.DescriptionList(), CurMd5, "") == false)
+ continue;
+ Ver->DescriptionList = V->DescriptionList;
+ return true;
+ }
+ }
+
+ // We haven't found reusable descriptions, so add the first description
pkgCache::DescIterator Desc = Ver.DescriptionList();
Dynamic<pkgCache::DescIterator> DynDesc(Desc);
map_ptrloc *LastDesc = &Ver->DescriptionList;
- // Skip to the end of description set
- for (; Desc.end() == false; LastDesc = &Desc->NextDesc, ++Desc);
-
- // Add new description
oldMap = Map.Data();
map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc);
if (oldMap != Map.Data())
return true;
}
/*}}}*/
+// IsDuplicateDescription /*{{{*/
+bool IsDuplicateDescription(pkgCache::DescIterator Desc,
+ MD5SumValue const &CurMd5, std::string const &CurLang)
+{
+ for ( ; Desc.end() == false; ++Desc)
+ if (MD5SumValue(Desc.md5()) == CurMd5 && Desc.LanguageCode() == CurLang)
+ return true;
+ return false;
+}
+ /*}}}*/
+
TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
setupenvironment
-configarchitecture "i386"
+configarchitecture 'i386' 'amd64'
# we need a valid locale here, otherwise the language configuration
# will be overridden by LC_ALL=C
MD5sum: 74769bfbcef9ebc4fa74f7a5271b9c08
Description-md5: d41ee493aa9fcc6cbc9ce4eb7069959c"
+PACKAGESTANZA2='Package: apt
+Priority: important
+Section: admin
+Installed-Size: 5984
+Maintainer: APT Development Team <deity@lists.debian.org>
+Architecture: amd64
+Version: 0.8.7
+Filename: pool/main/a/apt/apt_0.8.7_amd64.deb
+Size: 2210342
+MD5sum: 4a869bfbdef9ebc9fa74f7a5271e8d1a
+Description-md5: d41ee493aa9fcc6cbc9ce4eb7069959c'
echo "$PACKAGESTANZA
+Description: Advanced front-end for dpkg
+
+$PACKAGESTANZA2
Description: Advanced front-end for dpkg" > aptarchive/Packages
echo "Package: apt
APT-Dselect-Methode. Beides sind einfache und sicherere Wege,
um Pakete zu installieren und Upgrades durchzuführen.
"
+LOCALESTANZA2="$PACKAGESTANZA2
+Description-${LOCALE}: Mächtige Oberfläche für dpkg
+ Das Paket bietet dem Nutzer technisch führende Methoden für den Zugriff
+ auf den dpkg-Paketmanager. Es beinhaltet das apt-get-Werkzeug und die
+ APT-Dselect-Methode. Beides sind einfache und sicherere Wege,
+ um Pakete zu installieren und Upgrades durchzuführen.
+"
testrun() {
echo "Acquire::Languages { \"${LOCALE}\"; \"en\"; };" > rootdir/etc/apt/apt.conf.d/00languages
rm -rf rootdir/var/lib/apt/lists
setupaptarchive
testequal "$LOCALESTANZA" aptcache show apt -o Test=File-${LOCALE}
+ testequal "$LOCALESTANZA" aptcache show apt:i386 -o Test=File-${LOCALE}
+ testequal "$LOCALESTANZA2" aptcache show apt:amd64 -o Test=File-${LOCALE}
testequal "$NOLONGSTANZA" aptcache show apt -o Acquire::Languages="ww" -o Test=File-${LOCALE}
testequal "$LOCALESTANZA" aptcache show apt -o Acquire::Languages::="ww" -o Test=File-${LOCALE}
LC_ALL=C testequal "$ENGLISHSTANZA" aptcache show apt -o Test=File-${LOCALE}
testrun
echo "$PACKAGESTANZA
+Description: Advanced front-end for dpkg
+
+$PACKAGESTANZA2
Description: Advanced front-end for dpkg" > aptarchive/Packages
echo "Package: apt
It provides the apt-get utility and APT dselect method that provides a
simpler, safer way to install and upgrade packages.
"
+ENGLISHSTANZA2="$PACKAGESTANZA2
+Description-en: Advanced front-end for dpkg
+ This is Debian's next generation front-end for the dpkg package manager.
+ It provides the apt-get utility and APT dselect method that provides a
+ simpler, safer way to install and upgrade packages.
+"
testrun