-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
torizonEmulatorManager: add recipe to fetch and deploy the scripts
Signed-off-by: Matheus Castello <[email protected]>
- Loading branch information
1 parent
0d6902a
commit 307c91c
Showing
3 changed files
with
147 additions
and
0 deletions.
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,70 @@ | ||
#!/opt/bun/bin/bun | ||
|
||
import PATH from "path" | ||
import FS from "fs" | ||
import logger from "node-color-log" | ||
import { execSync } from "child_process" | ||
|
||
const ARCH = process.env.ARCH as string | ||
const MACHINE = process.env.MACHINE as string | ||
const MAX_IMG_SIZE = process.env.MAX_IMG_SIZE as string | ||
const BUILD_PATH = process.env.BUILD_PATH as string | ||
const DISTRO_MAJOR = process.env.DISTRO_MAJOR as string | ||
const DISTRO_MINOR = process.env.DISTRO_MINOR as string | ||
const DISTRO_PATCH = process.env.DISTRO_PATCH as string | ||
const USER_PASSWD = process.env.USER_PASSWD as string | ||
|
||
// get the actual script path, not the process.cwd | ||
const _path = PATH.dirname(process.argv[1]) | ||
const meta = JSON.parse(process.env.META as string) | ||
|
||
const IMAGE_MNT_BOOT = `${BUILD_PATH}/tmp/${MACHINE}/mnt/boot` | ||
const IMAGE_MNT_ROOT = `${BUILD_PATH}/tmp/${MACHINE}/mnt/root` | ||
process.env.IMAGE_MNT_BOOT = IMAGE_MNT_BOOT | ||
process.env.IMAGE_MNT_ROOT = IMAGE_MNT_ROOT | ||
|
||
logger.info(`deploy ${meta.name} ...`) | ||
|
||
// create the path only in case | ||
execSync( | ||
`echo ${USER_PASSWD} | sudo -E -S ` + | ||
`mkdir -p ${IMAGE_MNT_ROOT}/opt/${meta.name}`, | ||
{ | ||
shell: "/bin/bash", | ||
stdio: "inherit", | ||
encoding: "utf-8", | ||
env: process.env | ||
}) | ||
|
||
for (let _file of meta.files) { | ||
const _file_path = `${BUILD_PATH}/tmp/${MACHINE}/${meta.name}/${_file}` | ||
|
||
// copy the files to the rootfs | ||
execSync( | ||
`echo ${USER_PASSWD} | sudo -E -S ` + | ||
`cp ${_file_path} ${IMAGE_MNT_ROOT}/opt/${meta.name}/${_file}`, | ||
{ | ||
shell: "/bin/bash", | ||
stdio: "inherit", | ||
encoding: "utf-8", | ||
env: process.env | ||
}) | ||
} | ||
|
||
// create a symlink to the /usr/bin | ||
execSync( | ||
`echo ${USER_PASSWD} | sudo -E -S ` + | ||
`chroot ${IMAGE_MNT_ROOT} /bin/bash -c "` + | ||
`ln -sf /opt/${meta.name}/torizon-emulator-manager /usr/bin/emulator && ` + | ||
`ln -sf /opt/${meta.name}/torizon-emulator-manager /usr/bin/torizon-emulator-manager && ` + | ||
`chmod +x /usr/bin/torizon-emulator-manager && ` + | ||
`chmod +x /usr/bin/emulator` + | ||
`"`, | ||
{ | ||
shell: "/bin/bash", | ||
stdio: "inherit", | ||
encoding: "utf-8", | ||
env: process.env | ||
}) | ||
|
||
logger.success(`Deployed ${meta.name}!`) |
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,44 @@ | ||
#!/opt/bun/bin/bun | ||
|
||
import PATH from "path" | ||
import FS from "fs" | ||
import logger from "node-color-log" | ||
import { execSync } from "child_process" | ||
|
||
const ARCH = process.env.ARCH as string | ||
const MACHINE = process.env.MACHINE as string | ||
const MAX_IMG_SIZE = process.env.MAX_IMG_SIZE as string | ||
const BUILD_PATH = process.env.BUILD_PATH as string | ||
const DISTRO_MAJOR = process.env.DISTRO_MAJOR as string | ||
const DISTRO_MINOR = process.env.DISTRO_MINOR as string | ||
const DISTRO_PATCH = process.env.DISTRO_PATCH as string | ||
const USER_PASSWD = process.env.USER_PASSWD as string | ||
|
||
// get the actual script path, not the process.cwd | ||
const _path = PATH.dirname(process.argv[1]) | ||
const meta = JSON.parse(process.env.META as string) | ||
|
||
|
||
logger.info(`fetch ${meta.name} ...`) | ||
|
||
// create the path only in case | ||
FS.mkdirSync( | ||
`${BUILD_PATH}/tmp/${MACHINE}/${meta.name}`, { recursive: true } | ||
) | ||
|
||
logger.info(`Fetching ${meta.source} ...`) | ||
|
||
for (let _file of meta.files) { | ||
const _file_path = `${BUILD_PATH}/tmp/${MACHINE}/${meta.name}/${_file}` | ||
|
||
execSync( | ||
`wget ${meta.source}/${_file} -O ${_file_path}`, | ||
{ | ||
shell: "/bin/bash", | ||
stdio: "inherit", | ||
encoding: "utf-8" | ||
} | ||
) | ||
} | ||
|
||
logger.success(`Fetched ${meta.name}!`) |
33 changes: 33 additions & 0 deletions
33
cookbook/recipes-wsl/torizonEmulatorManager/torizoEmulatorManager.json
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,33 @@ | ||
{ | ||
"name": "torizon-emulator-manager", | ||
"type": "application", | ||
"priority": 0, | ||
"support": [ | ||
"linux/amd64" | ||
], | ||
"source": "https://github.com/commontorizon/torizonEmulatorManager/releases/download/0.0.22/", | ||
"files": [ | ||
"docker-compose.yml", | ||
"torizon-emulator-manager" | ||
], | ||
"hostDeps": [ | ||
"unzip" | ||
], | ||
"targetDeps": [ | ||
"libfontconfig1", | ||
"mesa-utils", | ||
"x11-xserver-utils", | ||
"libxkbcommon-x11-0", | ||
"xkb-data", | ||
"libfreetype6", | ||
"libgbm1", | ||
"libinput10", | ||
"libxkbcommon0" | ||
], | ||
"fetchRecipes": [ | ||
"fetch.ts" | ||
], | ||
"deployRecipes": [ | ||
"deploy.ts" | ||
] | ||
} |