Skip to content

Commit 152de40

Browse files
authored
Merge pull request PowerShell#2082 from andschwa/appimage
Generate AppImage
2 parents 69841d5 + db93f41 commit 152de40

9 files changed

Lines changed: 713 additions & 6 deletions

File tree

.spelling

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ nuspec
7373
hashtables
7474
nunit
7575
exe
76+
AppImage
7677
init
7778
labeled
7879
toolset

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ matrix:
1616
addons:
1717
artifacts:
1818
paths:
19-
- $(ls powershell*{deb,pkg} | tr "\n" ":")
19+
- $(ls powershell*{deb,pkg,AppImage} | tr "\n" ":")
2020
- pester-tests.xml
2121

2222
install:
@@ -37,5 +37,5 @@ script:
3737
- powershell -File tools/travis.ps1
3838
# spellcheck
3939
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
40-
mdspell "**/*.md" --ignore-numbers --ignore-acronyms --report;
40+
mdspell '**/*.md' '!powershell/**/*.md' --ignore-numbers --ignore-acronyms --report;
4141
fi

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ You can download and install a PowerShell package for any of the following platf
2929
| Ubuntu 16.04 | [.deb][rl-ubuntu16] | [Instructions][in-ubuntu16] |
3030
| Ubuntu 14.04 | [.deb][rl-ubuntu14] | [Instructions][in-ubuntu14] |
3131
| CentOS 7 | [.rpm][rl-centos] | [Instructions][in-centos] |
32+
| Many Linux distributions | [.AppImage][rl-ai] | [Instructions][in-appimage] |
3233
| macOS 10.11 | [.pkg][rl-macos] | [Instructions][in-macos] |
3334
| Docker | | [Instructions][in-docker] |
3435

@@ -39,13 +40,15 @@ You can download and install a PowerShell package for any of the following platf
3940
[rl-ubuntu16]: https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.16/powershell_6.0.0-alpha.16-1ubuntu1.16.04.1_amd64.deb
4041
[rl-ubuntu14]: https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.16/powershell_6.0.0-alpha.16-1ubuntu1.14.04.1_amd64.deb
4142
[rl-centos]: https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.16/powershell-6.0.0_alpha.16-1.el7.centos.x86_64.rpm
43+
[rl-ai]: TODO: Post link when available
4244
[rl-macos]: https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.16/powershell-6.0.0-alpha.16.pkg
4345

4446
[installation]: docs/installation
4547
[in-windows]: docs/installation/windows.md#msi
4648
[in-ubuntu14]: docs/installation/linux.md#ubuntu-1404
4749
[in-ubuntu16]: docs/installation/linux.md#ubuntu-1604
4850
[in-centos]: docs/installation/linux.md#centos-7
51+
[in-appimage]: docs/installation/linux.md#linux-appimage
4952
[in-macos]: docs/installation/linux.md#macos-1011
5053
[in-docker]: docker
5154

assets/AppImageThirdPartyNotices.txt

Lines changed: 506 additions & 0 deletions
Large diffs are not rendered by default.

