summaryrefslogtreecommitdiff
path: root/src/backend/setprofile.py
blob: e4da0aa85dfbf4da0c467260468e4c9a00da9b42 (plain)
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
#!/usr/bin/python3

import animation
import platform
import signal
import subprocess


def sigint_handler(signal, frame):
    sys.exit(0)


signal.signal(signal.SIGINT, sigint_handler)


@animation.wait('setting up profile')
def start():
    if platform.uname()[4] == 'x86_64':
        e_exe = subprocess.Popen(
            ['eselect', 'profile', 'set', 'default/linux/amd64/23.0/split-usr/hardened'])
        try:
            e_exe.wait()
        except KeyboardInterrupt:
            e_exe.terminate()
            try:
                e_exe.wait(1)
            except subprocess.TimeoutExpired:
                e_exe.kill()
            sys.exit()

    if platform.uname()[4] == 'aarch64':
        e_exe = subprocess.Popen(
            ['eselect', 'profile', 'set', 'default/linux/arm64/23.0/split-usr'])
        try:
            e_exe.wait()
        except KeyboardInterrupt:
            e_exe.terminate()
            try:
                e_exe.wait(1)
            except subprocess.TimeoutExpired:
                e_exe.kill()
            sys.exit()

    env_exe = subprocess.Popen(['env-update'], stdout=subprocess.DEVNULL)
    try:
        env_exe.wait()
    except KeyboardInterrupt:
        env_exe.terminate()
        try:
            env_exe.wait(1)
        except subprocess.TimeoutExpired:
            env_exe.kill()
        sys.exit()