From a215997dcdc9d9123c6cff086b1dfb34bfea4a45 Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Tue, 10 Sep 2019 18:40:14 +0200 Subject: [PATCH 1/6] Introduce debian packaging --- .gitignore | 7 +++++++ debian/changelog | 5 +++++ debian/compat | 1 + debian/control | 18 ++++++++++++++++++ debian/copyright | 32 ++++++++++++++++++++++++++++++++ debian/install | 1 + debian/postinst | 8 ++++++++ debian/postrm | 17 +++++++++++++++++ debian/rules | 25 +++++++++++++++++++++++++ debian/source/format | 1 + docker/Dockerfile.bionic | 23 +++++++++++++++++++++++ 11 files changed, 138 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/install create mode 100644 debian/postinst create mode 100644 debian/postrm create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 docker/Dockerfile.bionic diff --git a/.gitignore b/.gitignore index 2026921b61..d8aedd6cec 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,10 @@ **/*.rs.bk history.txt tests/fixtures/nuplayground + +# Debian/Ubuntu +debian/.debhelper/ +debian/debhelper-build-stamp +debian/files +debian/nu.substvars +debian/nu/ diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000000..d6f8273939 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +nu (0.2.0-1) unstable; urgency=low + + * Initial release + + -- Jan Koprowski Wed, 04 Sep 2019 21:38:44 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000000..50c156c8da --- /dev/null +++ b/debian/control @@ -0,0 +1,18 @@ +Source: nu +Section: shells +Priority: optional +Maintainer: Jan Koprowski +Build-Depends: debhelper (>= 10) +Standards-Version: 4.1.2 +Homepage: https://github.com/nushell/nushell +Vcs-Git: https://github.com/nushell/nushell.git +Vcs-Browser: https://github.com/nushell/nushell + +Package: nu +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: A modern shell for the GitHub era + The goal of this project is to take the Unix + philosophy of shells, where pipes connect simple + commands together, and bring it to the modern + style of development. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000000..81ce9e5e34 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,32 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: nu +Source: https://github.com/nushell/nushell + +Files: * +Copyright: 2019 Yehuda Katz + 2019 Jonathan Turner +License: MIT + +Files: debian/* +Copyright: 2019 Yehuda Katz + 2019 Jonathan Turner +License: MIT + +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/debian/install b/debian/install new file mode 100644 index 0000000000..eca0e05134 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +target/release/nu usr/bin diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000000..861d76811d --- /dev/null +++ b/debian/postinst @@ -0,0 +1,8 @@ +#! /bin/bash + +if [ "$1" = configure ] && which add-shell >/dev/null +then + add-shell /usr/bin/nu +fi + +exit 0 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000000..1e4655c7be --- /dev/null +++ b/debian/postrm @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +case "$1" in + upgrade|failed-upgrade|abort-install|abort-upgrade) + ;; + remove|purge|disappear) + if which remove-shell >/dev/null && [ -f /etc/shells ]; then + remove-shell /usr/bin/nu + fi + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000000..e1c367c123 --- /dev/null +++ b/debian/rules @@ -0,0 +1,25 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + + +%: + dh $@ + + +# dh_make generated override targets +# This is example for Cmake (See https://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000000..163aaf8d82 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/docker/Dockerfile.bionic b/docker/Dockerfile.bionic new file mode 100644 index 0000000000..5d5bafc48c --- /dev/null +++ b/docker/Dockerfile.bionic @@ -0,0 +1,23 @@ +FROM ubuntu:18.04 + +# docker build -f docker/Dockerfile.bionic . + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y libssl-dev \ + libxcb-composite0-dev \ + libx11-dev \ + pkg-config \ + curl \ + devscripts \ + debhelper + +WORKDIR /code +COPY ./rust-toolchain ./rust-toolchain +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain `cat rust-toolchain` +ENV PATH=/root/.cargo/bin:$PATH +COPY . /code +RUN rustc -Vv && cargo build --release +RUN debuild -b -us -uc -i +RUN dpkg -i ../nu_0.2.0-1_amd64.deb +RUN chsh -s /usr/bin/nu +RUN echo 'ls | get name | echo $it' | /usr/bin/nu From 4ad249694fb3cb5d7744b4244227411f31494eea Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Mon, 16 Sep 2019 19:55:53 +0200 Subject: [PATCH 2/6] Base on quay.io/nushell/nu-base:latest image --- docker/packaging/Dockerfile.ubuntu-bionic | 17 +++++++++++++++++ docker/packaging/README.md | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 docker/packaging/Dockerfile.ubuntu-bionic create mode 100644 docker/packaging/README.md diff --git a/docker/packaging/Dockerfile.ubuntu-bionic b/docker/packaging/Dockerfile.ubuntu-bionic new file mode 100644 index 0000000000..144f7b421e --- /dev/null +++ b/docker/packaging/Dockerfile.ubuntu-bionic @@ -0,0 +1,17 @@ +# docker build -f docker/packaging/Dockerfile.ubuntu-bionic . + +ARG FROMTAG=latest +FROM quay.io/nushell/nu-base:${FROMTAG} + +RUN apt-get update && apt-get install -y \ + devscripts \ + debhelper + +COPY debian /code/debian + +RUN rustc -Vv && cargo build --release && \ + cp README.md debian/README.Debian && \ + debuild -b -us -uc -i && \ + dpkg -i ../nu_0.2.0-1_amd64.deb && \ + chsh -s /usr/bin/nu && \ + echo 'ls | get name | echo $it' | /usr/bin/nu \ No newline at end of file diff --git a/docker/packaging/README.md b/docker/packaging/README.md new file mode 100644 index 0000000000..8ca442bda3 --- /dev/null +++ b/docker/packaging/README.md @@ -0,0 +1,21 @@ +# Packaging + +This directory contains docker images used for creating packages for different distribution. + +## How to use this docker files? + +Start with: + +`docker build -f docker/packaging/Dockerfile.ubuntu-bionic .` + +after building the image please copy dpkg package from inside: + +`docker cp $(docker ps -q -a | head -n1):/nu_0.2.0-1_amd64.deb .` + +## What should be done + +* We should run sbuild command to create chroot and then install dpkg. +For two reasons. First: we want to use the same tools as Ubuntu package builders +to handle the cornercases. Second: we want to test dpkg requirements. +* File debian/changelog file should be generated based on git history. +* Building package and nu version should be parametrized. \ No newline at end of file From c9310265feaa6a71d3e65cb4f5df129056bf967e Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Wed, 18 Sep 2019 17:04:31 +0200 Subject: [PATCH 3/6] Remove Dockerfile.bionic from docker directory --- docker/Dockerfile.bionic | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 docker/Dockerfile.bionic diff --git a/docker/Dockerfile.bionic b/docker/Dockerfile.bionic deleted file mode 100644 index 5d5bafc48c..0000000000 --- a/docker/Dockerfile.bionic +++ /dev/null @@ -1,23 +0,0 @@ -FROM ubuntu:18.04 - -# docker build -f docker/Dockerfile.bionic . - -ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get install -y libssl-dev \ - libxcb-composite0-dev \ - libx11-dev \ - pkg-config \ - curl \ - devscripts \ - debhelper - -WORKDIR /code -COPY ./rust-toolchain ./rust-toolchain -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain `cat rust-toolchain` -ENV PATH=/root/.cargo/bin:$PATH -COPY . /code -RUN rustc -Vv && cargo build --release -RUN debuild -b -us -uc -i -RUN dpkg -i ../nu_0.2.0-1_amd64.deb -RUN chsh -s /usr/bin/nu -RUN echo 'ls | get name | echo $it' | /usr/bin/nu From a8e2801e0b8c30ddbff3408ae848bdb2001cdc0f Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Wed, 18 Sep 2019 17:43:06 +0200 Subject: [PATCH 4/6] Enhance docker/packaging/README.md about issue links --- docker/packaging/README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docker/packaging/README.md b/docker/packaging/README.md index 8ca442bda3..f3703fe2bf 100644 --- a/docker/packaging/README.md +++ b/docker/packaging/README.md @@ -8,14 +8,23 @@ Start with: `docker build -f docker/packaging/Dockerfile.ubuntu-bionic .` -after building the image please copy dpkg package from inside: +after building the image please run container -`docker cp $(docker ps -q -a | head -n1):/nu_0.2.0-1_amd64.deb .` +`docker run -d --name nushell $(docker images -q -a | head -n+1)` + +and copy deb package from inside: + +`docker cp nushell:/nu_0.2.0-1_amd64.deb .` ## What should be done * We should run sbuild command to create chroot and then install dpkg. For two reasons. First: we want to use the same tools as Ubuntu package builders to handle the cornercases. Second: we want to test dpkg requirements. +https://github.com/nushell/nushell/issues/681 + * File debian/changelog file should be generated based on git history. -* Building package and nu version should be parametrized. \ No newline at end of file +https://github.com/nushell/nushell/issues/682 + +* Building package and nu version should be parametrized. +https://github.com/nushell/nushell/issues/683 \ No newline at end of file From 85a5ed70b1fef32d1ed7b39df45cba55c6a66fa5 Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Thu, 19 Sep 2019 08:16:39 +0200 Subject: [PATCH 5/6] Replace command with --- docker/packaging/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/packaging/README.md b/docker/packaging/README.md index f3703fe2bf..ecefa0150d 100644 --- a/docker/packaging/README.md +++ b/docker/packaging/README.md @@ -10,7 +10,7 @@ Start with: after building the image please run container -`docker run -d --name nushell $(docker images -q -a | head -n+1)` +`docker run -d --name nushell ` and copy deb package from inside: From a96836facb8282e562aad8a380478776cfe22c8f Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Thu, 19 Sep 2019 17:57:36 +0200 Subject: [PATCH 6/6] Use tags instead container id and add all binaries to debian/install --- debian/install | 9 +++++++++ docker/packaging/README.md | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/debian/install b/debian/install index eca0e05134..75cf2844d9 100644 --- a/debian/install +++ b/debian/install @@ -1 +1,10 @@ target/release/nu usr/bin +target/release/nu_plugin_binaryview usr/bin +target/release/nu_plugin_edit usr/bin +target/release/nu_plugin_inc usr/bin +target/release/nu_plugin_skip usr/bin +target/release/nu_plugin_str usr/bin +target/release/nu_plugin_sum usr/bin +target/release/nu_plugin_sys usr/bin +target/release/nu_plugin_textview usr/bin +target/release/nu_plugin_tree usr/bin diff --git a/docker/packaging/README.md b/docker/packaging/README.md index ecefa0150d..e825c2780f 100644 --- a/docker/packaging/README.md +++ b/docker/packaging/README.md @@ -6,15 +6,40 @@ This directory contains docker images used for creating packages for different d Start with: -`docker build -f docker/packaging/Dockerfile.ubuntu-bionic .` +```bash +$ docker build -f docker/packaging/Dockerfile.ubuntu-bionic -t nushell/package:ubuntu-bionic . +``` -after building the image please run container +after building the image please run container: + +```bash +$ docker run -td --rm --name nushell_package_ubuntu_bionic nushell/package:ubuntu-bionic +``` -`docker run -d --name nushell ` - and copy deb package from inside: -`docker cp nushell:/nu_0.2.0-1_amd64.deb .` +```bash +$ docker cp nushell_package_ubuntu_bionic:/nu_0.2.0-1_amd64.deb . +``` + +or shell inside, and test install: + +```bash +$ docker exec -it nushell_package_ubuntu_bionic bash +$ dpkg -i /nu_0.2.0-1_amd64.deb + +(Reading database ... 25656 files and directories currently installed.) +Preparing to unpack /nu_0.2.0-1_amd64.deb ... +Unpacking nu (0.2.0-1) over (0.2.0-1) ... +Setting up nu (0.2.0-1) ... +``` + +When you are finished, exit and stop the container. It will be removed since we +used `--rm`. + +```bash +$ docker stop nushell_package_ubuntu_bionic +``` ## What should be done