build.psm1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ function Start-PSPackage {
12261226
[string]$Name = "powershell",
12271227

12281228
# Ubuntu, CentOS, Fedora, OS X, and Windows packages are supported
1229-
[ValidateSet("deb", "osxpkg", "rpm", "msi", "appx", "zip")]
1229+
[ValidateSet("deb", "osxpkg", "rpm", "msi", "appx", "zip", "AppImage")]
12301230
[string[]]$Type,
12311231

12321232
# Generate windows downlevel package
@@ -1340,6 +1340,13 @@ function Start-PSPackage {
13401340
}
13411341
New-AppxPackage @Arguments
13421342
}
1343+
"AppImage" {
1344+
if ($IsUbuntu14) {
1345+
Start-NativeExecution { bash -iex "$PSScriptRoot/tools/appimage.sh" }
1346+
} else {
1347+
Write-Warning "Ignoring AppImage type for non Ubuntu Trusty platform"
1348+
}
1349+
}
13431350
default {
13441351
$Arguments = @{
13451352
Type = $_

docs/installation/linux.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package installation instructions
22
=================================
33

44
Supports [Ubuntu 14.04][u14], [Ubuntu 16.04][u16],
5-
[CentOS 7][cos], and [macOS 10.11][osx].
5+
[CentOS 7][cos], [many Linux distributions (AppImage)][lai], and [macOS 10.11][mac].
66
All packages are available on our GitHub [releases][] page.
77

88
All of these steps can be done automatically by the [`download.sh`][download] script.
@@ -19,7 +19,8 @@ Once the package is installed, run `powershell` from a terminal.
1919
[u14]: #ubuntu-1404
2020
[u16]: #ubuntu-1604
2121
[cos]: #centos-7
22-
[osx]: #os-x-1011
22+
[lai]: #linux-appimage
23+
[mac]: #macos-1011
2324
[download]: https://github.com/PowerShell/PowerShell/blob/v6.0.0-alpha.16/tools/download.sh
2425

2526
Ubuntu 14.04
@@ -105,6 +106,31 @@ sudo yum remove powershell
105106

106107
[CentOS 7]: https://www.centos.org/download/
107108

109+
Linux AppImage
110+
==============
111+
112+
> Please note that we do not have an alpha.16 AppImage,
113+
> this is preparation for the next release!
114+
115+
Using a recent Linux distribution,
116+
download the AppImage `powershell-6.0.0-alpha.16-x86_64.AppImage`
117+
from the [releases][] page onto the Linux machine.
118+
119+
Then execute the following in the terminal:
120+
121+
```
122+
chmod a+x powershell-6.0.0-alpha.16-x86_64.AppImage
123+
./powershell-6.0.0-alpha.16-x86_64.AppImage
124+
```
125+
126+
The [AppImage][] lets you run PowerShell without installing it.
127+
It is a portable application that bundles PowerShell and its dependencies
128+
(including .NET Core's system dependencies) into one cohesive package.
129+
This package works independently of the user's Linux distribution,
130+
and is a single binary.
131+
132+
[appimage]: http://appimage.org/
133+
108134
macOS 10.11
109135
===========
110136

license_thirdparty_proprietary.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,4 +720,25 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
720720
prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois
721721
de votre pays si celles-ci ne le permettent pas.
722722

723-
723+
The following components are governed by the MIT license, a copy of which appears
724+
below the list of components:
725+
------------------------------------------------------
726+
tools/appimage.sh
727+
------------------------------------------------------
728+
Copyright (c) 2016 Simon Peter
729+
All rights reserved.
730+
MIT License
731+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
732+
software and associated documentation files (the "Software"), to deal in the Software
733+
without restriction, including without limitation the rights to use, copy, modify,
734+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
735+
permit persons to whom the Software is furnished to do so, subject to the following
736+
conditions:
737+
The above copyright notice and this permission notice shall be included in all copies
738+
or substantial portions of the Software.
739+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
740+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
741+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
742+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
743+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
744+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

tools/appimage.sh

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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+
cp ../../assets/AppImageThirdPartyNotices.txt ThirdPartyNotices.txt
107+
108+
cat > ./AppRun <<\EOF
109+
#!/bin/sh
110+
HERE=$(dirname $(readlink -f "${0}"))
111+
export PATH="${HERE}/usr/bin/":$PATH
112+
export LD_LIBRARY_PATH="${HERE}/usr/lib/":$LD_LIBRARY_PATH
113+
exec "${HERE}/usr/bin/powershell.wrapper" "$@"
114+
EOF
115+
chmod a+x ./AppRun
116+
117+
move_lib
118+
mv ./usr/lib/x86_64-linux-gnu/* ./usr/lib/ # AppRun sets Qt env here
119+
120+
mv ./usr/lib/pulseaudio/*.so usr/lib/ || true
121+
122+
mv usr/local/share/man usr/share/ || true
123+
124+
delete_blacklisted
125+
rm -rf ./etc/ ./home/ ./lib/ || true
126+
rm -r opt/ usr/lib/x86_64-linux-gnu/ usr/lib64 usr/share/ || true
127+
128+
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')
129+
echo $VERSION
130+
131+
get_desktopintegration $APP
132+
sed -i -e 's|^echo|# echo|g' usr/bin/$APP.wrapper # Make less verbose
133+
134+
# Go out of AppImage
135+
cd ..
136+
137+
ARCH="x86_64"
138+
generate_appimage
139+
140+
cp ../out/*AppImage ..
141+
142+
cd ..

tools/travis.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Start-PSPester @pesterParam
113113
if (-not $isPr) {
114114
# Only build packages for branches, not pull requests
115115
Start-PSPackage
116+
Start-PSPackage -Type AppImage
116117
try {
117118
# this throws if there was an error
118119
Test-PSPesterResults

0 commit comments

Comments
 (0)