-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.nims
54 lines (49 loc) · 2.06 KB
/
install.nims
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env nim
import std/[envvars, os, strutils, strformat, cmdline]
let basedir = getEnv("BASEDIR", "/usr")
let sudo = if existsEnv "INSTALL_WITH_SUDO": "sudo " else: ""
let pkgconfigCheck = getEnv("PKGCONFIG_CHECK", "1")
let nimbleFlags = commandLineParams()[1..^1].join(" ")
proc run(cmd: string) =
echo "$ " & cmd
try:
let result = gorgeEx cmd
if result.exitCode != 0:
echo fmt"┌─ Fail to execute command: {cmd}"
for line in result.output.splitLines:
echo "┊ "&line
echo fmt"└─ Command returned exit code {$result.exitCode}"
quit 1
except:
echo fmt"Fail to execute command: {cmd}"
quit 1
proc `/`(left, right: string): string =
assert not right.startsWith '/'
if left.endsWith '/':
return left & right
return left & '/' & right
proc pkgconfig(id: string) =
if ["no", "0", "", "false", "off"].contains pkgconfigCheck.toLower:
return
let f = "pkgconfig/"&id&".pc"
let x = fileExists("/usr/lib64/"&f) or fileExists("/usr/lib/"&f) or fileExists(basedir/"lib64/"&f) or fileExists(basedir/"lib64/"&f)
if not x:
echo "E: Cannot find pkgconfig for: " & id
echo fmt"E: On RPM-based systems, install `pkgconfig({id})`"
echo "E: On Fedora/Ultramarine:"
echo fmt"E: $ sudo dnf in 'pkgconfig({id})'"
echo "E: This package is a build dependency of umupgrade and is thus required."
quit 1
echo "umupgrader will be installed in (set $BASEDIR to change this): " & $basedir
echo "This script should be run with the proper priviledges such that the above path can be accessed freely"
echo "If you want install.nims to call sudo, define $INSTALL_WITH_SUDO"
echo ""
echo "Checking build dependencies"
pkgconfig "gtk4"
pkgconfig "libadwaita-1"
echo ""
echo "Building umupgrader"
run "nimble build " & nimbleFlags
run sudo & "cp umupgrader " & $(basedir/"bin")
run sudo & "cp com.fyralabs.umupgrader.policy " & $(basedir/"share/polkit-1/actions/")
run sudo & "cp umupgrader.desktop "& $(basedir/"share/applications/")