Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with anylinux appimage with yt-dlp #3

Merged
merged 25 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .github/workflows/blank2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: build
run: |
Expand All @@ -21,16 +21,14 @@ jobs:
sudo apt install equivs libavutil-dev libavcodec-dev libswscale-dev python3-dev cython3 g++ nasm git libavfilter-dev libxmu-dev libxcb1-dev
sudo apt install libfuse2 libdbus-1-dev libx11-dev libxinerama-dev libxrandr-dev yasm intltool autoconf libtool devscripts libass-dev libx264-dev
sudo apt install libxss-dev libglib2.0-dev libpango1.0-dev libgtk-3-dev libxdg-basedir-dev libnotify-dev libc++-dev libplacebo-dev libx265-dev
sudo apt install ninja-build autotools-dev autoconf automake make build-essential pkg-config python3-pip
sudo apt install ninja-build autotools-dev autoconf automake make build-essential pkg-config python3-pip desktop-file-utils zsync
sudo pip3 install packaging meson
wget https://raw.githubusercontent.com/Samueru-sama/mpv-AppImage/main/mpv-AppImage.sh
chmod a+x ./*.sh
./mpv-AppImage.sh
chmod a+x ./mpv-AppImage.sh && ./mpv-AppImage.sh
mkdir dist
mv *AppImage dist/
mv *.AppImage* dist/

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: mpv-x86_64.AppImage
path: 'dist'
Expand All @@ -41,7 +39,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: mpv-x86_64.AppImage

Expand All @@ -53,5 +51,5 @@ jobs:
prerelease: false
draft: false
files: |
*.AppImage
*.AppImage*
repo_token: ${{ secrets.GITHUB_TOKEN }}
90 changes: 48 additions & 42 deletions mpv-AppImage.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,61 @@
#!/bin/sh

# THIS SCRIPT BUILDS MPV DEPENDENCIES AND MPV STATICALLY USING THIS: https://github.com/mpv-player/mpv-build
# dependencies:
# meson cmake automake ninja ninja-build vulkan-headers freetype-dev libass-dev libtool
# fribidi-dev harfbuzz-dev yasm libx11 libx11-dev libxinerama-dev libxrandr-dev
# libxscrnsaver libxscrnsaver-dev xscreensaver-gl-extras jack libpulse pulseaudio-dev
# rubberband libcaca mesa-egl libxpresent-dev lua5.3-dev libxcb-dev desktop-file-utils

set -u
export ARCH=x86_64
export ARCH="$(uname -m)"
export APPIMAGE_EXTRACT_AND_RUN=1
APP=mpv
APPDIR="$APP".AppDir
REPO="https://github.com/mpv-player/mpv-build.git"
EXEC="$APP"
APPIMAGETOOL=$(wget -q https://api.github.com/repos/probonopd/go-appimage/releases -O - | sed 's/[()",{} ]/\n/g' | grep -oi 'https.*continuous.*tool.*x86_64.*mage$' | head -1)
GOAPPIMAGETOOL=$(wget -q https://api.github.com/repos/probonopd/go-appimage/releases -O - \
| sed 's/[()",{} ]/\n/g' | grep -oi 'https.*continuous.*tool.*x86_64.*mage$' | head -1)
APPIMAGETOOL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
UPINFO="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|mpv-AppImage|latest|*$ARCH.AppImage.zsync"
rm -rf ./mpv 2>/dev/null
mkdir -p ./mpv/mpv.AppDir && cd ./mpv/mpv.AppDir || exit 1

# make vulkan headers
wget https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/v1.3.238.tar.gz
wget "https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/v1.3.238.tar.gz"
tar fx *tar* && cd Vulkan*
cmake -S . -B build/
sudo cmake --install build --prefix '/usr'
cd .. && rm -rf ./*tar* ./Vulkan*

# CREATE DIRECTORIES AND BUILD MPV
[ -n "$APP" ] && mkdir -p ./"$APP/$APPDIR" && cd ./"$APP/$APPDIR" || exit 1
CURRENTDIR="$(readlink -f "$(dirname "$0")")" # DO NOT MOVE THIS
git clone "$REPO" && cd ./mpv-build && sed -i "s#meson setup build#meson setup build -Dprefix=$CURRENTDIR/usr#g" ./scripts/mpv-config \
&& ./rebuild -j$(nproc) && ./install && cd .. && rm -rf ./mpv-build || exit 1

# AppRun
cat >> ./AppRun << 'EOF'
#!/bin/sh
CURRENTDIR="$(dirname "$(readlink -f "$0")")"
if [ -z "$@" ]; then
"$CURRENTDIR/usr/bin/mpv" --player-operation-mode=pseudo-gui
else
"$CURRENTDIR/usr/bin/mpv" "$@"
# Build mpv
if [ ! -d ./usr ]; then
CURRENTDIR="$(readlink -f "$(dirname "$0")")"
git clone "$REPO" && cd ./mpv-build || exit 1
sed -i "s#meson setup build#meson setup build -Dprefix=$CURRENTDIR/usr#g" ./scripts/mpv-config
./rebuild -j$(nproc) && ./install && cd .. && rm -rf ./mpv-build || exit 1
cp ./usr/share/icons/hicolor/128x128/apps/mpv.png ./ && ln -s ./mpv.png ./.DirIcon
fi
EOF
chmod a+x ./AppRun
export VERSION=$(./AppRun --version | awk 'FNR == 1 {print $2}')
cp ./usr/share/icons/hicolor/128x128/apps/mpv.png ./ && ln -s ./mpv.png ./.DirIcon # If not done linuxdeploy will pick the wrong icon

# MAKE APPIMAGE USING FUSE3 COMPATIBLE APPIMAGETOOL
cd .. && cp -r "$APPDIR" "$APPDIR"2 && wget -q "$APPIMAGETOOL" -O ./appimagetool && chmod a+x ./appimagetool || exit 1

./appimagetool deploy "$APPDIR"/usr/share/applications/*.desktop || exit 1
sed -i 's/export PYTHONHOME/#export PYTHONHOME/g' "$APPDIR"/AppRun # unsets this since python isn't bundled
./appimagetool -s ./"$APPDIR" || exit 1
mv ./*.AppImage .. && echo "Regular appimage made" || exit 1

# EXPERIMENTAL DEPLOY EVERYTHING MODE. TODO FIX INTERNET ISSUES
APPDIR="$APPDIR"2
export VERSION="$VERSION-anylinux"
sed -i 's/Name=mpv/Name=WIP-mpv/g' "$APPDIR"/usr/share/applications/*.desktop
./appimagetool -s deploy "$APPDIR"/usr/share/applications/*.desktop || exit 1
sed -i 's/export PYTHONHOME/#export PYTHONHOME/g' "$APPDIR"/AppRun # unsets this since python isn't bundled
./appimagetool -s ./"$APPDIR" || exit 1
[ -n "$APP" ] && mv ./*.AppImage .. && cd .. && rm -rf ./"$APP" && echo "Deploy everything appimage made" || exit 1

export VERSION=$(./usr/bin/mpv --version 2>/dev/null | awk 'FNR==1 {print $2}')
[ -z "$VERSION" ] && echo "ERROR: Could not get version from mpv" && exit 1

# bundle appdir
cd ..
[ ! -f ./go-appimagetool ] && { wget -q "$GOAPPIMAGETOOL" -O ./go-appimagetool || exit 1; }
chmod +x ./go-appimagetool
./go-appimagetool -s deploy ./mpv.AppDir/usr/share/applications/*.desktop || exit 1

# disable this since we are not shipping python
sed -i 's/export PYTHONHOME/#export PYTHONHOME/g' ./mpv.AppDir/AppRun

# Fix some issue with yt-dlp not working
# Likely go-appimage breaking something
cp /lib64/ld-linux-x86-64.so.2 ./mpv.AppDir/lib64/ld-linux-x86-64.so.2 || exit 1

# maybe not needed but I had appimagetool bug out before if the AppDir isnt in the top level of home
mv ./mpv.AppDir ../ && cd ../ || exit 1

# make appimage
[ ! -f ./appimagetool ] && { wget -q "$APPIMAGETOOL" -O ./appimagetool || exit 1; }
chmod +x ./appimagetool
./appimagetool --comp zstd \
--mksquashfs-opt -Xcompression-level --mksquashfs-opt 22 \
-n -u "$UPINFO" ./mpv.AppDir mpv-"$VERSION"-"$ARCH".AppImage
echo "All done!"