|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This code is based on an example recipe from the AppImage project, |
| 4 | +# https://github.com/probonopd/AppImages/blob/e05cbebc62c86f8c602d74d9050bbfbf10df1c69/recipes/powershell/Recipe |
| 5 | +# Copyright (c) 2016 Simon Peter |
| 6 | +# The license of this code and of https://github.com/probonopd/AppImages/raw/e05cbebc62c86f8c602d74d9050bbfbf10df1c69/functions.sh |
| 7 | +# is the MIT License, see https://github.com/probonopd/AppImages/blob/e05cbebc62c86f8c602d74d9050bbfbf10df1c69/LICENSE |
| 8 | +# |
| 9 | +# Generate AppImage, http://appimage.org |
| 10 | +# |
| 11 | +# The resulting PowerShell AppImage is known to run on |
| 12 | +# CentOS-7.0-1406-x86_64-GnomeLive.iso |
| 13 | +# CentOS-7-x86_64-LiveGNOME-1511.iso |
| 14 | +# Chromixium-1.5-amd64.iso |
| 15 | +# Fedora-Live-Workstation-x86_64-22-3.iso |
| 16 | +# Fedora-Live-Workstation-x86_64-23-10.iso |
| 17 | +# SL-72-x86_64-2016-02-03-LiveDVDgnome.iso |
| 18 | +# debian-live-8.0.0-amd64-xfce-desktop+nonfree.iso |
| 19 | +# debian-live-8.4.0-amd64-gnome-desktop.iso |
| 20 | +# elementary_OS_0.3_freya_amd64.iso |
| 21 | +# kali-linux-2.0-amd64.iso |
| 22 | +# kali-linux-2016.1-amd64.iso |
| 23 | +# kubuntu-14.04.4-desktop-amd64.iso |
| 24 | +# kubuntu-15.04-desktop-amd64.iso |
| 25 | +# kubuntu-16.04-desktop-amd64.iso |
| 26 | +# linuxmint-17.3-cinnamon-64bit.iso |
| 27 | +# neon-devedition-gitunstable-20160814-0806-amd64.iso |
| 28 | +# netrunner-17-64bit.iso |
| 29 | +# ubuntu-14.04.1-desktop-amd64.iso |
| 30 | +# ubuntu-16.04-desktop-amd64.iso |
| 31 | +# ubuntu-gnome-16.04-desktop-amd64.iso |
| 32 | +# ubuntu-mate-16.04-desktop-amd64.iso |
| 33 | +# xubuntu-16.04-desktop-amd64.iso |
| 34 | + |
| 35 | +APP=powershell |
| 36 | + |
| 37 | +mkdir -p ./$APP/$APP.AppDir/usr/lib |
| 38 | + |
| 39 | +cd ./$APP/ |
| 40 | + |
| 41 | +wget -q https://github.com/probonopd/AppImages/raw/e05cbebc62c86f8c602d74d9050bbfbf10df1c69/functions.sh -O ./functions.sh |
| 42 | +. ./functions.sh |
| 43 | + |
| 44 | +# We get this app and almost all its dependencies via apt-get |
| 45 | +# but not using the host system's information about what is |
| 46 | +# installed on the system but our own assumptions instead |
| 47 | + |
| 48 | +mkdir -p ./tmp/archives/ |
| 49 | +mkdir -p ./tmp/lists/partial |
| 50 | +touch tmp/pkgcache.bin tmp/srcpkgcache.bin |
| 51 | + |
| 52 | +generate_status |
| 53 | + |
| 54 | +echo "deb http://archive.ubuntu.com/ubuntu/ trusty main universe |
| 55 | +" > sources.list |
| 56 | + |
| 57 | +OPTIONS="-o Debug::NoLocking=1 |
| 58 | +-o APT::Cache-Limit=125829120 |
| 59 | +-o Dir::Etc::sourcelist=./sources.list |
| 60 | +-o Dir::State=./tmp |
| 61 | +-o Dir::Cache=./tmp |
| 62 | +-o Dir::State::status=./status |
| 63 | +-o Dir::Etc::sourceparts=- |
| 64 | +-o APT::Get::List-Cleanup=0 |
| 65 | +-o APT::Get::AllowUnauthenticated=1 |
| 66 | +-o Debug::pkgProblemResolver=true |
| 67 | +-o Debug::pkgDepCache::AutoInstall=true |
| 68 | +-o APT::Install-Recommends=0 |
| 69 | +-o APT::Install-Suggests=0 |
| 70 | +" |
| 71 | + |
| 72 | +cp ../powershell_*_amd64.deb . |
| 73 | + |
| 74 | +# Add local repository so that we can install deb files |
| 75 | +# that were downloaded outside of a repository |
| 76 | +dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz |
| 77 | +echo "deb file:$(readlink -e $PWD) ./" >> sources.list |
| 78 | + |
| 79 | +apt-get $OPTIONS update |
| 80 | + |
| 81 | +URLS=$(apt-get $OPTIONS -y install --print-uris $APP | cut -d "'" -f 2 | grep -e "^http") |
| 82 | + |
| 83 | +wget -c $URLS |
| 84 | + |
| 85 | +cd ./$APP.AppDir/ |
| 86 | + |
| 87 | +find ../*.deb -exec dpkg -x {} . \; || true |
| 88 | + |
| 89 | +rm usr/bin/powershell |
| 90 | +mv opt/microsoft/powershell/*/* usr/bin/ |
| 91 | + |
| 92 | +cat > $APP.desktop <<\EOF |
| 93 | +[Desktop Entry] |
| 94 | +Name=PowerShell |
| 95 | +Comment=Microsoft PowerShell |
| 96 | +Exec=powershell |
| 97 | +Keywords=shell;prompt;command;commandline;cmd; |
| 98 | +Icon=powershell |
| 99 | +Type=Application |
| 100 | +Categories=System;TerminalEmulator; |
| 101 | +StartupNotify=true |
| 102 | +Terminal=true |
| 103 | +EOF |
| 104 | + |
| 105 | +cp ../../assets/Powershell_256.png $APP.png |
| 106 | + |
| 107 | +cat > ./AppRun <<\EOF |
| 108 | +#!/bin/sh |
| 109 | +HERE=$(dirname $(readlink -f "${0}")) |
| 110 | +export PATH="${HERE}/usr/bin/":$PATH |
| 111 | +export LD_LIBRARY_PATH="${HERE}/usr/lib/":$LD_LIBRARY_PATH |
| 112 | +exec "${HERE}/usr/bin/powershell.wrapper" "$@" |
| 113 | +EOF |
| 114 | +chmod a+x ./AppRun |
| 115 | + |
| 116 | +move_lib |
| 117 | +mv ./usr/lib/x86_64-linux-gnu/* ./usr/lib/ # AppRun sets Qt env here |
| 118 | + |
| 119 | +mv ./usr/lib/pulseaudio/*.so usr/lib/ || true |
| 120 | + |
| 121 | +mv usr/local/share/man usr/share/ || true |
| 122 | + |
| 123 | +delete_blacklisted |
| 124 | +rm -rf ./etc/ ./home/ ./lib/ || true |
| 125 | +rm -r opt/ usr/lib/x86_64-linux-gnu/ usr/lib64 usr/share/ || true |
| 126 | + |
| 127 | +VERSION=$(find ../*.deb -name $APP"_*" | head -n 1 | cut -d "~" -f 1 | cut -d "_" -f 2 | cut -d "-" -f 1-2 | sed -e 's|1%3a||g') |
| 128 | +echo $VERSION |
| 129 | + |
| 130 | +get_desktopintegration $APP |
| 131 | +sed -i -e 's|^echo|# echo|g' usr/bin/$APP.wrapper # Make less verbose |
| 132 | + |
| 133 | +# Go out of AppImage |
| 134 | +cd .. |
| 135 | + |
| 136 | +ARCH="x86_64" |
| 137 | +generate_appimage |
| 138 | + |
| 139 | +cp ../out/*AppImage .. |
| 140 | + |
| 141 | +cd .. |
0 commit comments