Comments (1)
This is the script i use
#!/bin/bash
curdir=`realpath $0`
parent_dir=`dirname $curdir`
pparent_dir=`dirname $parent_dir`
ppparent_dir=`dirname $pparent_dir`
PKGNAME=`basename $ppparent_dir`
export PACKAGE_NAME=$PKGNAME
chrootEnvPath=/opt/apps/$PKGNAME/files/bookworm-env
#if [ ! -e $chrootEnvPath/finish.flag ];then
#
#if [ "$(id -u)" = "0" ]; then
# `dirname $chrootEnvPath`/bin/bookworm-init
#else
#pkexec `dirname $chrootEnvPath`/bin/bookworm-init
#fi
#fi
non_root_user=$(who | awk '{print $1}' | head -n 1)
uid=$(id -u $non_root_user)
#### This part is for args pharm
if [ "$1" = "" ];then
container_command="bash"
else
container_command="$1"
shift
for arg in "$@"; do
arg="$(echo "${arg}x" | sed 's|'\''|'\'\\\\\'\''|g')"
arg="${arg%x}"
container_command="${container_command} '${arg}'"
done
fi
#########################################################################################
##########合成bwrap 1. 基础函数配置段
# 初始化 EXEC_COMMAND 为 bwrap 基础指令
EXEC_COMMAND="bwrap --dev-bind / / bwrap"
# add_command 函数定义
function add_command() {
# 参数拼接,考虑到转义和空格的处理
for arg in "$@"; do
EXEC_COMMAND="${EXEC_COMMAND} ${arg}"
done
}
function add_env_var() {
local var_name="${1}"
local var_value="${2}"
if [ "$var_value" != "" ]; then
add_command "--setenv $var_name $var_value"
fi
}
##########合成bwrap 2. 特殊需求函数配置段
function cursor_theme_dir_integration() {
local directory=""
if [ "$(id -u)" = "0" ]; then #####We don't want bother root to install themes,but will try to fix the unwriteable issue
mkdir -p $chrootEnvPath/usr/share/icons
chmod 777 -R $chrootEnvPath/usr/share/icons
return
fi
for directory in "/usr/share/icons"/*; do
# 检查是否为目录
if [ -d "$directory" ]; then
# 检查目录中是否存在 cursors 文件
if [ -d "$directory/cursors" ]; then
if [ -w $chrootEnvPath/usr/share/icons ];then
add_command "--ro-bind-try $directory $directory"
fi
fi
fi
done
}
##########合成bwrap 3. 环境变量和目录绑定配置段
# 添加环境变量和其他初始设置
ENV_VARS=(
"LANG $LANG"
"LC_COLLATE $LC_COLLATE"
"LC_CTYPE $LC_CTYPE"
"LC_MONETARY $LC_MONETARY"
"LC_MESSAGES $LC_MESSAGES"
"LC_NUMERIC $LC_NUMERIC"
"LC_TIME $LC_TIME"
"LC_ALL $LC_ALL"
"PULSE_SERVER /run/user/\$uid/pulse/native"
"PATH /flamescion-container-tools/bin-override:\$PATH"
"IS_ACE_ENV 1"
)
BIND_DIRS=(
"--dev-bind $chrootEnvPath/ /"
"--dev-bind-try /media /media"
"--dev-bind-try /tmp /tmp"
"--dev /dev"
"--dev-bind-try /dev/dri /dev/dri"
"--proc /proc"
"--dev-bind /sys /sys"
"--dev-bind /run /run"
"--dev-bind-try /run/user/\$uid/pulse /run/user/\$uid/pulse"
"--dev-bind / /host"
"--ro-bind-try /usr/share/themes /usr/local/share/themes"
"--ro-bind-try /usr/share/icons /usr/local/share/icons"
"--ro-bind-try /usr/share/fonts /usr/local/share/fonts"
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
"--dev-bind-try /home /home"
"--ro-bind /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/"
"--ro-bind $(realpath /lib/ld-linux-aarch64.so.1) /lib/ld-linux-aarch64.so.1"
)
EXTRA_ARGS=(
"--hostname AmberCE-Bookworm-x86"
"--unshare-uts"
"--cap-add CAP_SYS_ADMIN"
)
EXTRA_SCRIPTS=(
cursor_theme_dir_integration
)
##########合成bwrap 4. 合成并执行指令
# 逐一添加到 EXEC_COMMAND
for var in "${ENV_VARS[@]}"; do
add_env_var $var
done
for var in "${BIND_DIRS[@]}"; do
add_command "$var"
done
for var in "${EXTRA_ARGS[@]}"; do
add_command "$var"
done
for var in "${EXTRA_SCRIPTS[@]}"; do
$var
done
# 添加最终的 bash 命令
add_command "bash -c \"${container_command}\""
# 输出完整的 EXEC_COMMAND 以查看
# echo "${EXEC_COMMAND}"
# 注意: 实际执行时,请确保所有变量(如 $uid, $chrootEnvPath 等)都已正确定义
eval ${EXEC_COMMAND}
from box64.
Related Issues (20)
- Unsupported Syscall 0x10Dh (269)
- box64 gallium nine
- Nintendo switch steam being weird HOT 31
- Anydesk: error initializing needed lib HOT 1
- Installing box64rc configurations HOT 2
- Wine on an M1 doesn’t show the toolbar HOT 3
- Right clicking in the wine registry editor is broken on m1 HOT 5
- Mouse not working when using keyboard when using apple silicon HOT 20
- [Steam] Games with native linux and proton support don't work HOT 6
- Missing libc symbols with glibc 2.39 on Fedora 40 HOT 5
- Missing symbol errors with bash on M1 Pro running NixOS 24.05 HOT 3
- Viber on m1 HOT 3
- QT 6.7
- Fallout 3 crashes on hangover with box64 when you press play HOT 1
- Steam doesnt work in wine 9.5 on apple silicon (working on native x86) HOT 1
- Error compiling box64 0.2.8 with GCC 13.3.0 within Buildroot HOT 6
- visual novel games dowloaded in itch.io HOT 3
- (Ark Survival Ascended) Unimplemented Opcode (C0 D1 48 06) HOT 1
- Unimplemented function propsys.dll.VariantToString HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from box64.