Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu: Don't reference all packages, just the ones we need (langpacks) #23

Merged
merged 1 commit into from Sep 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -39,12 +39,12 @@ extern (C) char *bindtextdomain (const char *domainname, const char *dirName) no

class UbuntuPackage : DebPackage
{
this (string pname, string pver, string parch, string globalTmpDir, ref Array!Package allPackages)
this (string pname, string pver, string parch, string globalTmpDir, ref Array!Package langpacks)
{
this.globalTmpDir = globalTmpDir;
this.langpackDir = buildPath (globalTmpDir, "langpacks");
this.localeDir = buildPath (langpackDir, "locales");
this.allPackages = allPackages;
this.langpacks = langpacks;
super (pname, pver, parch);
}

@@ -78,7 +78,7 @@ private:
string langpackDir;
string localeDir;
string[] langpackLocales;
Array!Package allPackages;
Array!Package langpacks;

private void extractLangpacks ()
{
@@ -97,8 +97,8 @@ private:

langpackDir.mkdirRecurse ();

foreach (pkg; allPackages) {
if (!pkg.name.startsWith ("language-pack") || pkg.name in extracted)
foreach (ref pkg; langpacks) {
if (pkg.name in extracted)
continue;

auto upkg = to!UbuntuPackage (pkg);
@@ -109,6 +109,9 @@ private:
extracted[pkg.name] = true;
}

// get back the memory
langpacks.clear;

auto supportedd = buildPath (langpackDir, "var", "lib", "locales", "supported.d");

localeDir.mkdirRecurse ();
@@ -133,6 +136,9 @@ private:
scope (exit) wait (pid);
}
}
} else {
// we don't need it; we've already extracted the langpacks
langpacks.clear;
}

if (langpackLocales is null)
@@ -30,34 +30,43 @@ class UbuntuPackageIndex : DebianPackageIndex
{

private:
Array!Package allPackages;
Array!Package langpacks;

public:
this (string dir)
{
/*
* UbuntuPackage needs to extract the langpacks, so we give it an array
* of all packages. We don't do this here, as you migh think makes
* sense, because it is a very expensive operation and we want to avoid
* doing it if it's not necessary (when no packages being processed are
* using langpacks).
* of langpacks. There is a small overhead when computing this array
* which might be unnecessary if no processed packages are using
* langpacks, but otherwise we need to keep a reference to all packages
* around, which is very expensive.
*/
allPackages = make!(Array!Package);
langpacks = make!(Array!Package);
super (dir);
}

override
DebPackage newPackage (string name, string ver, string arch)
{
return new UbuntuPackage (name, ver, arch, tmpDir, allPackages);
return new UbuntuPackage (name, ver, arch, tmpDir, langpacks);
}

override
Package[] packagesFor (string suite, string section, string arch)
{
import std.string : startsWith;

auto pkgs = super.packagesFor (suite, section, arch);
auto pkgslangpacks = appender!(Package[]);

foreach (ref pkg; pkgs) {
if (pkg.name.startsWith ("language-pack-"))
pkgslangpacks ~= pkg;
}

langpacks ~= pkgslangpacks.data;

allPackages ~= pkgs;
return pkgs;
}
}