-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The configuration file for the FreeBSD backend is expected to point to the Poudriere-built repository root. The ArchiveRoot property should be the path to Poudriere "data/packages" directory and Suite names correspond to its subdirectories. Here is an sample config: { "ProjectName": "FreeBSD", "ArchiveRoot": "/usr/local/poudriere/data/packages/", "Backend": "freebsd", "Suites": { "131amd64-default": { "sections": ["default"], "architectures": ["amd64"] } } } Sponsored by: Serenity Cybersecurity, LLC
- Loading branch information
Showing
6 changed files
with
234 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (C) 2023 Serenity Cyber Security, LLC | ||
* Author: Gleb Popov <[email protected]> | ||
* | ||
* Licensed under the GNU Lesser General Public License Version 3 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the license, or | ||
* (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this software. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
module asgen.backends.freebsd.fbsdpkg; | ||
|
||
import std.stdio; | ||
import std.json; | ||
import std.path; | ||
import std.string; | ||
import std.array : empty; | ||
import asgen.backends.interfaces; | ||
import asgen.logging; | ||
import asgen.zarchive; | ||
|
||
|
||
final class FreeBSDPackage : Package | ||
{ | ||
private: | ||
JSONValue pkgjson; | ||
|
||
string pkgFname; | ||
PackageKind _kind; | ||
|
||
public: | ||
this (string pkgRoot, JSONValue[string] j) | ||
{ | ||
pkgjson = j; | ||
pkgFname = buildPath (pkgRoot, pkgjson["path"].str()); // TODO: or pkgjson["repopath"] ??? | ||
_kind = PackageKind.PHYSICAL; | ||
} | ||
|
||
@property override string name () const { return pkgjson["name"].str(); } | ||
@property override string ver () const { return pkgjson["version"].str(); } | ||
@property override string arch () const { return pkgjson["arch"].str(); } | ||
@property override string maintainer () const { return pkgjson["maintainer"].str(); } | ||
@property override string getFilename () const { return pkgFname; } | ||
|
||
|
||
@property override const(string[string]) summary () const | ||
{ | ||
string[string] sums; | ||
sums["en"] = pkgjson["comment"].str(); | ||
return sums; | ||
} | ||
|
||
@property override const(string[string]) description () const | ||
{ | ||
string[string] descs; | ||
descs["en"] = pkgjson["desc"].str(); | ||
return descs; | ||
} | ||
|
||
override | ||
const(ubyte[]) getFileData (string fname) | ||
{ | ||
ArchiveDecompressor ad; | ||
ad.open (pkgFname); | ||
|
||
return ad.readData(fname); | ||
} | ||
|
||
@property override | ||
string[] contents () | ||
{ | ||
ArchiveDecompressor ad; | ||
ad.open (pkgFname); | ||
|
||
auto c = ad.readContents(); | ||
|
||
//throw new Exception(join(c, "\n")); | ||
|
||
return c; | ||
} | ||
|
||
override | ||
void finish () | ||
{ | ||
} | ||
|
||
@property override | ||
PackageKind kind () @safe pure | ||
{ | ||
return this._kind; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (C) 2023 Serenity Cyber Security, LLC | ||
* Author: Gleb Popov <[email protected]> | ||
* | ||
* Licensed under the GNU Lesser General Public License Version 3 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the license, or | ||
* (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this software. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
module asgen.backends.freebsd.fbsdpkgindex; | ||
|
||
import std.json; | ||
import std.stdio; | ||
import std.path; | ||
import std.string; | ||
import std.conv : to; | ||
import std.array : appender; | ||
import std.algorithm : remove; | ||
static import std.file; | ||
|
||
import asgen.logging; | ||
import asgen.zarchive; | ||
import asgen.backends.interfaces; | ||
import asgen.backends.freebsd.fbsdpkg; | ||
|
||
|
||
final class FreeBSDPackageIndex : PackageIndex | ||
{ | ||
|
||
private: | ||
string rootDir; | ||
Package[][string] pkgCache; | ||
|
||
public: | ||
|
||
this (string dir) | ||
{ | ||
this.rootDir = dir; | ||
if (!std.file.exists (dir)) | ||
throw new Exception ("Directory '%s' does not exist.", dir); | ||
} | ||
|
||
void release () | ||
{ | ||
pkgCache = null; | ||
} | ||
|
||
Package[] packagesFor (string suite, string section, string arch, bool withLongDescs = true) | ||
{ | ||
auto pkgRoot = buildPath (rootDir, suite); | ||
auto listsTarFname = buildPath (pkgRoot, "packagesite.pkg"); | ||
if (!std.file.exists (listsTarFname)) { | ||
logWarning ("Package lists file '%s' does not exist.", listsTarFname); | ||
return []; | ||
} | ||
|
||
ArchiveDecompressor ad; | ||
ad.open (listsTarFname); | ||
logDebug ("Opened: %s", listsTarFname); | ||
|
||
auto d = ad.readData("packagesite.yaml"); | ||
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)); | ||
} | ||
|
||
return pkgs.data; | ||
} | ||
|
||
Package packageForFile (string fname, string suite = null, string section = null) | ||
{ | ||
return null; // FIXME: not implemented | ||
} | ||
|
||
bool hasChanges (DataStore dstore, string suite, string section, string arch) | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2023 Serenity Cyber Security, LLC | ||
* Author: Gleb Popov <[email protected]> | ||
* | ||
* Licensed under the GNU Lesser General Public License Version 3 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the license, or | ||
* (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this software. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
module asgen.backends.freebsd; | ||
|
||
public import asgen.backends.freebsd.fbsdpkg; | ||
public import asgen.backends.freebsd.fbsdpkgindex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters