From 41b64be11032cf1457ca32226526f39fdf4dbfaa Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Mon, 26 Dec 2016 00:30:55 +0800 Subject: [PATCH] OK to build ttyd on MSYS2 (#30) --- README.md | 10 ++++++++++ html/README.md | 2 +- msys2/README.md | 7 +++++++ msys2/json-c/PKGBUILD | 27 ++++++++++++++++++++++++++ msys2/libwebsockets/PKGBUILD | 37 ++++++++++++++++++++++++++++++++++++ msys2/ttyd/PKGBUILD | 34 +++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 msys2/README.md create mode 100644 msys2/json-c/PKGBUILD create mode 100644 msys2/libwebsockets/PKGBUILD create mode 100644 msys2/ttyd/PKGBUILD diff --git a/README.md b/README.md index 2af0df9..d0c79cf 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,13 @@ make && make install > **NOTE:** You may need to compile libwebsockets from source for ubuntu versions old than 16.04, since they have outdated `libwebsockets-dev` package ([Issue #6][9]). +## Install on Windows + +ttyd can be built with [MSYS2][10] on windows, [follow the instructions here](msys2). + +> **NOTE:** Native windows console programs may not work correctly due to [pty incompatibility issues][11]. + As a workaround, you can use [winpty][12] as a wrapper to invoke the windows program, eg: `ttyd winpty cmd`. + ## Install on OpenWrt/LEDE ```bash @@ -147,3 +154,6 @@ Docker containers are jailed environments which are more secure, this is useful [7]: http://brew.sh [8]: https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm [9]: https://github.com/tsl0922/ttyd/issues/6 + [10]: http://msys2.github.io + [11]: https://github.com/mintty/mintty/blob/master/wiki/Tips.md#inputoutput-interaction-with-alien-programs + [12]: https://github.com/rprichard/winpty diff --git a/html/README.md b/html/README.md index 7791a0b..681e3d6 100644 --- a/html/README.md +++ b/html/README.md @@ -1,4 +1,4 @@ -### Build the inlined html +# Building the inlined html install [Yarn](https://yarnpkg.com), then run the following commands: diff --git a/msys2/README.md b/msys2/README.md new file mode 100644 index 0000000..17ec3a5 --- /dev/null +++ b/msys2/README.md @@ -0,0 +1,7 @@ +# Building ttyd with [MSYS2][1] + +1. Download and install the **latest** version of [MSYS2][1], make sure you've updated the package database. +2. Build json-c and libwebsockets: cd to package dir and run `makepkg -s && pacman -U *.pkg.tar.xz`. +3. Build ttyd: cd to ttyd dir and run `makepkg --skipchecksums`. + + [1]: http://msys2.github.io \ No newline at end of file diff --git a/msys2/json-c/PKGBUILD b/msys2/json-c/PKGBUILD new file mode 100644 index 0000000..13b847f --- /dev/null +++ b/msys2/json-c/PKGBUILD @@ -0,0 +1,27 @@ +# Maintainer: Shuanglei Tao + +pkgname=json-c +pkgver=0.12.1 +pkgrel=1 +pkgdesc="A JSON implementation in C" +arch=('any') +url="https://github.com/json-c/json-c" +license=('MIT') +makedepends=('gcc' 'make' 'autoconf') +source=("https://s3.amazonaws.com/json-c_releases/releases/${pkgname}-${pkgver}.tar.gz") +sha256sums=('2a136451a7932d80b7d197b10441e26e39428d67b1443ec43bbba824705e1123') + +build() { + cd ${srcdir}/${pkgname}-${pkgver} + ./configure \ + --prefix=/usr \ + --enable-shared \ + --enable-static + make +} + +package() { + options=('staticlibs') + cd ${srcdir}/${pkgname}-${pkgver} + make DESTDIR="$pkgdir" install +} \ No newline at end of file diff --git a/msys2/libwebsockets/PKGBUILD b/msys2/libwebsockets/PKGBUILD new file mode 100644 index 0000000..c3d5f99 --- /dev/null +++ b/msys2/libwebsockets/PKGBUILD @@ -0,0 +1,37 @@ +# Maintainer: Shuanglei Tao + +pkgname="libwebsockets" +pkgver=2.1.0 +pkgrel=1 +pkgdesc="A lightweight pure C library for websockets (msys)" +arch=('any') +url="http://libwebsockets.org" +license=('LGPL 2.1') +makedepends=('gcc' 'cmake' 'zlib-devel' 'openssl-devel') +source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/warmcat/${pkgname}/archive/v${pkgver}.tar.gz") +sha256sums=('bcc96aaa609daae4d3f7ab1ee480126709ef4f6a8bf9c85de40aae48e38cce66') + +prepare() { + cd "${srcdir}/${pkgname}-${pkgver}" +} + +build() { + mkdir -p "${srcdir}/build-${CARCH}" + cd "${srcdir}/build-${CARCH}" + + cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DLWS_USE_BUNDLED_ZLIB=OFF \ + -DLWS_WITHOUT_TESTAPPS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + ../${pkgname}-${pkgver} + + make +} + +package() { + depends=('zlib-devel' 'openssl-devel') + options=('staticlibs') + cd "${srcdir}/build-${CARCH}" + make DESTDIR=${pkgdir} install +} \ No newline at end of file diff --git a/msys2/ttyd/PKGBUILD b/msys2/ttyd/PKGBUILD new file mode 100644 index 0000000..143900c --- /dev/null +++ b/msys2/ttyd/PKGBUILD @@ -0,0 +1,34 @@ +# Maintainer: Shuanglei Tao + +pkgname="ttyd" +pkgver=master +pkgrel=1 +pkgdesc="A command-line tool for sharing terminal over the web" +arch=('any') +url="https://github.com/tsl0922/ttyd" +license=('MIT') +makedepends=('gcc' 'cmake' 'json-c' 'libwebsockets') +source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/tsl0922/${pkgname}/archive/${pkgver}.tar.gz") +sha256sums=('6f4f5e30d92ea1694ce528bdebb892a92aac5dda1ce13ea3b1ce7b865b971f85') + +prepare() { + cd "${srcdir}/${pkgname}-${pkgver}" +} + +build() { + mkdir -p "${srcdir}/build-${CARCH}" + cd "${srcdir}/build-${CARCH}" + + cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + ../${pkgname}-${pkgver} + + make +} + +package() { + options=('staticlibs' 'strip') + cd "${srcdir}/build-${CARCH}" + make DESTDIR=${pkgdir} install +} \ No newline at end of file -- 2.43.4