From 032574038932ce572775916d92628cd43160757d Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Mon, 2 Nov 2015 20:49:06 -0200 Subject: [PATCH 1/5] =?UTF-8?q?Moved=20update.sh=20to=20bin=20folder=20as?= =?UTF-8?q?=20=E2=80=9Capt-select-update=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update.sh => bin/apt-select-update | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename update.sh => bin/apt-select-update (100%) diff --git a/update.sh b/bin/apt-select-update similarity index 100% rename from update.sh rename to bin/apt-select-update From f922607be97633e4f7cae40f1078f1ac5fe905d1 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Mon, 2 Nov 2015 20:49:39 -0200 Subject: [PATCH 2/5] added apt-select executable to bin folder --- bin/apt-select | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 bin/apt-select diff --git a/bin/apt-select b/bin/apt-select new file mode 100755 index 0000000..61ffcbb --- /dev/null +++ b/bin/apt-select @@ -0,0 +1,6 @@ +#!/bin/bash + +current_path=$(dirname $([ -L $0 ] && readlink -f $0 || echo $0)) +workdir=${current_path}/.. + +exec ${workdir}/apt-select.py $@ From 68b76e1b1a566a67322b6460e2841ea7602e702d Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Mon, 2 Nov 2015 20:50:05 -0200 Subject: [PATCH 3/5] Added FPM-Cookery recipe --- .gitignore | 3 +++ deb-package.rb | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 deb-package.rb diff --git a/.gitignore b/.gitignore index bb4d8dc..c234179 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ __pycache__ *.pyc *test* sources.list +pkg +tmp-build +tmp-dest diff --git a/deb-package.rb b/deb-package.rb new file mode 100644 index 0000000..bf76765 --- /dev/null +++ b/deb-package.rb @@ -0,0 +1,68 @@ +class AptSelect < FPM::Cookery::Recipe + name 'apt-select' + version '0.1.0' + revision 0 + homepage 'https://github.com/jblakeman/apt-select' + license 'MIT' + description 'Choose a fast, up to date Ubuntu apt mirror' + maintainer 'Gabriel Mazetto ' + source './', :with => :local_path + + platforms [:ubuntu] do + depends 'python-bs4' + end + + def build + end + + def install + share('apt-select').mkdir + share('apt-select/bin').mkdir + Dir["#{workdir}/*"].each { |f| share('apt-select').install f if allowed_file?(f) } + Dir["#{workdir}/bin/*"].each { |f| share('apt-select/bin').install f } + + with_trueprefix do + create_post_install_hook <<-EOF + set -e + BIN_PATH="#{share('apt-select/bin')}" + + update-alternatives --install /usr/bin/apt-select apt-select $BIN_PATH/apt-select 100 + update-alternatives --install /usr/bin/apt-select-update apt-select-update $BIN_PATH/apt-select-update 100 + + exit 0 + EOF + create_pre_uninstall_hook <<-EOF + set -e + BIN_PATH="#{share('apt-select/bin')}" + + if [ "$1" != "upgrade" ]; then + update-alternatives --remove apt-select $BIN_PATH/apt-select + update-alternatives --remove apt-select-update $BIN_PATH/apt-select-update + fi + + exit 0 + EOF + end + end + + private + + def allowed_file?(file) + allowed_formats = %w(.py .md .sh) + allowed_formats.include? File.extname(file) + end + + def create_post_install_hook(script, interpreter = '/bin/sh') + File.open(builddir('post-install'), 'w', 0755) do |f| + f.write "#!#{interpreter}\n" + script.gsub(/^\s+/, '') + self.class.post_install(File.expand_path(f.path)) + end + end + + def create_pre_uninstall_hook(script, interpreter = '/bin/sh') + File.open(builddir('pre-uninstall'), 'w', 0755) do |f| + f.write "#!#{interpreter}\n" + script.gsub(/^\s+/, '') + self.class.pre_uninstall(File.expand_path(f.path)) + end + end +end From d356421c9206eaeccc40e8cebe2ca7c3851f06ca Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Mon, 2 Nov 2015 20:50:22 -0200 Subject: [PATCH 4/5] Added Makefile to easy install FPM dependencies and build package --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..286aced --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +all: package + +package: package-dependencies + @fpm-cook package deb-package.rb + +package-dependencies: + @if ! `gem list -i fpm-cookery`; then gem install fpm-cookery; fi From e6915a750ac594f1e46228ba708639519633446e Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Tue, 3 Nov 2015 01:33:17 -0200 Subject: [PATCH 5/5] Change architecture to be independent --- deb-package.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/deb-package.rb b/deb-package.rb index bf76765..dd60a22 100644 --- a/deb-package.rb +++ b/deb-package.rb @@ -7,6 +7,7 @@ class AptSelect < FPM::Cookery::Recipe description 'Choose a fast, up to date Ubuntu apt mirror' maintainer 'Gabriel Mazetto ' source './', :with => :local_path + arch 'all' platforms [:ubuntu] do depends 'python-bs4'