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

FreeBSD backend: catch up with new pkg repository layout #129

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions src/asgen/backends/freebsd/fbsdpkgindex.d
Original file line number Diff line number Diff line change
Expand Up @@ -60,45 +60,44 @@ public:
{
auto pkgRoot = buildPath (rootDir, suite);
auto metaFname = buildPath (pkgRoot, "meta.conf");
string manifestFname, manifestArchive;
string dataFname;

if (!std.file.exists (metaFname)) {
logError ("Metadata file '%s' does not exist.", metaFname);
return [];
}

foreach(line; std.file.slurp!(string)(metaFname, "%s")) {
if (line.startsWith("manifests_archive")) {
// manifests_archive = "packagesite";
if (line.startsWith("data")) {
// data = "data";
auto splitResult = line.split("\"");
if (splitResult.length == 3)
manifestArchive = splitResult[1];
}
else if (line.startsWith("manifests")) {
// manifests = "packagesite.yaml";
auto splitResult = line.split("\"");
if (splitResult.length == 3)
manifestFname = splitResult[1];
if (splitResult.length == 3) {
dataFname = splitResult[1];
break;
}
}
}

auto listsTarFname = buildPath (pkgRoot, manifestArchive ~ ".pkg");
if (!std.file.exists (listsTarFname)) {
logError ("Package lists file '%s' does not exist.", listsTarFname);
auto dataTarFname = buildPath (pkgRoot, dataFname ~ ".pkg");
if (!std.file.exists (dataTarFname)) {
logError ("Package lists file '%s' does not exist.", dataTarFname);
return [];
}

ArchiveDecompressor ad;
ad.open (listsTarFname);
logDebug ("Opened: %s", listsTarFname);
ad.open (dataTarFname);
logDebug ("Opened: %s", dataTarFname);

auto d = ad.readData(manifestFname);
auto dataJson = parseJSON(assumeUTF(ad.readData(dataFname)));
if (dataJson.type != JSONType.object) {
logError ("JSON from '%s' is not an object .", dataTarFname);
return [];
}
auto pkgs = appender!(Package[]);

foreach(entry; d.split('\n')) {
auto j = parseJSON(assumeUTF(entry));
if (j.type == JSONType.object)
pkgs ~= to!Package(new FreeBSDPackage(pkgRoot, j.object));
foreach(entry; dataJson.object["packages"].array) {
if (entry.type == JSONType.object)
pkgs ~= to!Package(new FreeBSDPackage(pkgRoot, entry.object));
}

return pkgs.data;
Expand Down
Loading