File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727
2828echo -e " ${BLUE} Using config file:${NC} ${PACKAGES_CONF} "
2929
30+ # If the chosen PACKAGES_CONF is not writable (e.g. inside a bundled binary's
31+ # temporary directory), fall back to a user-writable location under $HOME
32+ if [ -f " ${PACKAGES_CONF} " ]; then
33+ if [ ! -w " ${PACKAGES_CONF} " ]; then
34+ echo -e " ${YELLOW} Warning:${NC} ${PACKAGES_CONF} is not writable. Falling back to user config."
35+ USER_DIR=" ${HOME} /.ok_computer"
36+ mkdir -p " ${USER_DIR} "
37+ NEW_CONF=" ${USER_DIR} /packages.conf"
38+ if [ ! -f " ${NEW_CONF} " ] && [ -f " ${SCRIPT_DIR} /packages.conf" ]; then
39+ # seed from repository packages.conf if available
40+ cp " ${SCRIPT_DIR} /packages.conf" " ${NEW_CONF} " || true
41+ fi
42+ PACKAGES_CONF=" ${NEW_CONF} "
43+ echo -e " ${BLUE} Using fallback config file:${NC} ${PACKAGES_CONF} "
44+ fi
45+ else
46+ # If the file doesn't exist, check whether we can create it in place; if not, use fallback
47+ parent_dir=$( dirname " ${PACKAGES_CONF} " )
48+ if [ ! -w " ${parent_dir} " ]; then
49+ echo -e " ${YELLOW} Warning:${NC} Cannot create ${PACKAGES_CONF} in ${parent_dir} . Falling back to user config."
50+ USER_DIR=" ${HOME} /.ok_computer"
51+ mkdir -p " ${USER_DIR} "
52+ PACKAGES_CONF=" ${USER_DIR} /packages.conf"
53+ echo -e " ${BLUE} Using fallback config file:${NC} ${PACKAGES_CONF} "
54+ fi
55+ fi
56+
3057# Check availability functions (simplified versions of app.sh)
3158check_homebrew_api () {
3259 local app=$1
You can’t perform that action at this time.
0 commit comments