From 9121fc64ebe1e185ee163c5416c031a406edcffb Mon Sep 17 00:00:00 2001 From: Harald Schilly Date: Wed, 18 Dec 2024 16:25:50 +0100 Subject: [PATCH 1/2] next/software: include ubuntu 24.04 inventory; download inventory files in parallel --- src/packages/next/lib/landing/landing.test.ts | 2 +- .../next/lib/landing/software-data.ts | 4 +++ src/packages/next/pages/software/index.tsx | 9 ++++--- src/packages/next/software-inventory/setup.sh | 27 ++++++++++++++++--- src/packages/util/consts/software-envs.ts | 2 +- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/packages/next/lib/landing/landing.test.ts b/src/packages/next/lib/landing/landing.test.ts index f843271b15..2c3f248df1 100644 --- a/src/packages/next/lib/landing/landing.test.ts +++ b/src/packages/next/lib/landing/landing.test.ts @@ -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", () => { diff --git a/src/packages/next/lib/landing/software-data.ts b/src/packages/next/lib/landing/software-data.ts index 7ab9a3e4cb..7cb40708be 100644 --- a/src/packages/next/lib/landing/software-data.ts +++ b/src/packages/next/lib/landing/software-data.ts @@ -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) => [ @@ -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; diff --git a/src/packages/next/pages/software/index.tsx b/src/packages/next/pages/software/index.tsx index 868aa4454b..07002e3a54 100644 --- a/src/packages/next/pages/software/index.tsx +++ b/src/packages/next/pages/software/index.tsx @@ -186,10 +186,11 @@ export default function Software({ customize }) { Ubuntu {SOFTWARE_ENV_DEFAULT} - , 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.

); diff --git a/src/packages/next/software-inventory/setup.sh b/src/packages/next/software-inventory/setup.sh index a23765fa2a..b8024206d0 100755 --- a/src/packages/next/software-inventory/setup.sh +++ b/src/packages/next/software-inventory/setup.sh @@ -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 diff --git a/src/packages/util/consts/software-envs.ts b/src/packages/util/consts/software-envs.ts index 9ef09f64e1..34047f098d 100644 --- a/src/packages/util/consts/software-envs.ts +++ b/src/packages/util/consts/software-envs.ts @@ -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"; From b8c28fc33eab7eb70877b528959752972806cce7 Mon Sep 17 00:00:00 2001 From: Harald Schilly Date: Thu, 19 Dec 2024 14:56:30 +0100 Subject: [PATCH 2/2] next/software: fix erroneous memoization by removing useMemo --- .../next/components/landing/software-libraries.tsx | 8 ++++---- src/packages/next/lib/landing/software-specs.ts | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/packages/next/components/landing/software-libraries.tsx b/src/packages/next/components/landing/software-libraries.tsx index a205200d0c..ce86008c33 100644 --- a/src/packages/next/components/landing/software-libraries.tsx +++ b/src/packages/next/components/landing/software-libraries.tsx @@ -58,7 +58,7 @@ export default function SoftwareLibraries(props: Props) { debounce((e) => { setSearch(e.target.value); }, 500), - [] + [], ); let data: Item[]; @@ -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; @@ -98,7 +98,7 @@ export default function SoftwareLibraries(props: Props) { } return columns; - }, [libWidthPct]); + } return (
@@ -112,7 +112,7 @@ export default function SoftwareLibraries(props: Props) { />
{ } // 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 { // for development, set the env variable to directory, where this files are const localSpec = process.env.COCALC_SOFTWARE_ENVIRONMENTS;