Skip to content

Commit

Permalink
feat: mapping app directory
Browse files Browse the repository at this point in the history
flatpak转换添加profile文件用于映射/app目录
修复flatpak转换遇到的问题
  • Loading branch information
myml authored and dengbo11 committed Sep 27, 2024
1 parent 20864c9 commit 7522e78
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
bin
bin
/tests
2 changes: 1 addition & 1 deletion cmd/ll-pica-flatpak/ll-pica-flatpak
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function main() {
--base) test -z "$2" || BASE="$2"; shift 2;;
--base-version) test -z "$2" || BASE_VERSION="$2"; shift 2;;
# # 转换为玲珑的版本,规则是按'.'和'-'分割取前三位,不足三位补0,再末尾补充输入的打包版本号,如 5.15-23.08 生成 5.15.23.0
--version) test -z "$2" || VERSION="$(echo "$2.0.0.0" | awk -F'[-.]' 'BEGIN {OFS="."} {print $1,$2,$3}').0"; shift 2;;
--version) test -z "$2" || VERSION="$(echo "${2/.0/.}.0.0.0" | awk -F'[-.]' 'BEGIN {OFS="."} {print $1,$2,$3}').0"; shift 2;;
--build) test -z "$2" || BUILD=true; shift 1;;
--layer) test -z "$2" || LAYER=true; shift 1;;
-h|--help) test -z "$2" || "${LL_PICA_FLATPAK_PATH}/ll-pica-flatpak-utils" help; shift 1; exit 0;;
Expand Down
30 changes: 10 additions & 20 deletions cmd/ll-pica-flatpak/ll-pica-flatpak-convert
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,12 @@ ostree --repo="$FLATHUB_CACHE" pull "$REF"
rm -rf "$WORKDIR" && mkdir -p "$WORKDIR"
ostree --repo="$FLATHUB_CACHE" checkout "$REF" "$WORKDIR/flatpak"

FLATPAK_COMMAND=$(grep '^command=' $WORKDIR/flatpak/metadata | awk -F'=' '{print $2}')
FLATPAK_RUNTIME=$(grep '^runtime=' "$WORKDIR"/flatpak/metadata | awk -F'=' '{print $2}' | awk -F'/' '{print $1}')
FLATPAK_RUNTIME_VERSION=$(grep '^runtime=' "$WORKDIR"/flatpak/metadata | awk -F'=' '{print $2}' | awk -F'/' '{print $3}')

LINGLONG_BASE_NAME="org.deepin.base.flatpak.$(echo "$FLATPAK_RUNTIME"|awk -F'.' '{print $2}')"
LINGLONG_BASE_VERSION="$(echo "$FLATPAK_RUNTIME_VERSION.0.0.0" | awk -F'[-.]' 'BEGIN {OFS="."} {print $1,$2,$3}')"

# 尝试获取 base 的信息
LINGLONG_INSTALL_INFO=$(ll-cli install "$LINGLONG_BASE_NAME")
if [[ "$LINGLONG_INSTALL_INFO" != *installed* && "$LINGLONG_INSTALL_INFO" != *success* ]];
then
echo "$LINGLONG_BASE_NAME not found"
exit 1
fi

# 如果没有存在这个 base 选择一个默认的
ll-cli info "$LINGLONG_BASE_NAME"
if [[ $? != 0 ]];
then
LINGLONG_BASE_NAME=org.deepin.base.flatpak.kde
ll-cli install $LINGLONG_BASE_NAME
LINGLONG_BASE_VERSION=$BASE_VERSION
fi
LINGLONG_BASE_VERSION="$(echo "${FLATPAK_RUNTIME_VERSION/.0/.}.0.0.0" | awk -F'[-.]' 'BEGIN {OFS="."} {print $1,$2,$3}')"

if [[ -n $BASE ]];
then
Expand Down Expand Up @@ -74,7 +58,6 @@ then
else
BIN_FILE_PATH=$APPID/flatpak/files/bin/$BIN_FILE
fi
sed -i "s|/app|/opt/apps/$APPID/files|g" "$BIN_FILE_PATH"

tee "$WORKDIR"/linglong.yaml <<EOF
version: "1"
Expand All @@ -85,12 +68,19 @@ package:
kind: app
description: flatpak runtime environment on linglong
command: [$EXEC]
command: [$FLATPAK_COMMAND]
base: $LINGLONG_BASE_NAME/$LINGLONG_BASE_VERSION
build: |
mkdir \$PREFIX/etc
cp profile \$PREFIX/etc
cp -rf flatpak/files/* \$PREFIX
EOF

tee $WORKDIR/profile<<EOF
#!/bin/sh
# bind /opt/apps/$APPID/files to /app
ln -s "/opt/apps/\$LINGLONG_APPID/files" /run/linglong/app
EOF

if $BUILD;
Expand Down
Empty file modified cmd/ll-pica-flatpak/ll-pica-flatpak-utils
100644 → 100755
Empty file.

0 comments on commit 7522e78

Please sign in to comment.