Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
5,900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.94 KB | None | 0 0
  1. #!/bin/bash
  2. # Script that was used to build this package. Enjoy
  3.  
  4. # flatpak-make AppName /source/directory executable.exe
  5. # Put icon.png, Flatpak-Linux.md, Flatpak-Linux.reg and run.sh
  6. # files in to /source/directory when neeeded
  7.  
  8. NAME="$1"; shift
  9. APP="$1"; shift
  10. EXE="$1"; shift
  11.  
  12. # [ -z "$WINE" ] && WINE=~/.PlayOnLinux/wine/linux-amd64/2.19-staging
  13. [ -z "$WINE" ] && WINE=~/.PlayOnLinux/wine/linux-x86/2.19-staging
  14.  
  15. NICE_NAME=$(echo $(echo "$NAME" | sed 's/[A-Z]/ \0/g'))
  16. DOT_NAME=$(echo "$NICE_NAME" | tr " " . )
  17. WINEEXE="/app/bin/wine64"
  18. SRCLIB="/usr/lib/"
  19. LDLINUX=""
  20. ARCH="x86_64"
  21. LIB="lib64"
  22.  
  23. if [[ "$WINE" == *"x86"* ]] ; then
  24.     WINEEXE="/app/bin/wine"
  25.     SRCLIB="/usr/lib32/"
  26.     LDLINUX=$SRCLIB/ld-linux.so.2
  27.     ARCH="i386"
  28.     LIB="lib"
  29. fi
  30.  
  31. mkdir -p target/package/files/bin
  32. mkdir -p target/package/files/lib
  33. mkdir -p target/package/export/share/applications
  34. mkdir -p target/package/export/share/icons/hicolor
  35. mkdir -p target/\[Flatpak-Linux\]$DOT_NAME
  36.  
  37. cat << EOF > target/package/files/bin/run.sh
  38. #!/bin/bash
  39. mkdir -p /tmp/wine.$$.prefix/
  40. export WINEPREFIX=\$HOME/.local/share/flatpak-linux/$NAME/
  41. export WINEDLLOVERRIDES="mscoree=d;mshtml=d;"
  42. export WINEEXE="$WINEEXE"
  43.  
  44. cd "/app/$(basename "$APP")"
  45.  
  46. if [ -e Flatpak-Linux.md ] ; then
  47.     cat Flatpak-Linux.md | sed -e "s|FLATPAKNAME|org.flatpaklinux.$NAME|" -e "s|WINEPREFIX|\$WINEPREFIX|"
  48. fi
  49.  
  50. if [ -e Flatpak-Linux.reg ] ; then
  51.     $WINEEXE regedit /C Flatpak-Linux.reg
  52. fi
  53.  
  54.  
  55. if [ "\$1" == "winecfg" ] ; then
  56.     $WINEEXE winecfg
  57. elif [ "\$1" == "regedit" ] ; then
  58.     $WINEEXE regedit
  59. elif [ "\$1" == "bash" ] ; then
  60.     bash
  61. elif [ -e run.sh ] ; then
  62.     sh run.sh \$@
  63.     exit $?
  64. else
  65.     $WINEEXE "$EXE" \$@
  66.     exit $?
  67. fi
  68. EOF
  69.  
  70. cat << EOF >target/package/metadata
  71. [Application]
  72. name=org.flatpaklinux.$NAME
  73. runtime=org.freedesktop.Platform/$ARCH/1.6
  74. command=run.sh
  75.  
  76. [Context]
  77. features=devel;multiarch;
  78. shared=network;ipc;
  79. sockets=x11;pulseaudio;
  80. devices=dri;
  81. filesystems=xdg-documents;~/.local/share/flatpak-linux/:create
  82. EOF
  83.  
  84. cat << EOF >target/\[Flatpak-Linux\]$DOT_NAME/install.sh
  85. #!/bin/bash
  86. # Installs game bundle for user.
  87. # You can delete everything after installation.
  88.  
  89. DIR=\$(dirname "\$0")
  90. set -ex
  91. flatpak --user remote-add --if-not-exists --from gnome https://sdk.gnome.org/gnome.flatpakrepo || true
  92. flatpak --user install -y --app --bundle "\$DIR/$NAME.flatpak" || echo "Installation failed. Check if you have Flatpak properly configured. See http://flatpak.org/ for more info."
  93. EOF
  94.  
  95. cat << EOF >target/\[Flatpak-Linux\]$DOT_NAME/uninstall.sh
  96. #!/bin/bash
  97. # You can as well use package manager to uninstall the game
  98. echo You can as well use package manager to uninstall the game
  99.  
  100. set -ex
  101. flatpak --user uninstall org.flatpaklinux.$NAME
  102. EOF
  103.  
  104. cat << EOF >target/\[Flatpak-Linux\]$DOT_NAME/run.sh
  105. #!/bin/bash
  106. set -ex
  107. flatpak run org.flatpaklinux.$NAME \$@
  108. EOF
  109.  
  110. cat << EOF >target/package/export/share/applications/org.flatpaklinux.$NAME.desktop
  111. [Desktop Entry]
  112. Version=1.0
  113. Name=$NICE_NAME
  114. Exec=run.sh
  115. Icon=org.flatpaklinux.$NAME
  116. StartupNotify=true
  117. Terminal=false
  118. Type=Application
  119. Categories=Game;
  120. EOF
  121.  
  122.  
  123. set -ex
  124. [ -e "$APP"/icon.png ] && cp "$APP"/icon.png target/package/export/share/icons/hicolor/org.flatpaklinux.$NAME.png
  125. cp -rd "$APP" target/package/files/
  126. cp -rd $WINE/bin $WINE/$LIB $WINE/share target/package/files/
  127. cp -d $SRCLIB/libpng12.so* target/package/files/lib
  128. cp -d $SRCLIB/libudev.so* target/package/files/lib
  129. find target/package/files/$LIB -iname "*libz*" -print -delete
  130. [ ! -z $LDLINUX ] && cp $LDLINUX target/package/files/$LIB
  131.  
  132. chmod +x target/package/files/bin/run.sh
  133. chmod +x target/\[Flatpak-Linux\]$DOT_NAME/install.sh
  134. chmod +x target/\[Flatpak-Linux\]$DOT_NAME/uninstall.sh
  135. chmod +x target/\[Flatpak-Linux\]$DOT_NAME/run.sh
  136. cp "$0" target/package/files/flatpak-make
  137.  
  138.  
  139. flatpak build-export target/repo target/package
  140. flatpak build-bundle --arch=$ARCH target/repo target/\[Flatpak-Linux\]$DOT_NAME/$NAME.flatpak org.flatpaklinux.$NAME
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement