Skip to content

Commit

Permalink
tea/cli handles installation
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Sep 19, 2022
1 parent bac454b commit 4b4cb5b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
20 changes: 20 additions & 0 deletions scripts/clean-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env -S tea -E

_="
---
args: /bin/sh
---
"

ROOTS=$(ls /opt/tea.xyz/var/pantry/projects)

for x in $ROOTS
do
if [ "X$x" = "X" ]
then
continue
fi
rm -rf /opt/"$x"
done

rm /opt/tea.xyz/var/www/*.tar.?z
35 changes: 35 additions & 0 deletions scripts/install.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env -S tea -E

// returns all pantry entries as `[{ name, path }]`

/*---
args:
- deno
- run
- --allow-env
- --allow-read
- --allow-write
- --import-map={{ srcroot }}/import-map.json
- --allow-net
- --allow-run
---*/

import { lvl1 as link } from "prefab/link.ts"
import install from "prefab/install.ts"
import { parsePackageRequirement } from "types"
import resolve from "prefab/resolve.ts"
import useFlags from "hooks/useFlags.ts"

useFlags()

const pkgs = Deno.args.map(project => {
const match = project.match(/projects\/(.+)\/package.yml/)
return match ? match[1] : project
}).map(parsePackageRequirement)

// resolve and install precise versions that are available in available inventories
for await (const pkg of await resolve(pkgs)) {
console.log({ installing: pkg.project })
const installation = install(pkg)
await link(installation)
}
6 changes: 3 additions & 3 deletions src/hooks/useShellEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default async function useShellEnv(requirements: PackageRequirement[] | I
}))).compactMap(x => x)

const projects = new Set([...pkgs.map(x => x.pkg.project), ...pending.map(x=>x.project)])
const has_pkg_config = projects.has('freedesktop.org/pkg-config')
const has_cmake = projects.has('cmake.org')
const archaic = true

for (const installation of pkgs) {
for (const key of EnvKeys) {
Expand All @@ -54,8 +54,7 @@ export default async function useShellEnv(requirements: PackageRequirement[] | I
}
}

// if the tool provides no pkg-config files then fall back on old-school specification methods
if (true) { //!vars.PKG_CONFIG_PATH?.chuzzle() || !has_pkg_config) {
if (archaic) {
if (!vars.LIBRARY_PATH) vars.LIBRARY_PATH = []
if (!vars.CPATH) vars.CPATH = []
vars.LIBRARY_PATH.compactUnshift(installation.path.join("lib").compact()?.string)
Expand All @@ -82,6 +81,7 @@ export default async function useShellEnv(requirements: PackageRequirement[] | I
// but these PATHs will almost certainly contain other things that will
// interfere with our ability to create reproducibility
//NOTE /usr/local/bin is explicitly NOT ADDED
//TODO provide stub packages that exec the actual tools so we can exclude these PATHs
if (!vars.PATH) vars.PATH = []
vars.PATH.push('/usr/bin', '/bin', '/usr/sbin', '/sbin', tea.string)

Expand Down

0 comments on commit 4b4cb5b

Please sign in to comment.