-
Notifications
You must be signed in to change notification settings - Fork 4
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
http_server: serve license files #76
Changes from all commits
9914fb3
1e0a722
4388475
5224a73
369c569
6a8076a
7c67d61
1fe79f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
PACKAGE NAME: tacd | ||
PACKAGE VERSION: 0.1.0+gitAUTOINC+803b2084b2 | ||
RECIPE NAME: tacd | ||
LICENSE: GPL-2.0-or-later | ||
|
||
PACKAGE NAME: tacd-webinterface | ||
PACKAGE VERSION: 0.1.0+gitAUTOINC+803b2084b2 | ||
RECIPE NAME: tacd-webinterface | ||
LICENSE: GPL-2.0-or-later |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import fs from "node:fs"; | ||
import ReactDOM from "react-dom/client"; | ||
|
||
import { parse_manifest, package_table } from "./Legal"; | ||
|
||
const manifest_ref = [ | ||
{ | ||
package_name: "tacd", | ||
version: "0.1.0+gitAUTOINC+803b2084b2", | ||
recipe_name: "tacd", | ||
license: "GPL-2.0-or-later", | ||
}, | ||
{ | ||
package_name: "tacd-webinterface", | ||
version: "0.1.0+gitAUTOINC+803b2084b2", | ||
recipe_name: "tacd-webinterface", | ||
license: "GPL-2.0-or-later", | ||
}, | ||
]; | ||
|
||
it("parses the manifest", () => { | ||
const manifest_raw = fs.readFileSync( | ||
"../demo_files/usr/share/common-licenses/license.manifest", | ||
"utf-8", | ||
); | ||
|
||
const manifest = parse_manifest(manifest_raw); | ||
|
||
expect(manifest).toEqual(manifest_ref); | ||
}); | ||
|
||
it("renders", () => { | ||
const div = document.createElement("div"); | ||
const root = ReactDOM.createRoot(div); | ||
|
||
const manifest_table = package_table(manifest_ref); | ||
|
||
root.render(manifest_table); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
// This file is part of tacd, the LXA TAC system daemon | ||
// Copyright (C) 2024 Pengutronix e.K. | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; either version 2 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program 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 General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, write to the Free Software Foundation, Inc., | ||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
import Container from "@cloudscape-design/components/container"; | ||
import Header from "@cloudscape-design/components/header"; | ||
import Table from "@cloudscape-design/components/table"; | ||
import Link from "@cloudscape-design/components/link"; | ||
import SpaceBetween from "@cloudscape-design/components/space-between"; | ||
|
||
import { useEffect, useState } from "react"; | ||
|
||
type Package = { | ||
package_name: string; | ||
version: string; | ||
recipe_name: string; | ||
license: string; | ||
}; | ||
|
||
export function parse_manifest(text: string) { | ||
let packages: Package[] = []; | ||
|
||
// The content of `text` looks something like this: | ||
// | ||
// PACKAGE NAME: tacd | ||
// PACKAGE VERSION: 1.0.0 | ||
// RECIPE NAME: tacd | ||
// LICENSE: GPL-2.0-or-later | ||
// | ||
// PACKAGE NAME: tacd-webinterface | ||
// ... | ||
|
||
for (var group of text.split("\n\n")) { | ||
let pkg: Package = { | ||
package_name: "", | ||
version: "", | ||
recipe_name: "", | ||
license: "", | ||
}; | ||
|
||
for (var line of group.split("\n")) { | ||
if (line.startsWith("PACKAGE NAME: ")) { | ||
pkg.package_name = line.replace("PACKAGE NAME: ", ""); | ||
} | ||
if (line.startsWith("PACKAGE VERSION: ")) { | ||
pkg.version = line.replace("PACKAGE VERSION: ", ""); | ||
} | ||
if (line.startsWith("RECIPE NAME: ")) { | ||
pkg.recipe_name = line.replace("RECIPE NAME: ", ""); | ||
} | ||
if (line.startsWith("LICENSE: ")) { | ||
pkg.license = line.replace("LICENSE: ", ""); | ||
} | ||
} | ||
|
||
if (pkg.package_name && pkg.version && pkg.recipe_name && pkg.license) { | ||
packages.push(pkg); | ||
} | ||
} | ||
|
||
return packages; | ||
} | ||
|
||
export function package_table(packages?: Package[]) { | ||
return ( | ||
<Table | ||
header={ | ||
<Header | ||
variant="h3" | ||
description="Software packages used on this LXA TAC" | ||
> | ||
Packages | ||
</Header> | ||
} | ||
columnDefinitions={[ | ||
{ | ||
id: "package_name", | ||
header: "Package Name", | ||
cell: (p) => p.package_name, | ||
}, | ||
{ | ||
id: "version", | ||
header: "Version", | ||
cell: (p) => p.version, | ||
}, | ||
{ | ||
id: "recipe_name", | ||
header: "Recipe Name", | ||
cell: (p) => p.recipe_name, | ||
}, | ||
{ | ||
id: "license", | ||
header: "License", | ||
cell: (p) => ( | ||
<Link href={"/docs/legal/files/" + p.recipe_name}>{p.license}</Link> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I first thought that we could just set the mime type in the link on the front end, but we also generate a file listing. So you're approach is probably a good abstraction. |
||
), | ||
}, | ||
]} | ||
items={packages || []} | ||
loading={packages === undefined} | ||
sortingDisabled | ||
resizableColumns | ||
stickyHeader | ||
trackBy="package_name" | ||
/> | ||
); | ||
} | ||
|
||
function PackageList() { | ||
const [packages, setPackages] = useState<Package[]>(); | ||
|
||
useEffect(() => { | ||
fetch("/docs/legal/license.manifest").then((response) => { | ||
if (response.ok) { | ||
response.text().then((text) => setPackages(parse_manifest(text))); | ||
} | ||
}); | ||
}, []); | ||
|
||
return package_table(packages); | ||
} | ||
|
||
export default function Legal() { | ||
return ( | ||
<SpaceBetween size="m"> | ||
<Header | ||
variant="h1" | ||
description="Information regarding your rights as an LXA TAC software user" | ||
> | ||
LXA TAC / Legal Information | ||
</Header> | ||
|
||
<Container | ||
header={ | ||
<Header | ||
variant="h2" | ||
description="Where to find the source code that makes up the LXA TAC software" | ||
> | ||
Availability of Source Code | ||
</Header> | ||
} | ||
> | ||
<p> | ||
The LXA TAC software uses many pieces of free and open source | ||
software. A list of these pieces of software, along with their version | ||
number and their respective software license, is shown below. | ||
</p> | ||
|
||
<p> | ||
Linux Automation GmbH provides all software components required to | ||
build your own LXA TAC software bundles in the form of a public Yocto | ||
Layer:{" "} | ||
<Link href="https://github.com/linux-automation/meta-lxatac"> | ||
linux-automation/meta-lxatac | ||
</Link> | ||
. | ||
</p> | ||
|
||
<p> | ||
To comply with the terms of copyleft licenses like the GPL we also | ||
provide copies of their sources, along with the applied patches on our{" "} | ||
<Link href="https://downloads.linux-automation.com/lxatac/software/"> | ||
download server | ||
</Link> | ||
. | ||
</p> | ||
</Container> | ||
|
||
<PackageList /> | ||
</SpaceBetween> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How stable is the format generated by
poky/meta/classes-recipe/license_image.bbclass
? How hard would it be to have some kind of unit-test against a recent license file?