From 39d4b9c1344158e748f552a60aef7fe1770f6b3b Mon Sep 17 00:00:00 2001
From: Peter Squicciarini <stripedpajamas273@gmail.com>
Date: Fri, 19 Apr 2019 06:30:10 -0700
Subject: [PATCH] AppImage support (#108)

---
 .travis.yml                  |  1 +
 VSCodium-AppImage-Recipe.yml | 35 +++++++++++++++++++++++++++++++++++
 build.sh                     |  3 ++-
 create_appimage.sh           | 10 ++++++++++
 4 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 VSCodium-AppImage-Recipe.yml
 create mode 100755 create_appimage.sh

diff --git a/.travis.yml b/.travis.yml
index 6553766..fce3498 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -46,6 +46,7 @@ deploy:
     - vscode/.build/linux/deb/amd64/deb/*.deb
     - vscode/.build/linux/rpm/x86_64/*.rpm
     - vscode/.build/linux/deb/arm64/deb/*.deb
+    - vscode/out/*.AppImage
   on:
     all_branches: true
     condition: $SHOULD_BUILD = yes
diff --git a/VSCodium-AppImage-Recipe.yml b/VSCodium-AppImage-Recipe.yml
new file mode 100644
index 0000000..d463135
--- /dev/null
+++ b/VSCodium-AppImage-Recipe.yml
@@ -0,0 +1,35 @@
+# Based on
+# https://github.com/AppImage/pkg2appimage/blob/master/recipes/VSCode.yml
+#
+# On a Debian/Ubuntu system:
+# wget -c "https://github.com/AppImage/pkg2appimage/raw/master/pkg2appimage"
+# bash -ex pkg2appimage VSCodium
+
+app: VSCodium
+
+ingredients:
+  packages:
+    - code
+    - libgconf2-4
+  dist: trusty
+  sources: 
+    - deb http://archive.ubuntu.com/ubuntu/ trusty main universe
+  script:
+    - pwd
+    - cp ../.build/linux/deb/amd64/deb/*.deb .
+    - ls vscodium_*.deb | cut -d _ -f 2 > VERSION
+
+script:
+  - sed -i -e 's|/usr/share/vscodium/||g' usr/share/applications/vscodium.desktop
+  - sed -i -e 's|com.visualstudio.code.oss|vscodium|g' usr/share/applications/vscodium.desktop
+  - cp usr/share/applications/vscodium.desktop .
+  - cp usr/share/pixmaps/com.visualstudio.code.oss.png vscodium.png
+  - convert vscodium.png -resize 512x512 usr/share/icons/hicolor/512x512/apps/vscodium.png
+  - convert vscodium.png -resize 256x256 usr/share/icons/hicolor/256x256/apps/vscodium.png
+  - convert vscodium.png -resize 128x128 usr/share/icons/hicolor/128x128/apps/vscodium.png
+  - convert vscodium.png -resize 64x64 usr/share/icons/hicolor/64x64/apps/vscodium.png
+  - convert vscodium.png -resize 48x48 usr/share/icons/hicolor/48x48/apps/vscodium.png
+  - convert vscodium.png -resize 32x32 usr/share/icons/hicolor/32x32/apps/vscodium.png
+  - convert vscodium.png -resize 24x24 usr/share/icons/hicolor/24x24/apps/vscodium.png
+  - convert vscodium.png -resize 22x22 usr/share/icons/hicolor/22x22/apps/vscodium.png
+  - ( cd usr/bin/ ; ln -s ../share/vscodium/vscodium  . )
diff --git a/build.sh b/build.sh
index 7e0cde5..074c961 100755
--- a/build.sh
+++ b/build.sh
@@ -36,7 +36,8 @@ if [[ "$SHOULD_BUILD" == "yes" ]]; then
     npm run gulp -- "vscode-linux-${BUILDARCH}-min"
     npm run gulp -- "vscode-linux-${BUILDARCH}-build-deb"
     npm run gulp -- "vscode-linux-${BUILDARCH}-build-rpm"
-  fi  
+    . ../create_appimage.sh
+  fi
 
   cd ..
 fi
diff --git a/create_appimage.sh b/create_appimage.sh
new file mode 100755
index 0000000..5cf187f
--- /dev/null
+++ b/create_appimage.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+if [[ "$BUILDARCH" == "x64" ]]; then
+  # install a dep needed for this process
+  sudo apt-get install desktop-file-utils
+
+  # download pkg2appimage from github
+  curl -LO "https://github.com/AppImage/pkg2appimage/raw/master/pkg2appimage"
+  
+  bash -e pkg2appimage ../VSCodium-AppImage-Recipe.yml
+fi