Skip to content

Commit 29af5b0

Browse files
committed
Fix homebrew install/remove scripts
1 parent f38131f commit 29af5b0

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

10/system_root/usr/bin/heliumos-homebrew-install

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,34 @@
33
from sys import stderr
44
from urllib.request import urlretrieve
55
import subprocess
6+
import os
67

78
script_install_path = '/tmp/homebrew-install.sh'
9+
script_env_temp_path = '/tmp/homebrew-profile.sh'
810
script_env_path = '/etc/profile.d/homebrew.sh'
911

10-
shell = lambda command: subprocess.run(command.split())
12+
shell = lambda command: subprocess.run(command.split(), check=True)
13+
14+
if os.path.exists(script_install_path):
15+
os.remove(script_install_path)
1116

1217
try:
1318
urlretrieve(
1419
url='https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh',
1520
filename=script_install_path
1621
)
17-
except:
18-
print("Failed to download Homebrew installation script", file=stderr)
22+
except Exception as e:
23+
print(f"Failed to download Homebrew installation script: {e}", file=stderr)
1924
exit(1)
2025

21-
shell(f'/usr/bin/bash {script_install_path}')
26+
shell(f'bash {script_install_path}')
27+
28+
with open(script_env_temp_path, 'w') as f:
29+
f.write('eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" \n')
30+
f.write('export PATH=$PATH:/home/linuxbrew/.linuxbrew/bin/ \n')
31+
f.write('export C_INCLUDE_PATH=$CC_INCLUDE_PATH:/var/home/linuxbrew/.linuxbrew/include/ \n')
2232

23-
shell(f'sudo touch {script_env_path}')
24-
shell(f'sudo echo \'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"\' >> {script_env_path}')
25-
shell(f'sudo echo \'export C_INCLUDE_PATH=$CC_INCLUDE_PATH:/var/home/linuxbrew/.linuxbrew/include/\' >> {script_env_path}')
33+
shell(f'sudo mv {script_env_temp_path} {script_env_path}')
2634

2735
print("*" * 80)
2836
print("Complete!")

10/system_root/usr/bin/heliumos-homebrew-remove

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/usr/bin/env python3
22

3-
43
import subprocess
54

65
script_env_path = '/etc/profile.d/homebrew.sh'
76
linuxbrew_profile_path = '/home/linuxbrew/'
87

9-
shell = lambda command: subprocess.run(command.split())
8+
shell = lambda command: subprocess.run(command.split(), check=True)
109

1110
shell(f'sudo rm -f {script_env_path}')
1211
shell(f'sudo rm -rf {linuxbrew_profile_path}')

0 commit comments

Comments
 (0)