Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e79923c206 | |||
| 36b2ea2ced | |||
| e9f2ebd9e5 | |||
| 99268485c4 | |||
| ca582467dc | |||
| 92f87a3f62 | |||
| 6d76dc98aa | |||
| fd1d9dded0 | |||
| 488c2f038f | |||
| 1b531a75b1 | |||
| 73e3bec9c3 | |||
| 0bbaaea422 | |||
| 24fe84d5be | |||
| d74b603469 | |||
| 903788732c | |||
| c976b58920 | |||
| 516c4c30d4 | |||
| 75469cf1fc | |||
| b22439d7e6 | |||
| 0549dc74c3 | |||
| a2c95f2518 | |||
| 34f4ba62cb | |||
| 63fa6b6c46 | |||
| 172e219bb3 | |||
| 878d559241 | |||
| e9c9f488f5 | |||
| 02a70eb0e7 | |||
| 8d5a07277a | |||
| 12a2c435be | |||
| 798554ab22 | |||
| a284695f80 | |||
| fe19bf6efc | |||
| 4c19bf865a | |||
| af5594cdcb | |||
| 130ff44a29 | |||
| dba6361d29 | |||
| b5f45bbecf | |||
| f3be1f48f6 | |||
| af04000b02 |
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
*.deb
|
||||
src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env.tar.xz
|
||||
src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/ace-env.tar.xz
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
cd rpmbuild && rpmbuild -ba SPECS/bookworm-compatibility-mode.spec
|
||||
@@ -1,58 +0,0 @@
|
||||
Name: cn.flamescion.bookworm-compatibility-mode
|
||||
Version: 12.4.7
|
||||
Release: 1
|
||||
Summary: A container app packaging and distributing solution.
|
||||
License: unknown
|
||||
URL: https://gitee.com/amber-compatability-environment/bookworm-compatibility-mode
|
||||
Source0: bookworm-compatibility-mode-%{version}.tar.gz
|
||||
|
||||
BuildRequires: debootstrap, dpkg, bash, which, systemd-container
|
||||
Requires: bubblewrap, xdg-desktop-portal, flatpak, zenity, gcc
|
||||
|
||||
%description
|
||||
A container app packaging and distributing solution.
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -n bookworm-compatibility-mode-%{version}
|
||||
%global debug_package %{nil}
|
||||
|
||||
%post
|
||||
/opt/apps/%{name}/files/bin/bookworm-init
|
||||
|
||||
%postun
|
||||
if [ "$1" = "0" ] || [ "$1" = "1" ]; then
|
||||
echo "清理卸载残留"
|
||||
rm -rf /opt/apps/%{name}
|
||||
else
|
||||
echo "非卸载,跳过清理"
|
||||
fi
|
||||
|
||||
%install
|
||||
cp -r src/opt %{buildroot}
|
||||
cp -r src/etc %{buildroot}
|
||||
cp -r src/usr %{buildroot}
|
||||
|
||||
pushd %{buildroot}/opt/apps/%{name}/files
|
||||
if [ "%{_target_cpu}" = "aarch64" ]; then
|
||||
bash build-container.sh arm64
|
||||
elif [ "%{_target_cpu}" = "x86_64" ]; then
|
||||
bash build-container.sh amd64
|
||||
else
|
||||
echo "Unsupportable arch!"
|
||||
fi
|
||||
popd
|
||||
|
||||
%files
|
||||
%dir /opt/apps/%{name}
|
||||
/opt/apps/%{name}/*
|
||||
/etc/X11/Xsession.d/20ACE-Bookworm
|
||||
/etc/profile.d/ACE-Bookworm.sh
|
||||
%{_bindir}/*
|
||||
%attr(755,root,root) /usr/lib/systemd/user-environment-generators/60-ACE-Bookworm
|
||||
%attr(755,root,root) /usr/share/applications/*
|
||||
/usr/share/icons/*
|
||||
/usr/share/polkit-1/actions/cn.flamescion.ace-uninstaller.policy
|
||||
|
||||
%changelog
|
||||
* Fri Jan 26 2024 懵仙兔兔 <acgm@qq.com> - 12.4.7-1
|
||||
- First pello package
|
||||
59
README.md
@@ -1,48 +1,39 @@
|
||||
# 书虫兼容模式
|
||||
书虫兼容模式,是`琥珀兼容环境(ACE)`的一部分
|
||||
|
||||
琥珀兼容环境是一款基于bubblewrap的容器化应用打包和分发方案。
|
||||
|
||||
书虫兼容模式用极为轻量的容器方案让你可以在几乎任何的Linux发行版上运行一个`Debian 12`容器。在`Appimage`应用无法启动或者打包的时候,使用书虫兼容模式来打包可以让你在使用最新的环境的同时在更多的发行版上运行,是一个很好的选择
|
||||
|
||||
书虫兼容模式让你可以在deepin或UOS上使用Debian 12的应用,为你带来更好的使用体验!
|
||||
|
||||
请使用 `git clone --recurse-submodules` 来获取
|
||||
|
||||
## 构建指南
|
||||
|
||||
### Debian
|
||||
|
||||
先构建容器再打包,容器位置在`src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files`
|
||||
|
||||
下面是详细步骤:
|
||||
|
||||
1. 安装依赖:sudo apt-get install arch-test debootstrap libnss-mymachines systemd-container
|
||||
2. 在`src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files`位置进入终端,执行`./build-container.sh amd64`[amd架构,其他架构同理]`
|
||||
3. 等待容器打包完成
|
||||
4. 进入`bookworm-compatibility-mode`目录,执行fakeroot dpkg-deb -b src cn.flamescion.bookworm-compatibility-mode.deb
|
||||
5. 等待打包完成
|
||||
|
||||
### Fedora
|
||||
|
||||
`ACE-rpm`目录下有相关的说明
|
||||
|
||||
### Arch
|
||||
|
||||
https://bbs.spark-app.store/d/1668-xing-huo-ying-yong-shang-dian-on-ace
|
||||
|
||||
# Bookworm compatibility mode
|
||||
|
||||
# [中文](README.zh.md)
|
||||
|
||||
Bookworm compatibility mode is a part of `Amber Compatability Environment(ACE)`
|
||||
|
||||
Amber Compatability Environment is a container app packaging and distributing solution.
|
||||
|
||||
With the help of bubblewrap, a super tiny container solution, you can run a `Debian 12` container in almost every linux distrobution. When you can not launch or pack an `Appimage` App, using Bookworm compatibility mode can allow you to pack the app in a newer environment and also be able to run on more distrobutions. It is a good choice!
|
||||
|
||||
Bookworm compatibility mode allows you to use Debian 12 applications on deepin or UniontechOS using bwrap containers, providing you with a better user experience!
|
||||
**You need to logout or reboot your computer to show the entries in launcher app list if it's your first time using ACE.**
|
||||
|
||||
Please use `git clone --recurse-submodules` to obtain the env
|
||||
|
||||
|
||||
## Install Guide
|
||||
|
||||
|
||||
### Quick Install (Need to install Spark Store first)
|
||||
|
||||
[spk://store/tools/cn.flamescion.bookworm-compatibility-mode/](https://spark-store-project.gitee.io/spk-resolv/?spk=spk://store/tools/cn.flamescion.bookworm-compatibility-mode/)
|
||||
|
||||
### Manual Install(Debian/Fedora/Arch)
|
||||
|
||||
https://share.shenmo.tech:23333/index.php?share/folder&user=1&sid=kr8z6Fqf
|
||||
|
||||
(Dependencies are needed to upgrade for Ubuntu 18.04/deepin 15)
|
||||
|
||||
https://cdn.d.store.deepinos.org.cn/store/depends/bubblewrap_0.3.1-4_amd64.deb x86
|
||||
|
||||
https://cdn.d.store.deepinos.org.cn/aarch64-store/depends/bubblewrap_0.3.1-4_arm64.deb arm64
|
||||
|
||||
|
||||
## Build Guide
|
||||
|
||||
### Debian
|
||||
@@ -52,14 +43,14 @@ Here are the details:
|
||||
1. Install dependencies: sudo apt-get install arch-test debootstrap libnss-mymachines systemd-container
|
||||
2. Enter the terminal at `src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files` and execute `./build-container.sh amd64`.[for amd,other arch please change]
|
||||
3. Wait for the container to complete.
|
||||
4.Get in to `bookworm-compatibility-mode` dir,run`fakeroot dpkg-deb -b src cn.flamescion.bookworm-compatibility-mode.deb
|
||||
4.Get in to `bookworm-compatibility-mode` dir,run`fakeroot dpkg-deb -b src .`
|
||||
5.Wating for complete.
|
||||
|
||||
|
||||
### Fedora
|
||||
|
||||
See readme in `ACE-rpm` directory
|
||||
See https://gitee.com/amber-compatability-environment/ace-rpm
|
||||
|
||||
### Arch
|
||||
|
||||
https://bbs.spark-app.store/d/1668-xing-huo-ying-yong-shang-dian-on-ace
|
||||
`yay -S cn.flamescion.bookworm-compatibility-mode`
|
||||
|
||||
52
README.zh.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# 书虫兼容模式
|
||||
|
||||
# [English](README.md)
|
||||
|
||||
|
||||
琥珀兼容环境是一款基于bubblewrap的容器化应用打包和分发方案。
|
||||
|
||||
书虫兼容模式用极为轻量的容器方案让你可以在几乎任何的Linux发行版上运行一个`Debian 12`容器。在`Appimage`应用无法启动或者打包的时候,使用书虫兼容模式来打包可以让你在使用最新的环境的同时在更多的发行版上运行,是一个很好的选择
|
||||
|
||||
**首次安装后请注销或重启以展示启动器入口**
|
||||
|
||||
请使用 `git clone --recurse-submodules` 来获取
|
||||
|
||||
## 安装指南
|
||||
|
||||
### 快捷安装 (需要安装星火应用商店)
|
||||
|
||||
[spk://store/tools/cn.flamescion.bookworm-compatibility-mode/](https://spark-store-project.gitee.io/spk-resolv/?spk=spk://store/tools/cn.flamescion.bookworm-compatibility-mode/)
|
||||
|
||||
### 手动安装(Debian/Fedora/Arch)
|
||||
|
||||
https://share.shenmo.tech:23333/index.php?share/folder&user=1&sid=kr8z6Fqf
|
||||
|
||||
(Ubuntu 18.04/deepin 15需要先安装依赖)
|
||||
|
||||
https://cdn.d.store.deepinos.org.cn/store/depends/bubblewrap_0.3.1-4_amd64.deb x86
|
||||
|
||||
https://cdn.d.store.deepinos.org.cn/aarch64-store/depends/bubblewrap_0.3.1-4_arm64.deb arm64
|
||||
|
||||
## 构建指南
|
||||
|
||||
### Debian
|
||||
|
||||
先构建容器再打包,容器位置在`src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files`
|
||||
|
||||
下面是详细步骤:
|
||||
|
||||
1. 安装依赖:sudo apt-get install arch-test debootstrap libnss-mymachines systemd-container
|
||||
2. 在`src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files`位置进入终端,执行`./build-container.sh amd64`[amd架构,其他架构同理]`
|
||||
3. 等待容器打包完成
|
||||
4. 进入`bookworm-compatibility-mode`目录,执行`fakeroot dpkg-deb -b src .`
|
||||
5. 等待打包完成
|
||||
|
||||
### Fedora
|
||||
|
||||
请前往 https://gitee.com/amber-compatability-environment/ace-rpm
|
||||
|
||||
### Arch
|
||||
|
||||
`yay -S cn.flamescion.bookworm-compatibility-mode`
|
||||
|
||||
---
|
||||
@@ -1,8 +1,8 @@
|
||||
Package: cn.flamescion.bookworm-compatibility-mode
|
||||
Version: 12.4.8
|
||||
Version: 12.4.11
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Depends: bubblewrap,flatpak,zenity,policykit-1,gcc,systemd
|
||||
Maintainer: shenmo <shenmo@spark-app.store>
|
||||
Architecture: amd64
|
||||
Architecture: arm64
|
||||
Description: bwrap wrapper for install and running debs inside a bookworm container
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
#!/bin/bash
|
||||
export PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"
|
||||
/opt/apps/$PACKAGE_NAME/files/bin/bookworm-init
|
||||
|
||||
if [ "${PACKAGE_NAME}" = "cn.flamescion.bookworm-compatibility-mode" ];then
|
||||
if [ -d /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env ];then
|
||||
if [ "$(arch)" != "loongarch64" ];then
|
||||
mv /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/ace-env
|
||||
ln -sfv /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/ace-env /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env
|
||||
else
|
||||
mv /opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env /opt/apps/amber-ce-loongnix/files/ace-env
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
/opt/apps/$PACKAGE_NAME/files/bin/ace-init
|
||||
|
||||
if [ "${PACKAGE_NAME}" = "cn.flamescion.bookworm-compatibility-mode" ];then
|
||||
systemctl daemon-reload
|
||||
systemctl enable ace-auto-upgrade
|
||||
systemctl start ace-auto-upgrade
|
||||
systemctl enable ace-bookworm-auto-upgrade
|
||||
systemctl start ace-bookworm-auto-upgrade
|
||||
fi
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"
|
||||
|
||||
if [ "${PACKAGE_NAME}" = "cn.flamescion.bookworm-compatibility-mode" ];then
|
||||
systemctl stop ace-auto-upgrade
|
||||
systemctl disable ace-auto-upgrade
|
||||
systemctl stop ace-bookworm-auto-upgrade
|
||||
systemctl disable ace-bookworm-auto-upgrade
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ fi
|
||||
|
||||
# Desktop files (used by desktop environments within both X11 and Wayland) are
|
||||
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for ACE
|
||||
ACE_path="/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env/usr/share/"
|
||||
ACE_path="/opt/apps/amber-ce-bookworm/files/ace-env/flamescion-container-tools/data-dir/"
|
||||
if [ -n "${XDG_DATA_DIRS##*${ACE_path}}" ] && [ -n "${XDG_DATA_DIRS##*${ACE_path}:*}" ]; then
|
||||
export XDG_DATA_DIRS="${ACE_path}:${XDG_DATA_DIRS}"
|
||||
fi
|
||||
|
||||
@@ -9,7 +9,7 @@ fi
|
||||
|
||||
# Desktop files (used by desktop environments within both X11 and Wayland) are
|
||||
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for ACE
|
||||
ACE_path="/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env/usr/share/"
|
||||
ACE_path="/opt/apps/amber-ce-bookworm/files/ace-env/flamescion-container-tools/data-dir/"
|
||||
if [ -n "${XDG_DATA_DIRS##*${ACE_path}}" ] && [ -n "${XDG_DATA_DIRS##*${ACE_path}:*}" ]; then
|
||||
export XDG_DATA_DIRS="${ACE_path}:${XDG_DATA_DIRS}"
|
||||
fi
|
||||
|
||||
1
src/opt/apps/amber-ce-bookworm
Symbolic link
@@ -0,0 +1 @@
|
||||
./cn.flamescion.bookworm-compatibility-mode/
|
||||
|
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 196 KiB |
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 134 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
@@ -8,7 +8,7 @@ fi
|
||||
unset ABSOLUTE_PATH IN_CONTAINER_PATH PKGNAME_GUESS DPKG_LIST_FILE ACE_ENV_PATH
|
||||
|
||||
# 定义环境路径变量
|
||||
ACE_ENV_PATH="/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env"
|
||||
ACE_ENV_PATH="/opt/apps/amber-ce-bookworm/files/ace-env"
|
||||
|
||||
# 检查参数个数
|
||||
if [ "$#" -ne 1 ]; then
|
||||
@@ -25,8 +25,13 @@ fi
|
||||
|
||||
# 验证是否为desktop文件
|
||||
if [[ ! $ABSOLUTE_PATH == *.desktop ]]; then
|
||||
if [ ! -e $ABSOLUTE_PATH ];then
|
||||
echo "$ABSOLUTE_PATH does not exist. May have already been uninstalled. Ignore it."
|
||||
exit
|
||||
else
|
||||
echo "Error: The file is not a desktop file."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 截取路径
|
||||
@@ -4,7 +4,7 @@ pkexec $0
|
||||
exit
|
||||
fi
|
||||
# 定义应用列表文件路径
|
||||
ACE_dir="/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env"
|
||||
ACE_dir="/opt/apps/amber-ce-bookworm/files/ace-env"
|
||||
|
||||
# 读取所有.desktop文件,并构造应用列表
|
||||
app_list=()
|
||||
@@ -44,7 +44,7 @@ selected_apps=$(zenity --list --title "应用列表" --column "是否卸载" --c
|
||||
if [ -n "$selected_apps" ]; then
|
||||
# 卸载选中的应用
|
||||
(for app_desktop_path in $selected_apps; do
|
||||
ace-uninstall-helper "$app_desktop_path"
|
||||
ace-bookworm-uninstall-helper "$app_desktop_path"
|
||||
ret=$?
|
||||
if [ "$ret" != "0" ];then
|
||||
zenity --error --width 768 --text "$app_desktop_path 卸载失败,中止操作\n请手动执行\nsudo ace-uninstall-helper $app_desktop_path \n查看报错!"
|
||||
118
src/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-init
Executable file
@@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "当前用户不是 root 用户,退出"
|
||||
exit
|
||||
fi
|
||||
if [ "$PACKAGE_NAME" = "" ];then
|
||||
curdir=`realpath $0`
|
||||
parent_dir=`dirname $curdir`
|
||||
pparent_dir=`dirname $parent_dir`
|
||||
ppparent_dir=`dirname $pparent_dir`
|
||||
PKGNAME=`basename $ppparent_dir`
|
||||
else
|
||||
PKGNAME=$PACKAGE_NAME
|
||||
fi
|
||||
chrootEnvPath=/opt/apps/$PKGNAME/files/ace-env
|
||||
if [ ! -e $chrootEnvPath ];then
|
||||
echo "Uncompress the env...."
|
||||
tar -xvf $chrootEnvPath.tar.xz -C /opt/apps/$PKGNAME/files/
|
||||
fi
|
||||
|
||||
|
||||
|
||||
non_root_user=$(who | awk '{print $1}' | head -n 1)
|
||||
uid=$(id -u $non_root_user)
|
||||
|
||||
function bookworm-run(){
|
||||
bwrap --dev-bind $chrootEnvPath/ / \
|
||||
--setenv LANG "$LANG" \
|
||||
--setenv LC_COLLATE "$LC_COLLATE" \
|
||||
--setenv LC_CTYPE "$LC_CTYPE" \
|
||||
--setenv LC_MONETARY "$LC_MONETARY" \
|
||||
--setenv LC_MESSAGES "$LC_MESSAGES" \
|
||||
--setenv LC_NUMERIC "$LC_NUMERIC" \
|
||||
--setenv LC_TIME "$LC_TIME" \
|
||||
--setenv LC_ALL "$LC_ALL" \
|
||||
--setenv PULSE_SERVER /run/user/$uid/pulse/native \
|
||||
--setenv PATH /flamescion-container-tools/bin-override:$PATH \
|
||||
--setenv IS_ACE_ENV "1" \
|
||||
--dev-bind-try /media /media \
|
||||
--dev-bind-try /tmp /tmp \
|
||||
--dev /dev \
|
||||
--dev-bind-try /dev/dri /dev/dri \
|
||||
--proc /proc \
|
||||
--dev-bind / /host \
|
||||
--dev-bind /sys /sys \
|
||||
--dev-bind /run /run \
|
||||
--dev-bind-try /run/user/$uid/pulse /run/user/$uid/pulse \
|
||||
--bind-try /usr/share/themes /usr/local/share/themes \
|
||||
--bind-try /usr/share/icons /usr/local/share/icons \
|
||||
--bind-try /usr/share/fonts /usr/local/share/fonts \
|
||||
--hostname Amber-CE-Bookworm \
|
||||
--unshare-uts \
|
||||
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \
|
||||
--dev-bind-try /home /home \
|
||||
$@
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo "Update the flamescion container tools"
|
||||
cp -r `dirname $chrootEnvPath`/flamescion-container-tools/ $chrootEnvPath
|
||||
|
||||
rm -rf $chrootEnvPath/usr/lib/`gcc -dumpmachine`/dri/dri
|
||||
# 之前错误的多复制了一个,这里删掉
|
||||
|
||||
export container_user_gid="$(sudo -u $non_root_user id -rg)"
|
||||
export container_user_home="/home/${non_root_user}"
|
||||
export container_user_name="${non_root_user}"
|
||||
export container_user_uid="$(sudo -u $non_root_user id -ru)"
|
||||
|
||||
|
||||
|
||||
|
||||
#####init
|
||||
|
||||
|
||||
bookworm-run bash /flamescion-container-tools/container-init/init.sh
|
||||
rm $chrootEnvPath/etc/localtime
|
||||
cp $(realpath /etc/localtime) $chrootEnvPath/etc/localtime
|
||||
chmod 777 $chrootEnvPath/etc/localtime
|
||||
bookworm-run cp /host/etc/locale.gen /etc/locale.gen && locale-gen
|
||||
bookworm-run touch /finish.flag
|
||||
bookworm-run apt clean
|
||||
bookworm-run chown -R $(who | awk '{print $1}' | head -n 1) /usr/lib/locale/
|
||||
sudo -u $(who | awk '{print $1}' | head -n 1) bwrap --dev-bind $chrootEnvPath/ / \
|
||||
--setenv LANG "$LANG" \
|
||||
--setenv LC_COLLATE "$LC_COLLATE" \
|
||||
--setenv LC_CTYPE "$LC_CTYPE" \
|
||||
--setenv LC_MONETARY "$LC_MONETARY" \
|
||||
--setenv LC_MESSAGES "$LC_MESSAGES" \
|
||||
--setenv LC_NUMERIC "$LC_NUMERIC" \
|
||||
--setenv LC_TIME "$LC_TIME" \
|
||||
--setenv LC_ALL "$LC_ALL" \
|
||||
--setenv PULSE_SERVER /run/user/$uid/pulse/native \
|
||||
--setenv PATH /flamescion-container-tools/bin-override:$PATH \
|
||||
--setenv IS_ACE_ENV "1" \
|
||||
--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 \
|
||||
--bind-try /usr/share/themes /usr/local/share/themes \
|
||||
--bind-try /usr/share/icons /usr/local/share/icons \
|
||||
--bind-try /usr/share/fonts /usr/local/share/fonts \
|
||||
--hostname Amber-CE-Bookworm \
|
||||
--unshare-uts \
|
||||
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \
|
||||
--dev-bind-try /home /home \
|
||||
locale-gen
|
||||
|
||||
chown -R root $chrootEnvPath
|
||||
chmod 777 -R $chrootEnvPath /usr/share/icons
|
||||
@@ -1,357 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "当前用户不是 root 用户,退出"
|
||||
exit
|
||||
fi
|
||||
if [ "$PACKAGE_NAME" = "" ];then
|
||||
curdir=`realpath $0`
|
||||
parent_dir=`dirname $curdir`
|
||||
pparent_dir=`dirname $parent_dir`
|
||||
ppparent_dir=`dirname $pparent_dir`
|
||||
PKGNAME=`basename $ppparent_dir`
|
||||
else
|
||||
PKGNAME=$PACKAGE_NAME
|
||||
fi
|
||||
chrootEnvPath=/opt/apps/$PKGNAME/files/bookworm-env
|
||||
if [ ! -e $chrootEnvPath ];then
|
||||
echo "Uncompress the env...."
|
||||
tar -xvf $chrootEnvPath.tar.xz -C /opt/apps/$PKGNAME/files/
|
||||
fi
|
||||
|
||||
|
||||
|
||||
non_root_user=$(who | awk '{print $1}' | head -n 1)
|
||||
uid=$(id -u $non_root_user)
|
||||
|
||||
function bookworm-run(){
|
||||
bwrap --dev-bind $chrootEnvPath/ / \
|
||||
--setenv LANG "$LANG" \
|
||||
--setenv LC_COLLATE "$LC_COLLATE" \
|
||||
--setenv LC_CTYPE "$LC_CTYPE" \
|
||||
--setenv LC_MONETARY "$LC_MONETARY" \
|
||||
--setenv LC_MESSAGES "$LC_MESSAGES" \
|
||||
--setenv LC_NUMERIC "$LC_NUMERIC" \
|
||||
--setenv LC_TIME "$LC_TIME" \
|
||||
--setenv LC_ALL "$LC_ALL" \
|
||||
--setenv PULSE_SERVER /run/user/$uid/pulse/native \
|
||||
--setenv PATH /flamescion-container-tools/bin-override:$PATH \
|
||||
--setenv IS_ACE_ENV "1" \
|
||||
--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 \
|
||||
--bind-try /usr/share/themes /usr/local/share/themes \
|
||||
--bind-try /usr/share/icons /usr/local/share/icons \
|
||||
--bind-try /usr/share/fonts /usr/local/share/fonts \
|
||||
--hostname Amber-CE-Bookworm \
|
||||
--unshare-uts \
|
||||
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \
|
||||
--dev-bind-try /home /home \
|
||||
$@
|
||||
|
||||
|
||||
}
|
||||
# Move the package init work to build stage
|
||||
#bookworm-run apt update
|
||||
#bookworm-run apt install apt-utils bc curl dialog diffutils findutils gnupg2 less libnss-myhostname libvte-2.9*-common libvte-common lsof ncurses-base passwd pinentry-curses procps sudo time util-linux wget libegl1-mesa libgl1-mesa-glx libvulkan1 mesa-vulkan-drivers locales libglib2.0-bin -y
|
||||
echo "Update the flamescion container tools"
|
||||
cp -r `dirname $chrootEnvPath`/flamescion-container-tools/ $chrootEnvPath
|
||||
|
||||
rm -rf $chrootEnvPath/usr/lib/`gcc -dumpmachine`/dri/dri
|
||||
# 之前错误的多复制了一个,这里删掉
|
||||
|
||||
container_user_gid="$(sudo -u $non_root_user id -rg)"
|
||||
container_user_home="/home/${non_root_user}"
|
||||
container_user_name="${non_root_user}"
|
||||
container_user_uid="$(sudo -u $non_root_user id -ru)"
|
||||
|
||||
|
||||
cat << EOFFFFFF > $chrootEnvPath/init.sh
|
||||
#!/bin/bash
|
||||
printf "bookworm-cm: Setting up sudo...\n"
|
||||
mkdir -p /etc/sudoers.d
|
||||
# Do not check fqdn when doing sudo, it will not work anyways
|
||||
if ! grep -q 'Defaults !fqdn' /etc/sudoers.d/sudoers; then
|
||||
printf "Defaults !fqdn\n" >> /etc/sudoers.d/sudoers
|
||||
fi
|
||||
# Ensure passwordless sudo is set up for user
|
||||
if ! grep -q "\"${container_user_name}\" ALL = (root) NOPASSWD:ALL" /etc/sudoers.d/sudoers; then
|
||||
printf "\"%s\" ALL = (root) NOPASSWD:ALL\n" "${container_user_name}" >> /etc/sudoers.d/sudoers
|
||||
fi
|
||||
|
||||
|
||||
printf "bookworm-cm: Setting up groups...\n"
|
||||
# If not existing, ensure we have a group for our user.
|
||||
if ! grep -q "^${container_user_name}:" /etc/group; then
|
||||
if ! groupadd --force --gid "${container_user_gid}" "${container_user_name}"; then
|
||||
# It may occur that we have users with unsupported user name (eg. on LDAP or AD)
|
||||
# So let's try and force the group creation this way.
|
||||
printf "%s:x:%s:" "${container_user_name}" "${container_user_gid}" >> /etc/group
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "bookworm-cm: Setting up users...\n"
|
||||
|
||||
# Setup kerberos integration with the host
|
||||
if [ -d "/run/host/var/kerberos" ] &&
|
||||
[ -d "/etc/krb5.conf.d" ] &&
|
||||
[ ! -e "/etc/krb5.conf.d/kcm_default_ccache" ]; then
|
||||
|
||||
cat << EOF > "/etc/krb5.conf.d/kcm_default_ccache"
|
||||
# # To disable the KCM credential cache, comment out the following lines.
|
||||
[libdefaults]
|
||||
default_ccache_name = KCM:
|
||||
EOF
|
||||
fi
|
||||
|
||||
# If we have sudo/wheel groups, let's add the user to them.
|
||||
additional_groups=""
|
||||
if grep -q "^sudo" /etc/group; then
|
||||
additional_groups="sudo"
|
||||
elif grep -q "^wheel" /etc/group; then
|
||||
additional_groups="wheel"
|
||||
fi
|
||||
|
||||
# Let's add our user to the container. if the user already exists, enforce properties.
|
||||
#
|
||||
# In case of AD or LDAP usernames, it is possible we will have a backslach in the name.
|
||||
# In that case grep would fail, so we replace the backslash with a point to make the regex work.
|
||||
# shellcheck disable=SC1003
|
||||
if ! grep -q "^$(printf '%s' "${container_user_name}" | tr '\\' '.'):" /etc/passwd &&
|
||||
! grep -q "^.*:.*:${container_user_uid}:" /etc/passwd; then
|
||||
if ! useradd \
|
||||
--home-dir "${container_user_home}" \
|
||||
--no-create-home \
|
||||
--groups "${additional_groups}" \
|
||||
--shell "${SHELL:-"/bin/bash"}" \
|
||||
--uid "${container_user_uid}" \
|
||||
--gid "${container_user_gid}" \
|
||||
"${container_user_name}"; then
|
||||
|
||||
printf "Warning: there was a problem setting up the user\n"
|
||||
printf "Warning: trying manual addition\n"
|
||||
printf "%s:x:%s:%s:%s:%s:%s" \
|
||||
"${container_user_name}" "${container_user_uid}" \
|
||||
"${container_user_gid}" "${container_user_name}" \
|
||||
"${container_user_home}" "${SHELL:-"/bin/bash"}" >> /etc/passwd
|
||||
printf "%s::1::::::" "${container_user_name}" >> /etc/shadow
|
||||
fi
|
||||
# Ensure we're not using the specified SHELL. Run it only once, so that future
|
||||
# user's preferences are not overwritten at each start.
|
||||
elif [ ! -e /etc/passwd.done ]; then
|
||||
# This situation is presented when podman or docker already creates the user
|
||||
# for us inside container. We should modify the user's prepopulated shadowfile
|
||||
# entry though as per user's active preferences.
|
||||
|
||||
# If the user was there with a different username, get that username so
|
||||
# we can modify it
|
||||
if ! grep -q "^$(printf '%s' "${container_user_name}" | tr '\\' '.'):" /etc/passwd; then
|
||||
user_to_modify=$(getent passwd "${container_user_uid}" | cut -d: -f1)
|
||||
fi
|
||||
|
||||
if ! usermod \
|
||||
--home "${container_user_home}" \
|
||||
--shell "${SHELL:-"/bin/bash"}" \
|
||||
--groups "${additional_groups}" \
|
||||
--uid "${container_user_uid}" \
|
||||
--gid "${container_user_gid}" \
|
||||
--login "${container_user_name}" \
|
||||
"${user_to_modify:-"${container_user_name}"}"; then
|
||||
|
||||
printf "Warning: there was a problem setting up the user\n"
|
||||
fi
|
||||
touch /etc/passwd.done
|
||||
fi
|
||||
|
||||
# We generate a random password to initialize the entry for the user and root.
|
||||
temporary_password="$(cat /proc/sys/kernel/random/uuid)"
|
||||
printf "%s\n%s\n" "${temporary_password}" "${temporary_password}" | passwd root
|
||||
printf "%s:%s" "${container_user_name}" "${temporary_password}" | chpasswd -e
|
||||
# Delete password for root and user
|
||||
printf "%s:" "root" | chpasswd -e
|
||||
printf "%s:" "${container_user_name}" | chpasswd -e
|
||||
|
||||
mkdir -p /usr/share/fonts
|
||||
mkdir -p /usr/share/icons
|
||||
mkdir -p /usr/share/themes
|
||||
|
||||
## init host-spawn
|
||||
unlink /flamescion-container-tools/bin-override/host-spawn
|
||||
ln -sfv /flamescion-container-tools/bin-override/host-spawn-$(uname -m) /flamescion-container-tools/bin-override/host-spawn
|
||||
|
||||
## install host-integration
|
||||
|
||||
apt install --reinstall /flamescion-container-tools/ace-host-integration.deb
|
||||
|
||||
|
||||
|
||||
### Do NVIDIA Integration
|
||||
|
||||
echo "ACE: NVIDIA Integration"
|
||||
|
||||
ensureTargetDir() {
|
||||
targetFile=$1
|
||||
t=$(dirname "$targetFile")
|
||||
mkdir -p "$t"
|
||||
}
|
||||
|
||||
|
||||
lib32_dir="/usr/lib/"
|
||||
lib64_dir="/usr/lib/"
|
||||
if [ -e "/usr/lib/x86_64-linux-gnu" ]; then
|
||||
lib64_dir="/usr/lib/x86_64-linux-gnu/"
|
||||
elif [ -e "/usr/lib64" ]; then
|
||||
lib64_dir="/usr/lib64/"
|
||||
fi
|
||||
if [ -e "/usr/lib/i386-linux-gnu" ]; then
|
||||
lib32_dir="/usr/lib/i386-linux-gnu/"
|
||||
elif [ -e "/usr/lib32" ]; then
|
||||
lib32_dir="/usr/lib32/"
|
||||
fi
|
||||
|
||||
# First we find all non-lib files we need, this includes
|
||||
# - binaries
|
||||
# - confs
|
||||
# - egl files
|
||||
# - icd files
|
||||
# Excluding here the libs, we will threat them later specifically
|
||||
NVIDIA_FILES="$(find /host/etc/ /host/usr/ \
|
||||
-path "/host/usr/lib/i386-linux-gnu/*" -prune -o \
|
||||
-path "/host/usr/lib/x86_64-linux-gnu/*" -prune -o \
|
||||
-path "/host/usr/lib32/*" -prune -o \
|
||||
-path "/host/usr/lib64/*" -prune -o \
|
||||
-iname "*nvidia*" -not -type d -print 2> /dev/null || :)"
|
||||
for nvidia_file in ${NVIDIA_FILES}; do
|
||||
dest_file="$(printf "%s" "${nvidia_file}" | sed 's|/host||g')"
|
||||
ensureTargetDir ${dest_file}
|
||||
cp -r "${nvidia_file}" "${dest_file}"
|
||||
done
|
||||
|
||||
# Then we find all directories with nvidia in the name and just mount them
|
||||
NVIDIA_DIRS="$(find /host/etc /host/usr -iname "*nvidia*" -type d 2> /dev/null || :)"
|
||||
for nvidia_dir in ${NVIDIA_DIRS}; do
|
||||
# /usr/lib64 is common in Arch or RPM based distros, while /usr/lib/x86_64-linux-gnu is
|
||||
# common on Debian derivatives, so we need to adapt between the two nomenclatures.
|
||||
if printf "%s" "${nvidia_dir}" | grep -Eq "lib32|lib64|x86_64-linux-gnu|i386-linux-gnu"; then
|
||||
|
||||
# Remove origin so we plug our own
|
||||
dest_dir="$(printf "%s" "${nvidia_dir}" |
|
||||
sed "s|/host/usr/lib/x86_64-linux-gnu/|${lib64_dir}|g" |
|
||||
sed "s|/host/usr/lib/i386-linux-gnu/|${lib32_dir}|g" |
|
||||
sed "s|/host/usr/lib64/|${lib64_dir}|g" |
|
||||
sed "s|/host/usr/lib32/|${lib32_dir}|g")"
|
||||
else
|
||||
dest_dir="$(printf "%s" "${nvidia_dir}" | sed 's|/host||g')"
|
||||
fi
|
||||
ensureTargetDir ${dest_file}
|
||||
cp -r "${nvidia_dir}" "${dest_file}"
|
||||
done
|
||||
|
||||
# Then we find all the ".so" libraries, there are searched separately
|
||||
# because we need to extract the relative path to mount them in the
|
||||
# correct path based on the guest's setup
|
||||
#
|
||||
# /usr/lib64 is common in Arch or RPM based distros, while /usr/lib/x86_64-linux-gnu is
|
||||
# common on Debian derivatives, so we need to adapt between the two nomenclatures.
|
||||
NVIDIA_LIBS="$(find \
|
||||
/host/usr/lib/i386-linux-gnu/ \
|
||||
/host/usr/lib/x86_64-linux-gnu/ \
|
||||
/host/usr/lib32/ \
|
||||
/host/usr/lib64/ \
|
||||
-iname "*nvidia*.so*" \
|
||||
-o -iname "libcuda*.so*" \
|
||||
-o -iname "libnvcuvid*.so*" \
|
||||
-o -iname "libnvoptix*.so*" 2> /dev/null || :)"
|
||||
for nvidia_lib in ${NVIDIA_LIBS}; do
|
||||
dest_file="$(printf "%s" "${nvidia_lib}" |
|
||||
sed "s|/host/usr/lib/x86_64-linux-gnu/|${lib64_dir}|g" |
|
||||
sed "s|/host/usr/lib/i386-linux-gnu/|${lib32_dir}|g" |
|
||||
sed "s|/host/usr/lib64/|${lib64_dir}|g" |
|
||||
sed "s|/host/usr/lib32/|${lib32_dir}|g")"
|
||||
|
||||
# If file exists, just continue
|
||||
# this may happen for directories like /usr/lib/nvidia/xorg/foo.so
|
||||
# where the directory is already bind mounted (ro) and we don't need
|
||||
# to mount further files in it.
|
||||
if [ -e "${dest_file}" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
type="file"
|
||||
if [ -L "${nvidia_lib}" ]; then
|
||||
type="link"
|
||||
fi
|
||||
|
||||
if [ "${type}" = "link" ]; then
|
||||
mkdir -p "$(dirname "${dest_file}")"
|
||||
cp -d "${nvidia_lib}" "${dest_file}"
|
||||
continue
|
||||
fi
|
||||
ensureTargetDir ${dest_file}
|
||||
cp -r "${nvidia_lib}" "${dest_file}"
|
||||
|
||||
done
|
||||
|
||||
# Refresh ldconfig cache, also detect if there are empty files remaining
|
||||
# and clean them.
|
||||
# This could happen when upgrading drivers and changing versions.
|
||||
empty_libs="$(ldconfig 2>&1 | grep -Eo "File.*is empty" | cut -d' ' -f2)"
|
||||
if [ -n "${empty_libs}" ]; then
|
||||
# shellcheck disable=SC2086
|
||||
find ${empty_libs} -delete 2> /dev/null || :
|
||||
find /usr/ /etc/ -empty -iname "*nvidia*" -delete 2> /dev/null || :
|
||||
fi
|
||||
|
||||
|
||||
EOFFFFFF
|
||||
|
||||
#####init
|
||||
|
||||
chmod +x $chrootEnvPath/init.sh
|
||||
bookworm-run bash /init.sh
|
||||
bookworm-run rm /init.sh
|
||||
bookworm-run cp /host/etc/locale.gen /etc/locale.gen && locale-gen
|
||||
|
||||
bookworm-run touch /finish.flag
|
||||
bookworm-run apt clean
|
||||
bookworm-run chown -R $(who | awk '{print $1}' | head -n 1) /usr/lib/locale/
|
||||
sudo -u $(who | awk '{print $1}' | head -n 1) bwrap --dev-bind $chrootEnvPath/ / \
|
||||
--setenv LANG "$LANG" \
|
||||
--setenv LC_COLLATE "$LC_COLLATE" \
|
||||
--setenv LC_CTYPE "$LC_CTYPE" \
|
||||
--setenv LC_MONETARY "$LC_MONETARY" \
|
||||
--setenv LC_MESSAGES "$LC_MESSAGES" \
|
||||
--setenv LC_NUMERIC "$LC_NUMERIC" \
|
||||
--setenv LC_TIME "$LC_TIME" \
|
||||
--setenv LC_ALL "$LC_ALL" \
|
||||
--setenv PULSE_SERVER /run/user/$uid/pulse/native \
|
||||
--setenv PATH /flamescion-container-tools/bin-override:$PATH \
|
||||
--setenv IS_ACE_ENV "1" \
|
||||
--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 \
|
||||
--bind-try /usr/share/themes /usr/local/share/themes \
|
||||
--bind-try /usr/share/icons /usr/local/share/icons \
|
||||
--bind-try /usr/share/fonts /usr/local/share/fonts \
|
||||
--hostname Amber-CE-Bookworm \
|
||||
--unshare-uts \
|
||||
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \
|
||||
--dev-bind-try /home /home \
|
||||
locale-gen
|
||||
|
||||
chown -R root $chrootEnvPath
|
||||
|
||||
@@ -6,20 +6,14 @@ 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 [ "$(id -u)" = "0" ]; then
|
||||
`dirname $chrootEnvPath`/bin/bookworm-run-root "$@"
|
||||
exit
|
||||
fi
|
||||
chrootEnvPath=/opt/apps/$PKGNAME/files/ace-env
|
||||
|
||||
if [ ! -e $chrootEnvPath/finish.flag ];then
|
||||
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
`dirname $chrootEnvPath`/bin/bookworm-init
|
||||
`dirname $chrootEnvPath`/bin/ace-init
|
||||
else
|
||||
pkexec `dirname $chrootEnvPath`/bin/bookworm-init
|
||||
pkexec `dirname $chrootEnvPath`/bin/ace-init
|
||||
fi
|
||||
|
||||
|
||||
@@ -40,39 +34,127 @@ for arg in "$@"; do
|
||||
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 --dev-bind / / \
|
||||
bwrap \
|
||||
--setenv LANG "$LANG" \
|
||||
--setenv LC_COLLATE "$LC_COLLATE" \
|
||||
--setenv LC_CTYPE "$LC_CTYPE" \
|
||||
--setenv LC_MONETARY "$LC_MONETARY" \
|
||||
--setenv LC_MESSAGES "$LC_MESSAGES" \
|
||||
--setenv LC_NUMERIC "$LC_NUMERIC" \
|
||||
--setenv LC_TIME "$LC_TIME" \
|
||||
--setenv LC_ALL "$LC_ALL" \
|
||||
--setenv PULSE_SERVER /run/user/$uid/pulse/native \
|
||||
--setenv PATH /flamescion-container-tools/bin-override:$PATH \
|
||||
--setenv IS_ACE_ENV "1" \
|
||||
--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 \
|
||||
--hostname Amber-CE-Bookworm \
|
||||
--unshare-uts \
|
||||
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \
|
||||
--cap-add CAP_SYS_ADMIN \
|
||||
--dev-bind-try /home /home \
|
||||
bash -c "${container_command}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
##########合成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 /mnt /mnt"
|
||||
"--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"
|
||||
"--ro-bind-try $(realpath /etc/localtime) /etc/localtime"
|
||||
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
|
||||
"--dev-bind-try /home /home"
|
||||
|
||||
)
|
||||
EXTRA_ARGS=(
|
||||
"--hostname Amber-CE-Bookworm"
|
||||
"--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}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
#!/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/ace-env
|
||||
|
||||
if [ ! -e $chrootEnvPath/finish.flag ];then
|
||||
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
`dirname $chrootEnvPath`/bin/ace-init
|
||||
else
|
||||
pkexec `dirname $chrootEnvPath`/bin/ace-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"
|
||||
"--ro-bind-try $(realpath /etc/localtime) /etc/localtime"
|
||||
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
|
||||
"--dev-bind-try /home /home"
|
||||
|
||||
)
|
||||
EXTRA_ARGS=(
|
||||
"--hostname Amber-CE-Bookworm"
|
||||
"--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 \"/usr/bin/bwrap ${container_command}\""
|
||||
|
||||
# 输出完整的 EXEC_COMMAND 以查看
|
||||
# echo "${EXEC_COMMAND}"
|
||||
|
||||
# 注意: 实际执行时,请确保所有变量(如 $uid, $chrootEnvPath 等)都已正确定义
|
||||
eval ${EXEC_COMMAND}
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "当前用户不是 root 用户,退出"
|
||||
exit
|
||||
fi
|
||||
|
||||
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 --dev-bind / / \
|
||||
bwrap \
|
||||
--setenv LANG "$LANG" \
|
||||
--setenv LC_COLLATE "$LC_COLLATE" \
|
||||
--setenv LC_CTYPE "$LC_CTYPE" \
|
||||
--setenv LC_MONETARY "$LC_MONETARY" \
|
||||
--setenv LC_MESSAGES "$LC_MESSAGES" \
|
||||
--setenv LC_NUMERIC "$LC_NUMERIC" \
|
||||
--setenv LC_TIME "$LC_TIME" \
|
||||
--setenv LC_ALL "$LC_ALL" \
|
||||
--setenv PULSE_SERVER /run/user/$uid/pulse/native \
|
||||
--setenv PATH /flamescion-container-tools/bin-override:$PATH \
|
||||
--setenv IS_ACE_ENV "1" \
|
||||
--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 \
|
||||
--bind-try /usr/share/themes /usr/local/share/themes \
|
||||
--bind-try /usr/share/icons /usr/local/share/icons \
|
||||
--bind-try /usr/share/fonts /usr/local/share/fonts \
|
||||
--hostname Amber-CE-Bookworm \
|
||||
--unshare-uts \
|
||||
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \
|
||||
--cap-add CAP_SYS_ADMIN \
|
||||
--dev-bind-try /home /home \
|
||||
bash -c "${container_command}"
|
||||
|
||||
|
||||
|
||||
@@ -14,22 +14,29 @@ fi
|
||||
if [ "$1" = "amd64" ] || [ "$1" = "x64" ];then
|
||||
ARCH="amd64"
|
||||
ARCH_ANOTHERWAY="x64"
|
||||
cd "`dirname $0`"
|
||||
sudo debootstrap --include=libnotify-bin,apt-utils,bash-completion,bc,curl,dialog,diffutils,findutils,gnupg2,less,libnss-myhostname,libvte-common,lsof,ncurses-base,passwd,pinentry-curses,procps,sudo,time,util-linux,wget,libegl1-mesa,libgl1-mesa-glx,libvulkan1,mesa-vulkan-drivers,locales,libglib2.0-bin --arch=${ARCH} bookworm ./ace-env https://mirrors.ustc.edu.cn/debian/
|
||||
|
||||
elif [ "$1" = "arm64" ] || [ "$1" = "arm" ];then
|
||||
ARCH="arm64"
|
||||
ARCH_ANOTHERWAY="arm64"
|
||||
else
|
||||
echo "Invalid architecture! Exit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "`dirname $0`"
|
||||
sudo debootstrap --include=libnotify-bin,apt-utils,bash-completion,bc,curl,dialog,diffutils,findutils,gnupg2,less,libnss-myhostname,libvte-common,lsof,ncurses-base,passwd,pinentry-curses,procps,sudo,time,util-linux,wget,libegl1-mesa,libgl1-mesa-glx,libvulkan1,mesa-vulkan-drivers,locales,libglib2.0-bin --arch=${ARCH} bookworm ./bookworm-env https://mirrors.ustc.edu.cn/debian/
|
||||
sudo debootstrap --include=libnotify-bin,apt-utils,bash-completion,bc,curl,dialog,diffutils,findutils,gnupg2,less,libnss-myhostname,libvte-common,lsof,ncurses-base,passwd,pinentry-curses,procps,sudo,time,util-linux,wget,libegl1-mesa,libgl1-mesa-glx,libvulkan1,mesa-vulkan-drivers,locales,libglib2.0-bin --arch=${ARCH} bookworm ./ace-env https://mirrors.ustc.edu.cn/debian/
|
||||
elif [ "$1" = "loong" ] || [ "$1" = "loong64" ];then
|
||||
ARCH="loong64"
|
||||
ARCH_ANOTHERWAY="loong64"
|
||||
sudo debootstrap --no-check-gpg --include=libnotify-bin,apt-utils,bash-completion,bc,curl,dialog,diffutils,findutils,gnupg2,less,libnss-myhostname,libvte-common,lsof,ncurses-base,passwd,pinentry-curses,procps,sudo,time,util-linux,wget,libegl1,libgl1-mesa-dri,libvulkan1,mesa-vulkan-drivers,locales,libglib2.0-bin --arch=${ARCH} --variant=buildd sid ./ace-env http://lauosc.cn:11232/debian
|
||||
else
|
||||
echo "Need to point out architecture"
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
sudo rm -rf bookworm-env/var/cache/apt/archives/*.deb
|
||||
sudo rm -rf ace-env/var/cache/apt/archives/*.deb
|
||||
|
||||
sudo tar -I 'xz -T0' -cvf bookworm-env.tar.xz bookworm-env/*
|
||||
sudo rm -rf bookworm-env
|
||||
sudo tar -I 'xz -T0' -cvf ace-env.tar.xz ace-env/*
|
||||
sudo rm -rf ace-env
|
||||
|
||||
pushd flamescion-container-tools/ace-host-integration
|
||||
|
||||
|
||||
@@ -1,5 +1,43 @@
|
||||
#!/bin/bash
|
||||
ACE_dir="/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env"
|
||||
# ===== Log =====
|
||||
# log.info xxx
|
||||
# log.warn xxx
|
||||
# log.info xxx
|
||||
# log.debug xxx
|
||||
# 带颜色的echo
|
||||
function log.color_output() {
|
||||
local color=$1
|
||||
shift 1
|
||||
|
||||
echo >&2 -e "\033[${color}m$@\033[0m"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Log is named without prefix "utils." for convenience
|
||||
# Usage: log.log <level> ...content
|
||||
function log.log() {
|
||||
if [[ $# < 2 ]]; then
|
||||
return -1
|
||||
fi
|
||||
|
||||
local level=$1
|
||||
shift 1
|
||||
|
||||
case $level in
|
||||
error) log.color_output "0;31" "[ERROR] $@" ;;
|
||||
warn) log.color_output "1;33" "[WARN] $@" ;;
|
||||
info) log.color_output "1;37" "[INFO] $@" ;;
|
||||
debug) log.color_output "1;30" "[DEBUG] $@" ;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function log.error() { log.log "error" "$@"; }
|
||||
function log.warn() { log.log "warn" $@; }
|
||||
function log.info() { log.log "info" $@; }
|
||||
function log.debug() { log.log "debug" $@; }
|
||||
|
||||
|
||||
|
||||
function do_integrate(){
|
||||
@@ -11,12 +49,12 @@ local file=$1
|
||||
echo "$file is detected. Processing host system integration..."
|
||||
sed -i 's|^Exec=\(.*\)|Exec=bookworm-run \1|' "$file"
|
||||
sed -i '/^TryExec=/d' "$file"
|
||||
sed -i '/^Name=/ s/$/ (ACE-Integration)/' "$file"
|
||||
sed -i "/^Name\[${LANGUAGE}\]=/ s/\$/ (ACE-Integration)/" "$file"
|
||||
sed -i '/^Name=/ s/$/ (Bookworm)/' "$file"
|
||||
sed -i "/^Name\[${LANGUAGE}\]=/ s/\$/ (Bookworm)/" "$file"
|
||||
icon_line=$(grep "^Icon=" "$file")
|
||||
if [[ "$icon_line" == "Icon=/"* ]]; then
|
||||
# 如果Icon=后面接的是/,则添加前缀
|
||||
sed -i 's|^Icon=/|Icon=/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env/|' "$file"
|
||||
sed -i 's|^Icon=/|Icon=/opt/apps/amber-ce-bookworm/files/bookworm-env/|' "$file"
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -25,19 +63,25 @@ local file=$1
|
||||
chmod +x $file
|
||||
}
|
||||
|
||||
|
||||
|
||||
for app_dir in $(ls /opt/apps/); do
|
||||
if [ "${IS_ACE_ENV}" != "" ];then
|
||||
if [ -e /opt/apps/ ];then
|
||||
for app_dir in $(ls /opt/apps/); do
|
||||
for file in /opt/apps/$app_dir/entries/applications/*.desktop;do
|
||||
do_integrate $file
|
||||
|
||||
|
||||
done
|
||||
done
|
||||
|
||||
done
|
||||
else
|
||||
log.warn "No /opt/apps directory. Skip..."
|
||||
fi
|
||||
|
||||
for file in /usr/share/applications/*.desktop; do
|
||||
do_integrate $file
|
||||
done
|
||||
find "/usr/share/applications/" -xtype l -delete
|
||||
|
||||
else
|
||||
|
||||
log.error "DO NOT run me on host OS"
|
||||
fi
|
||||
|
||||
@@ -104,7 +104,7 @@ else
|
||||
log.error "Nope we support debian only now"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
${APT_COMMAND} clean
|
||||
${APT_COMMAND} update
|
||||
|
||||
updatetext=`${APT_COMMAND} update 2>&1`
|
||||
@@ -166,10 +166,10 @@ fi
|
||||
|
||||
user=$(who | awk '{print $1}' | head -n 1)
|
||||
|
||||
log.info "ACE环境中有 $update_app_number 个软件包可升级,正在自动升级"
|
||||
notify-send -a cn.flamescion.bookworm-compatibility-mode "ACE兼容环境" "ACE环境中有${update_app_number}个软件包可升级,执行自动升级..."
|
||||
log.info "ACE Bookworm环境中有 $update_app_number 个软件包可升级,正在自动升级"
|
||||
notify-send -a amber-ce-bookworm "ACE兼容环境" "ACE环境中有${update_app_number}个软件包可升级,执行自动升级..."
|
||||
|
||||
${APT_COMMAND} clean
|
||||
${APT_COMMAND} full-upgrade -y
|
||||
${APT_COMMAND} clean
|
||||
notify-send -a cn.flamescion.bookworm-compatibility-mode "ACE兼容环境" "自动升级结束"
|
||||
notify-send -a amber-ce-bookworm "ACE兼容环境" "自动升级结束"
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
host-spawn /opt/apps/amber-ce-bookworm/files/bin/bookworm-run-bwrap $@
|
||||
@@ -0,0 +1,128 @@
|
||||
#!/bin/bash
|
||||
if [ "$IS_ACE_ENV" != "1" ];then
|
||||
echo "ONLY RUN ME IN ACE"
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
|
||||
printf "ACE: Setting up sudo...\n"
|
||||
mkdir -p /etc/sudoers.d
|
||||
# Do not check fqdn when doing sudo, it will not work anyways
|
||||
if ! grep -q 'Defaults !fqdn' /etc/sudoers.d/sudoers; then
|
||||
printf "Defaults !fqdn\n" >> /etc/sudoers.d/sudoers
|
||||
fi
|
||||
# Ensure passwordless sudo is set up for user
|
||||
if ! grep -q "\"${container_user_name}\" ALL = (root) NOPASSWD:ALL" /etc/sudoers.d/sudoers; then
|
||||
printf "\"%s\" ALL = (root) NOPASSWD:ALL\n" "${container_user_name}" >> /etc/sudoers.d/sudoers
|
||||
fi
|
||||
|
||||
|
||||
printf "ACE: Setting up groups...\n"
|
||||
# If not existing, ensure we have a group for our user.
|
||||
if ! grep -q "^${container_user_name}:" /etc/group; then
|
||||
if ! groupadd --force --gid "${container_user_gid}" "${container_user_name}"; then
|
||||
# It may occur that we have users with unsupported user name (eg. on LDAP or AD)
|
||||
# So let's try and force the group creation this way.
|
||||
printf "%s:x:%s:" "${container_user_name}" "${container_user_gid}" >> /etc/group
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "ACE: Setting up users...\n"
|
||||
|
||||
# Setup kerberos integration with the host
|
||||
if [ -d "/run/host/var/kerberos" ] &&
|
||||
[ -d "/etc/krb5.conf.d" ] &&
|
||||
[ ! -e "/etc/krb5.conf.d/kcm_default_ccache" ]; then
|
||||
|
||||
cat << EOF > "/etc/krb5.conf.d/kcm_default_ccache"
|
||||
# # To disable the KCM credential cache, comment out the following lines.
|
||||
[libdefaults]
|
||||
default_ccache_name = KCM:
|
||||
EOF
|
||||
fi
|
||||
|
||||
# If we have sudo/wheel groups, let's add the user to them.
|
||||
additional_groups=""
|
||||
if grep -q "^sudo" /etc/group; then
|
||||
additional_groups="sudo"
|
||||
elif grep -q "^wheel" /etc/group; then
|
||||
additional_groups="wheel"
|
||||
fi
|
||||
|
||||
# Let's add our user to the container. if the user already exists, enforce properties.
|
||||
#
|
||||
# In case of AD or LDAP usernames, it is possible we will have a backslach in the name.
|
||||
# In that case grep would fail, so we replace the backslash with a point to make the regex work.
|
||||
# shellcheck disable=SC1003
|
||||
if ! grep -q "^$(printf '%s' "${container_user_name}" | tr '\\' '.'):" /etc/passwd &&
|
||||
! grep -q "^.*:.*:${container_user_uid}:" /etc/passwd; then
|
||||
if ! useradd \
|
||||
--home-dir "${container_user_home}" \
|
||||
--no-create-home \
|
||||
--groups "${additional_groups}" \
|
||||
--shell "${SHELL:-"/bin/bash"}" \
|
||||
--uid "${container_user_uid}" \
|
||||
--gid "${container_user_gid}" \
|
||||
"${container_user_name}"; then
|
||||
|
||||
printf "Warning: there was a problem setting up the user\n"
|
||||
printf "Warning: trying manual addition\n"
|
||||
printf "%s:x:%s:%s:%s:%s:%s" \
|
||||
"${container_user_name}" "${container_user_uid}" \
|
||||
"${container_user_gid}" "${container_user_name}" \
|
||||
"${container_user_home}" "${SHELL:-"/bin/bash"}" >> /etc/passwd
|
||||
printf "%s::1::::::" "${container_user_name}" >> /etc/shadow
|
||||
fi
|
||||
# Ensure we're not using the specified SHELL. Run it only once, so that future
|
||||
# user's preferences are not overwritten at each start.
|
||||
elif [ ! -e /etc/passwd.done ]; then
|
||||
# This situation is presented when podman or docker already creates the user
|
||||
# for us inside container. We should modify the user's prepopulated shadowfile
|
||||
# entry though as per user's active preferences.
|
||||
|
||||
# If the user was there with a different username, get that username so
|
||||
# we can modify it
|
||||
if ! grep -q "^$(printf '%s' "${container_user_name}" | tr '\\' '.'):" /etc/passwd; then
|
||||
user_to_modify=$(getent passwd "${container_user_uid}" | cut -d: -f1)
|
||||
fi
|
||||
|
||||
if ! usermod \
|
||||
--home "${container_user_home}" \
|
||||
--shell "${SHELL:-"/bin/bash"}" \
|
||||
--groups "${additional_groups}" \
|
||||
--uid "${container_user_uid}" \
|
||||
--gid "${container_user_gid}" \
|
||||
--login "${container_user_name}" \
|
||||
"${user_to_modify:-"${container_user_name}"}"; then
|
||||
|
||||
printf "Warning: there was a problem setting up the user\n"
|
||||
fi
|
||||
touch /etc/passwd.done
|
||||
fi
|
||||
|
||||
# We generate a random password to initialize the entry for the user and root.
|
||||
temporary_password="$(cat /proc/sys/kernel/random/uuid)"
|
||||
printf "%s\n%s\n" "${temporary_password}" "${temporary_password}" | passwd root
|
||||
printf "%s:%s" "${container_user_name}" "${temporary_password}" | chpasswd -e
|
||||
# Delete password for root and user
|
||||
printf "%s:" "root" | chpasswd -e
|
||||
printf "%s:" "${container_user_name}" | chpasswd -e
|
||||
|
||||
mkdir -p /usr/share/fonts
|
||||
mkdir -p /usr/share/icons
|
||||
mkdir -p /usr/share/themes
|
||||
|
||||
## init host-spawn
|
||||
unlink /flamescion-container-tools/bin-override/host-spawn
|
||||
ln -sfv /flamescion-container-tools/bin-override/host-spawn-$(uname -m) /flamescion-container-tools/bin-override/host-spawn
|
||||
|
||||
## install host-integration
|
||||
|
||||
apt install --reinstall /flamescion-container-tools/ace-host-integration.deb
|
||||
|
||||
cd /
|
||||
mkdir -p /flamescion-container-tools/data-dir
|
||||
cd /flamescion-container-tools/data-dir/
|
||||
ln -sfv ../../usr/share/applications/ .
|
||||
ln -sfv ../../usr/share/icons/ .
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"appid": "cn.flamescion.bookworm-compatibility-mode",
|
||||
"appid": "amber-ce-bookworm",
|
||||
"name": "cn.flamescion.bookworm-compatibility-mode",
|
||||
"version": "12.1.4",
|
||||
"arch": ["amd64"],
|
||||
|
||||
1
src/usr/bin/ace-bookworm-uninstall-helper
Symbolic link
@@ -0,0 +1 @@
|
||||
../../opt/apps/amber-ce-bookworm/files/bin/ace-bookworm-uninstall-helper
|
||||
1
src/usr/bin/ace-bookworm-uninstall-helper-gui
Symbolic link
@@ -0,0 +1 @@
|
||||
../../opt/apps/amber-ce-bookworm/files/bin/ace-bookworm-uninstall-helper-gui
|
||||
@@ -1 +0,0 @@
|
||||
../../opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-uninstall-helper
|
||||
@@ -1 +0,0 @@
|
||||
../../opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-uninstall-helper-gui
|
||||
@@ -1 +0,0 @@
|
||||
../../opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-init
|
||||
@@ -1 +1 @@
|
||||
../../opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/bookworm-run
|
||||
../../opt/apps/amber-ce-bookworm/files/bin/bookworm-run
|
||||
@@ -10,7 +10,7 @@ fi
|
||||
|
||||
# Desktop files (used by desktop environments within both X11 and Wayland) are
|
||||
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for ACE
|
||||
ACE_path="/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bookworm-env/usr/share/"
|
||||
ACE_path="/opt/apps/amber-ce-bookworm/files/ace-env/flamescion-container-tools/data-dir/"
|
||||
if [ -n "${XDG_DATA_DIRS##*${ACE_path}}" ] && [ -n "${XDG_DATA_DIRS##*${ACE_path}:*}" ]; then
|
||||
export XDG_DATA_DIRS="${ACE_path}:${XDG_DATA_DIRS}"
|
||||
fi
|
||||
|
||||
11
src/usr/share/applications/ACE-bookworm-uninstaller.desktop
Normal file
@@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=ACE Bookworm Software Uninstaller
|
||||
Name[zh_CN]=ACE Bookworm软件卸载器
|
||||
Comment=用于卸载ACE容器的应用
|
||||
Type=Application
|
||||
Exec=/opt/apps/amber-ce-bookworm/files/bin/ace-bookworm-uninstall-helper-gui
|
||||
Icon=ACE-bookworm-uninstaller
|
||||
Categories=System
|
||||
|
||||
# Generated from the DesktopGenerater component of the z-Tools toolkit
|
||||
@@ -1,11 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=ACE Software Uninstaller
|
||||
Name[zh_CN]=ACE软件卸载器
|
||||
Comment=用于卸载ACE容器的应用
|
||||
Type=Application
|
||||
Exec=/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-uninstall-helper-gui
|
||||
Icon=ACE-uninstaller
|
||||
Categories=System
|
||||
|
||||
# Generated from the DesktopGenerater component of the z-Tools toolkit
|
||||
@@ -1,9 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Categories=utils
|
||||
Exec=bookworm-run %U
|
||||
Icon=cn.flamescion.bookworm-compatibility-mode
|
||||
Name=Amber CE
|
||||
Name[zh_CN]=ACE兼容环境
|
||||
Icon=amber-ce-bookworm
|
||||
Name=Amber CE Bookworm
|
||||
Name[zh_CN]=ACE Bookworm兼容环境
|
||||
Keywords=BCM,ACE,ace,mode
|
||||
StartupNotify=true
|
||||
Type=Application
|
||||
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 134 KiB |
@@ -2,17 +2,17 @@
|
||||
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
<vendor>cn.flamescion.ace-uninstaller</vendor>
|
||||
<vendor>amber-ce-bookworm.ace-uninstaller</vendor>
|
||||
<icon_name>x-package-repository</icon_name>
|
||||
<action id="cn.flamescion.ace-uninstaller">
|
||||
<description>运行cn.flamescion.ace-uninstaller需要权限</description>
|
||||
<message>要使用cn.flamescion.ace-uninstaller需要权限</message>
|
||||
<action id="amber-ce-bookworm.ace-uninstaller">
|
||||
<description>运行amber-ce-bookworm.ace-uninstaller需要权限</description>
|
||||
<message>要使用amber-ce-bookworm.ace-uninstaller需要权限</message>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/opt/apps/cn.flamescion.bookworm-compatibility-mode/files/bin/ace-uninstall-helper-gui</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/opt/apps/amber-ce-bookworm/files/bin/ace-bookworm-uninstall-helper-gui</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
</policyconfig>
|
||||