1
0
Fork 0
mirror of https://codeberg.org/Mo8it/dotfiles.git synced 2024-12-30 20:13:42 +00:00

Remove build and npm

This commit is contained in:
Mo 2022-06-14 18:09:47 +02:00
parent 61cc09e575
commit bdf1e12e90
3 changed files with 3 additions and 101 deletions

View file

@ -4,5 +4,4 @@ launch fish -c "python ~/.scripts/update.py rpm-ostree"
launch fish -c "python ~/.scripts/update.py flatpak"
launch fish -c "python ~/.scripts/update.py pipx"
launch fish -c "python ~/.scripts/update.py cargo"
launch fish -c "python ~/.scripts/update.py npm"
launch fish -c "python ~/.scripts/update.py nvim"

View file

@ -15,16 +15,6 @@ def cap_run(command, **kwargs):
).stdout.strip()
def cap_run_in_build(command, **kwargs):
export_container_path = (
"export PATH=/root/.cargo/bin:/root/.npm-global/bin:$PATH && "
)
command_in_build = (
f"podman exec -it build bash -c '{export_container_path}{command}'"
)
return cap_run(command_in_build, **kwargs)
def rpm_ostree_packages(output_dir):
out = cap_run("rpm-ostree status --json")
json_out = json.loads(out)
@ -48,7 +38,7 @@ def rpm_ostree_packages(output_dir):
def cargo_packages(output_dir):
out = cap_run_in_build("cargo install --list")
out = cap_run("cargo install --list")
pattern = r"(.+) .+:.*"
crates = re.findall(pattern, out)
@ -59,17 +49,6 @@ def cargo_packages(output_dir):
f.write(crate + "\n")
def npm_packages(output_dir):
out = cap_run_in_build("npm list --json --location=global")
json_out = json.loads(out)
deps = json_out["dependencies"].keys()
file = output_dir / "npm.txt"
with file.open("w") as f:
for dep in deps:
f.write(dep + "\n")
def pipx_packages(output_dir):
out = cap_run("pipx list --json")
json_out = json.loads(out)
@ -101,14 +80,8 @@ def main():
pipx_packages(output_dir)
run("podman start build")
cargo_packages(output_dir)
npm_packages(output_dir)
run("podman kill build")
if __name__ == "__main__":
main()

View file

@ -51,80 +51,15 @@ def update_nvim():
run('nvim --headless -c "autocmd User PackerComplete quitall" -c "PackerSync"')
"""
podman run \
--name build \
-dit \
-v ~/.cargo:/root/.cargo:Z \
-v ~/.npm-global:/root/.npm-global:Z \
registry.fedoraproject.org/fedora:(rpm -E %fedora)
"""
def command_in_build(command, export_path):
if export_path:
export_container_path = (
"export PATH=/root/.cargo/bin:/root/.npm-global/bin:$PATH && "
)
else:
export_container_path = ""
return f"podman exec -it build bash -c '{export_container_path}{command}'"
def run_in_build(command, export_path=True, **kwargs):
return run(command_in_build(command, export_path), **kwargs)
def cap_live_lines_in_build(command, export_path=True, **kwargs):
lines = cap_live_lines(command_in_build(command, export_path), **kwargs)
return lines
def start_build():
run("podman start build")
def stop_build():
run("podman kill build")
def update_build():
run_in_build("dnf update -y && dnf autoremove -y", export_path=False)
def update_cargo():
"""
podman exec -it build bash -c 'dnf install -y cargo pkg-config openssl-devel libssh2-devel libgit2-devel'
podman exec -it build bash -c 'cargo install ...'
"""
run_in_build("cargo install-update -l")
lines = (
run_in_build("cargo install-update -a", stdout=subprocess.PIPE, text=True)
.stdout.strip()
.split("\n")
)
lines = cap_live_lines("cargo install-update -a")
if "no packages need updating" not in lines[-2].lower():
print("\n---DONE---\n")
press_to_exit()
def update_npm():
"""
podman exec -it build bash -c 'dnf install -y npm'
podman exec -it build bash -c 'npm config set prefix /root/.npm-global'
podman exec -it build bash -c 'npm install --location=global npm ...'
"""
run_in_build("npm update --location=global")
def main(input):
if input == "start":
start_build()
elif input == "rpm-ostree":
if input == "rpm-ostree":
update_rpm_ostree()
elif input == "flatpak":
update_flatpak()
@ -134,11 +69,6 @@ def main(input):
update_cargo()
elif input == "pipx":
update_pipx()
elif input == "npm":
update_npm()
elif input == "end":
update_build()
stop_build()
else:
print(f"Input {input} not valid!")