-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_dev_tools.sh
More file actions
executable file
·230 lines (190 loc) · 6.38 KB
/
install_dev_tools.sh
File metadata and controls
executable file
·230 lines (190 loc) · 6.38 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
# FydeOS Development Tools Installer
# Run this script on a running FydeOS system in developer mode
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PACKAGES_DIR="/mnt/sdb/fydeos_build/chroot/build/terra_fydeos/packages"
INSTALL_LOG="/tmp/fydeos_dev_tools_install.log"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
log_message() {
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1" | tee -a "$INSTALL_LOG"
}
error_message() {
echo -e "${RED}[ERROR]${NC} $1" | tee -a "$INSTALL_LOG"
}
success_message() {
echo -e "${GREEN}[SUCCESS]${NC} $1" | tee -a "$INSTALL_LOG"
}
warning_message() {
echo -e "${YELLOW}[WARNING]${NC} $1" | tee -a "$INSTALL_LOG"
}
# Available development tool categories
declare -A DEV_TOOLS=(
["editors"]="app-editors/vim app-editors/nano"
["debuggers"]="sys-devel/gdb dev-util/strace"
["compilers"]="sys-devel/gcc sys-devel/clang"
["build-tools"]="sys-devel/make dev-util/cmake"
["network-tools"]="net-analyzer/tcpdump net-misc/curl net-misc/wget"
["system-tools"]="sys-process/htop sys-apps/lsof sys-process/procps"
["text-tools"]="sys-apps/grep sys-apps/sed sys-devel/patch"
["version-control"]="dev-vcs/git"
["profiling"]="dev-util/valgrind sys-devel/gprof"
["python-tools"]="dev-lang/python dev-python/pip"
)
show_available_tools() {
log_message "Available development tool categories:"
echo
for category in "${!DEV_TOOLS[@]}"; do
echo -e "${GREEN}$category:${NC}"
for tool in ${DEV_TOOLS[$category]}; do
echo " - $tool"
done
echo
done
}
check_developer_mode() {
if [ ! -f "/root/.dev_mode" ] && [ ! -f "/.developer_mode" ]; then
warning_message "Developer mode may not be enabled."
warning_message "Please enable developer mode first:"
echo "1. Boot with Ctrl+D"
echo "2. Follow developer mode setup"
echo "3. Run: sudo touch /.developer_mode"
fi
}
make_rootfs_writable() {
log_message "Checking if root filesystem is writable..."
if touch /test_write 2>/dev/null; then
rm -f /test_write
success_message "Root filesystem is already writable"
return 0
fi
warning_message "Root filesystem is read-only. Attempting to make writable..."
# Try to remount as read-write
if mount -o remount,rw / 2>/dev/null; then
success_message "Root filesystem remounted as read-write"
return 0
fi
error_message "Could not make root filesystem writable"
error_message "You may need to run:"
error_message "sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions 2"
error_message "Then reboot and try again"
return 1
}
find_package_file() {
local package_name="$1"
local package_file
# Look for the package in the build directory
package_file=$(find "$PACKAGES_DIR" -name "*${package_name##*/}*.tbz2" 2>/dev/null | head -1)
if [ -n "$package_file" ] && [ -f "$package_file" ]; then
echo "$package_file"
return 0
fi
return 1
}
install_package() {
local package_name="$1"
local package_file
log_message "Installing package: $package_name"
# Try to find the package file
if package_file=$(find_package_file "$package_name"); then
log_message "Found package file: $package_file"
# Extract the package
if tar -xjf "$package_file" -C / 2>/dev/null; then
success_message "Successfully installed $package_name"
return 0
else
error_message "Failed to extract $package_name from $package_file"
return 1
fi
else
warning_message "Package file not found for $package_name"
warning_message "You may need to build this package first"
return 1
fi
}
install_category() {
local category="$1"
local tools="${DEV_TOOLS[$category]}"
if [ -z "$tools" ]; then
error_message "Unknown category: $category"
return 1
fi
log_message "Installing tools from category: $category"
local success_count=0
local total_count=0
for tool in $tools; do
((total_count++))
if install_package "$tool"; then
((success_count++))
fi
done
log_message "Category $category: $success_count/$total_count tools installed successfully"
}
install_specific_tool() {
local tool="$1"
install_package "$tool"
}
# Check if running as root
if [ "$EUID" -ne 0 ]; then
error_message "This script must be run as root"
error_message "Please run: sudo $0 $@"
exit 1
fi
# Main execution
case "${1:-help}" in
"help"|"-h"|"--help")
echo "FydeOS Development Tools Installer"
echo
echo "Usage: $0 [command] [options]"
echo
echo "Commands:"
echo " help Show this help message"
echo " list List available tool categories"
echo " install-category <name> Install all tools from a category"
echo " install-tool <name> Install a specific tool"
echo " setup Prepare system for tool installation"
echo
echo "Examples:"
echo " $0 list"
echo " $0 install-category debuggers"
echo " $0 install-tool sys-devel/gdb"
;;
"list")
show_available_tools
;;
"setup")
log_message "Setting up system for development tool installation..."
check_developer_mode
make_rootfs_writable
success_message "System setup complete"
;;
"install-category")
if [ -z "$2" ]; then
error_message "Please specify a category to install"
echo "Run '$0 list' to see available categories"
exit 1
fi
check_developer_mode
make_rootfs_writable || exit 1
install_category "$2"
;;
"install-tool")
if [ -z "$2" ]; then
error_message "Please specify a tool to install"
exit 1
fi
check_developer_mode
make_rootfs_writable || exit 1
install_specific_tool "$2"
;;
*)
error_message "Unknown command: $1"
echo "Run '$0 help' for usage information"
exit 1
;;
esac