Skip to content

Commit

Permalink
Merge pull request #8070 from sagemathinc/inventory-ubuntu-2404
Browse files Browse the repository at this point in the history
next/software: include ubuntu 24.04 inventory
  • Loading branch information
williamstein authored Dec 19, 2024
2 parents e27a41d + b8c28fc commit bc1f31f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/packages/next/components/landing/software-libraries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function SoftwareLibraries(props: Props) {
debounce((e) => {
setSearch(e.target.value);
}, 500),
[]
[],
);

let data: Item[];
Expand All @@ -74,7 +74,7 @@ export default function SoftwareLibraries(props: Props) {
}
}

const columns = useMemo((): Columns => {
function columns(): Columns {
const envs = Object.entries(spec);
const width = (100 - libWidthPct) / envs.length;

Expand All @@ -98,7 +98,7 @@ export default function SoftwareLibraries(props: Props) {
}

return columns;
}, [libWidthPct]);
}

return (
<div>
Expand All @@ -112,7 +112,7 @@ export default function SoftwareLibraries(props: Props) {
/>
<div style={{ overflowX: "auto", width: "100%" }}>
<Table
columns={columns}
columns={columns()}
bordered
pagination={false}
rowKey={"index"}
Expand Down
2 changes: 1 addition & 1 deletion src/packages/next/lib/landing/landing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SOFTWARE_FALLBACK, SOFTWARE_URLS } from "./software-data";
import { EnvData } from "./types";

test("3 known software environments", () => {
expect(SOFTWARE_ENV_NAMES.length).toBe(3);
expect(SOFTWARE_ENV_NAMES.length).toBe(4);
});

describe("Download URLs", () => {
Expand Down
4 changes: 4 additions & 0 deletions src/packages/next/lib/landing/software-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { EnvData } from "./types";
import SOFTWARE_1804 from "software-inventory/18.04.json";
import SOFTWARE_2004 from "software-inventory/20.04.json";
import SOFTWARE_2204 from "software-inventory/22.04.json";
import SOFTWARE_2404 from "software-inventory/24.04.json";


export const SOFTWARE_URLS: { [key in SoftwareEnvNames]: string } = fromPairs(
SOFTWARE_ENV_NAMES.map((name) => [
Expand All @@ -29,4 +31,6 @@ export const SOFTWARE_FALLBACK: { [key in SoftwareEnvNames]: EnvData } = {
"18.04": SOFTWARE_1804 as EnvData,
"20.04": SOFTWARE_2004 as EnvData,
"22.04": SOFTWARE_2204 as EnvData,
"24.04": SOFTWARE_2404 as EnvData,

} as const;
1 change: 0 additions & 1 deletion src/packages/next/lib/landing/software-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ async function downloadInventoryJson(name: SoftwareEnvNames): Promise<EnvData> {
}

// load the current version of the software specs – if there is a problem, use the locally stored files as fallback.
// both files go hand-in-hand, hence either both work or both are the fallback!
async function fetchInventory(): Promise<SoftwareEnvironments> {
// for development, set the env variable to directory, where this files are
const localSpec = process.env.COCALC_SOFTWARE_ENVIRONMENTS;
Expand Down
9 changes: 5 additions & 4 deletions src/packages/next/pages/software/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,11 @@ export default function Software({ customize }) {
<A href="https://en.wikipedia.org/wiki/Ubuntu">
Ubuntu {SOFTWARE_ENV_DEFAULT}
</A>
, but there are also {SOFTWARE_ENV_NAMES.length - 1} older variants
available. Only the newest variant is actively maintained and regularly
updated. The older ones are deprected and contain older software for
backwards compatibility and historic purposes.
, but there are also {SOFTWARE_ENV_NAMES.length - 1} other variants
available. The default variant is actively maintained and regularly
updated – others are for testing or are deprected. The reason to pick an
older environment is backwards compatibility with older software,
running an older project of yours, or for historic purposes.
</p>
</>
);
Expand Down
27 changes: 24 additions & 3 deletions src/packages/next/software-inventory/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,36 @@ set -e
dist="lib/software-inventory"
mkdir -p $dist

# don't update inventory files if they're symlinks – used for local testing
for name in "18.04" "20.04" "22.04"; do
# download and copy a single file
download_and_copy() {
name=$1
fn="software-inventory-$name.json"
local="software-inventory/$name.json"
targ="$dist/$name.json"

if [[ ! -L "$local" ]]; then
curl --silent --show-error --fail "https://storage.googleapis.com/cocalc-compute-environment/$fn" -o "$local"
if ! curl --silent --show-error --fail "https://storage.googleapis.com/cocalc-compute-environment/$fn" -o "$local"; then
echo "Error: Failed to download $fn" >&2
return 1
fi
fi

cp -v "$local" "$targ"
}

# we now run all downloads in parallel, wait for them, and check if any of them failed...
pids=()

# Start downloads in parallel
for name in "18.04" "20.04" "22.04" "24.04"; do
download_and_copy "$name" &
pids+=($!)
done

# Wait for all background processes to finish
for pid in "${pids[@]}"; do
if ! wait $pid; then
echo "Error: One or more downloads failed" >&2
exit 1
fi
done
2 changes: 1 addition & 1 deletion src/packages/util/consts/software-envs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export type LanguageName = (typeof LANGUAGE_NAMES)[number];

// sort this starting from the newest to the oldest – appears in the UI, e.g. on that /software/index page
// TODO: after https://github.com/sagemathinc/cocalc/pull/6284 has been merged, make 22.04 the first entry in that list
export const SOFTWARE_ENV_NAMES = ["22.04", "20.04", "18.04"] as const;
export const SOFTWARE_ENV_NAMES = ["24.04", "22.04", "20.04", "18.04"] as const;
export type SoftwareEnvNames = (typeof SOFTWARE_ENV_NAMES)[number];
export const SOFTWARE_ENV_DEFAULT: SoftwareEnvNames = "22.04";

0 comments on commit bc1f31f

Please sign in to comment.