diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 8dcc514e..dcbfbd91 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -68,9 +68,8 @@ jobs: - name: Package AppImage if: github.event.inputs.release_tag != '' run: | - chmod 755 package-appimage.sh - ./package-appimage.sh $OutputArch $OutputPath64 ${{ github.event.inputs.release_tag }} - ./package-appimage.sh $OutputArchArm $OutputPathArm64 ${{ github.event.inputs.release_tag }} + chmod a+x package-appimage.sh + ./package-appimage.sh - name: Upload AppImage to release uses: svenstaro/upload-release-action@v2 diff --git a/package-appimage.sh b/package-appimage.sh index db48ef6c..77df287b 100644 --- a/package-appimage.sh +++ b/package-appimage.sh @@ -1,71 +1,14 @@ #!/bin/bash -Arch="$1" -OutputPath="$2" -Version="$3" - -FileName="v2rayN-${Arch}.zip" -wget -nv -O $FileName "https://github.com/2dust/v2rayN-core-bin/raw/refs/heads/master/$FileName" -7z x $FileName -aoa -cp -rf v2rayN-${Arch}/* $OutputPath - -PackagePath="v2rayN-Package-${Arch}" -mkdir -p "${PackagePath}/AppDir/opt" -cp -rf $OutputPath "${PackagePath}/AppDir/opt/v2rayN" -echo "When this file exists, app will not store configs under this folder" >"${PackagePath}/AppDir/opt/v2rayN/NotStoreConfigHere.txt" - -if [ $Arch = "linux-64" ]; then - Arch2="x86_64" - Arch3="amd64" -else - Arch2="aarch64" - Arch3="arm64" -fi -echo $Arch2 - -# basic -cat >"${PackagePath}/AppDir/AppRun" <<-EOF -#!/bin/sh -HERE="\$(dirname "\$(readlink -f "\${0}")")" -export PATH="\${HERE}"/opt/v2rayN/:"\${PATH}" -export LD_LIBRARY_PATH="\${HERE}"/opt/v2rayN/:"\${LD_LIBRARY_PATH}" -exec "\${HERE}/opt/v2rayN/v2rayN" \$@ -EOF - -cat >"${PackagePath}/AppDir/v2rayN.desktop" <<-EOF -[Desktop Entry] -Name=v2rayN -Comment=A GUI client for Windows and Linux, support Xray core and sing-box-core and others -Exec=v2rayN -Icon=v2rayN -Terminal=false -Type=Application -Categories=Network; -EOF - -sudo cp "${PackagePath}/AppDir/opt/v2rayN/v2rayN.png" "${PackagePath}/AppDir/v2rayN.png" -sudo dpkg --add-architecture ${Arch3} -mkdir deb_folder -cd deb_folder -apt download libicu74:${Arch3} -apt download libfontconfig1:${Arch3} || true -apt download libfontconfig:${Arch3} || true -mkdir ../output_folder -for deb in *.deb; do - dpkg-deb -x "$deb" ../output_folder/ -done -cd .. -find output_folder -type f -name "*.so*" -exec cp {} ${PackagePath}/AppDir/opt/v2rayN/ \; -find output_folder -type l -name "*.so*" -exec cp {} ${PackagePath}/AppDir/opt/v2rayN/ \; -rm -rf deb_folder output_folder - -sudo chmod 0755 "${PackagePath}/AppDir/opt/v2rayN/v2rayN" -sudo chmod 0755 "${PackagePath}/AppDir/AppRun" - -# desktop && PATH - -wget "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" -chmod a+x appimagetool-x86_64.AppImage +sudo apt update -y sudo apt install -y libfuse2 -sudo ./appimagetool-x86_64.AppImage "${PackagePath}/AppDir" -sudo mv "v2rayN-${Arch2}.AppImage" "v2rayN-${Arch}.AppImage" +wget -O pkg2appimage https://github.com/AppImageCommunity/pkg2appimage/releases/download/continuous/pkg2appimage-1eceb30-x86_64.AppImage +chmod a+x pkg2appimage +export AppImageOutputArch=$OutputArch +export OutputPath=$OutputPath64 +./pkg2appimage ./pkg2appimage.yml +mv out/*.AppImage v2rayN-${AppImageOutputArch}.AppImage +export AppImageOutputArch=$OutputArchArm +export OutputPath=$OutputPathArm64 +./pkg2appimage ./pkg2appimage.yml +mv out/*.AppImage v2rayN-${AppImageOutputArch}.AppImage diff --git a/pkg2appimage.yml b/pkg2appimage.yml new file mode 100644 index 00000000..0b4565c7 --- /dev/null +++ b/pkg2appimage.yml @@ -0,0 +1,37 @@ +app: v2rayN +binpatch: true + +ingredients: + script: + - export FileName="v2rayN-${AppImageOutputArch}.zip" + - wget -nv -O $FileName "https://github.com/2dust/v2rayN-core-bin/raw/refs/heads/master/${FileName}" + - 7z x $FileName -aoa + - cp -rf v2rayN-${AppImageOutputArch}/* $OutputPath + +script: + - mkdir -p usr/bin usr/lib + - cp -rf $OutputPath usr/lib/v2rayN + - echo "When this file exists, app will not store configs under this folder" > usr/lib/v2rayN/NotStoreConfigHere.txt + - ln -sf usr/lib/v2rayN/v2rayN usr/bin/v2rayN + - chmod a+x usr/lib/v2rayN/v2rayN + - find usr -type f -exec sh -c 'file "{}" | grep -qi "executable" && chmod +x "{}"' \; + - install -Dm644 usr/lib/v2rayN/v2rayN.png v2rayN.png + - install -Dm644 usr/lib/v2rayN/v2rayN.png usr/share/pixmaps/v2rayN.png + - cat > v2rayN.desktop < AppRun <<\EOF + - #!/bin/sh + - HERE="$(dirname "$(readlink -f "${0}")")" + - cd ${HERE}/usr/lib/v2rayN + - exec ${HERE}/usr/lib/v2rayN/v2rayN $@ + - EOF + - chmod a+x AppRun