From 6824e451ea72fc96cba05a7f1db1f19e7fc54b37 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy <mmstickman@gmail.com> Date: Fri, 2 Nov 2018 05:57:42 +0000 Subject: [PATCH] Fix debian packaging, and mention new PPA --- .gitignore | 1 + Makefile | 34 ++++++++++++++++++++++------------ README.md | 10 ++++++++++ build.rs | 23 ++++++++++++++--------- debian/changelog | 7 ++++--- debian/files | 3 --- debian/postinst | 10 ++++++++++ debian/postinstall | 12 ------------ debian/rules | 6 ++++++ 9 files changed, 67 insertions(+), 39 deletions(-) delete mode 100644 debian/files create mode 100644 debian/postinst delete mode 100644 debian/postinstall diff --git a/.gitignore b/.gitignore index f8e0cfed..f634dd2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ !.travis cachegrind.* perf.* +git_revision.txt target manual/book .cargo/config diff --git a/Makefile b/Makefile index 1f75662b..204e2a77 100644 --- a/Makefile +++ b/Makefile @@ -3,31 +3,32 @@ BINARY = $(prefix)/bin/ion RELEASE = debug DEBUG ?= 0 VENDORED = 0 +REDOX ?= 0 ifeq (0,$(DEBUG)) ARGS += --release RELEASE = release endif -ifeq (1,$(REDOX)) - ARGS += --target x86_64-unknown-redox -endif - ifneq ($(wildcard vendor.tar.xz),) - VENDORED = 1 ARGSV += --frozen endif +ifeq (1,$(REDOX)) + undefine ARGSV + ARGS += --target x86_64-unknown-redox +endif + .PHONY: all clean distclean install uninstall -all: extract .cargo/config +all: version extract .cargo/config cargo build $(ARGS) $(ARGSV) clean: cargo clean -distclean: - rm -rf vendor vendor.tar.xz .cargo +distclean: clean + rm -rf vendor vendor.tar.xz .cargo git_revision.txt tests: cargo test $(ARGSV) @@ -44,23 +45,31 @@ uninstall: .cargo/config: mkdir -p .cargo - if [ -f vendor.tar.xz ]; then \ + echo $(wildcard vendor.tar.xz) + if [ "$(wildcard vendor.tar.xz)" != "" ]; then \ cp vendor_config $@; \ else \ cp nonvendor_config $@; \ - fi \ + fi vendor.tar.xz: cargo vendor tar pcfJ vendor.tar.xz vendor rm -rf vendor -vendor: .cargo/config vendor.tar.xz +vendor: vendor.tar.xz .cargo/config extract: -ifeq (1,$(VENDORED)$(wildcard vendor)) +ifneq ($(wildcard vendor.tar.xz),) +ifneq (1,$(REDOX)) tar pxf vendor.tar.xz endif +endif + +version: +ifeq ($(wildcard git_revision.txt),) + git rev-parse master > git_revision.txt +endif update-shells: if ! grep ion /etc/shells >/dev/null; then \ @@ -71,3 +80,4 @@ update-shells: sed -i -e "s#$$shell#$(BINARY)#g" /etc/shells; \ fi \ fi + diff --git a/README.md b/README.md index 1fac83b7..997e0f16 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,16 @@ The manual is located [here](https://doc.redox-os.org/ion-manual/) on Redox OS's also included in the source code for Ion, within the **manual** directory, which you may build with **mdbook**. +# Packages + +## Pop!\_OS / Ubuntu + +The following PPA supports the 18.04 (bionic) and 18.10 (cosmic) releases. Bionic builds were made using the Pop\_OS PPA's rustc 1.28.0 package. + +``` +sudo add-apt-repository ppa:mmstick76/ion-shell +``` + # Build dependencies Those who are developing software with Rust should install the [Rustup toolchain manager](https://rustup.rs/). diff --git a/build.rs b/build.rs index 34086f58..bca47492 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,7 @@ use std::{ env, - fs::File, + fs::{self, File}, io::{self, Read, Write}, path::Path, process::Command, @@ -34,14 +34,19 @@ fn write_version_file() -> io::Result<()> { } fn get_git_rev() -> io::Result<String> { - let rev = match Command::new("git").arg("rev-parse").arg("master").output() { - Ok(out) => match String::from_utf8(out.stdout) { - Ok(s) => s, - Err(_) => git_rev_from_file()?, - }, - Err(_) => git_rev_from_file()?, - }; - Ok(rev) + let version_file = Path::new("git_revision.txt"); + if version_file.exists() { + fs::read_to_string(&version_file) + } else { + Command::new("git").arg("rev-parse").arg("master").output() + .and_then(|out| { + String::from_utf8(out.stdout).map_err(|_| io::Error::new( + io::ErrorKind::InvalidData, + format!("git rev-parse master output was not UTF-8") + )) + }) + .or_else(|_| git_rev_from_file()) + } } fn git_rev_from_file() -> io::Result<String> { diff --git a/debian/changelog b/debian/changelog index cb471a7f..65f8a017 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ -ion-shell (1.0.0~alpha0) cosmic; urgency=medium +ion-shell (1.0.0-alpha0-cosmic2) cosmic; urgency=medium - * Initial release + * Add postinst script for setting the shell. + + -- Michael Aaron Murphy <michael@system76.com> Thu, 01 Nov 2018 16:44:15 -0600 - -- Michael Aaron Murphy <michael@system76.com> Sat, 20 Oct 2018 12:12:12 -0600 diff --git a/debian/files b/debian/files deleted file mode 100644 index 4a261d6f..00000000 --- a/debian/files +++ /dev/null @@ -1,3 +0,0 @@ -ion-shell-dbgsym_1.0.0~alpha0_amd64.ddeb debug optional -ion-shell_1.0.0~alpha0_amd64.buildinfo admin optional -ion-shell_1.0.0~alpha0_amd64.deb admin optional diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 00000000..a3f34d60 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,10 @@ +#!/bin/sh +BINARY="/usr/bin/ion" +if ! grep ion /etc/shells >/dev/null; then + echo ${BINARY} >> /etc/shells +else + shell=$(grep ion /etc/shells) + if [ "$shell" != "${BINARY}" ]; then + sed -i -e "s#$shell#${BINARY}#g" /etc/shells + fi +fi diff --git a/debian/postinstall b/debian/postinstall deleted file mode 100644 index e2e6f7d2..00000000 --- a/debian/postinstall +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -if ! grep ion /etc/shells >/dev/null; then - echo $(BINARY) >> /etc/shells; -else - shell=$(shell grep ion /etc/shells); - if [ $$shell != $(BINARY) ]; then - before=$$(echo $$shell | sed 's/\//\\\//g'); - after=$$(echo $(BINARY) | sed 's/\//\\\//g'); - sed -i -e "s/$$before/$$after/g" /etc/shells; - fi -fi - diff --git a/debian/rules b/debian/rules index fd1330ac..3e19f9f1 100755 --- a/debian/rules +++ b/debian/rules @@ -4,8 +4,14 @@ dh $@ override_dh_auto_clean: + cat git_revision.txt || echo git_revision.txt not found make clean make vendor + make version + +override_dh_auto_build: + cat .cargo/config + make all override_dh_auto_install: dh_auto_install -- prefix=/usr -- GitLab