Skip to content

Commit

Permalink
restructure Makefile and installation method
Browse files Browse the repository at this point in the history
This flattens the project structure and moves the completions, functions
and init script to their own directories under the project root level.

The installation will now use the new available vendor directories
provided by fish. This makes it so that users don't have to add this to
their bootstrap scripts manually etc.
  • Loading branch information
terlar committed Apr 15, 2016
1 parent d63ed4c commit c881b4e
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 33 deletions.
62 changes: 46 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,91 @@ VERSION=0.1.5
AUTHOR=terlar
URL=https://github.com/$(AUTHOR)/$(NAME)

DIRS=etc lib bin sbin share
INSTALL_DIRS=`find $(DIRS) -type d 2>/dev/null`
INSTALL_FILES=`find $(DIRS) -type f 2>/dev/null`
DOC_FILES=*.md

# Packaging
PKG_DIR=pkg
PKG_NAME=$(NAME)-$(VERSION)
PKG=$(PKG_DIR)/$(PKG_NAME).tar.gz
SIG=$(PKG_DIR)/$(PKG_NAME).asc

PREFIX?=/usr/local
DOC_DIR=$(PREFIX)/share/doc/$(PKG_NAME)
# Installation directories
PREFIX ?= /usr
DESTDIR ?=
FISHDIR ?= $(DESTDIR)$(PREFIX)/share/fish

COMPLETIONS_DIR_FILES := $(wildcard completions/*.fish)
FUNCTIONS_DIR_FILES := $(wildcard functions/*.fish)

pkg:
mkdir $(PKG_DIR)

download: pkg
wget -O $(PKG) $(URL)/archive/v$(VERSION).tar.gz
wget -O $(PKG) $(URL)/archive/$(VERSION).tar.gz

.PHONY: build
build: pkg
git archive --output=$(PKG) --prefix=$(PKG_NAME)/ HEAD

.PHONY: sign
sign: $(PKG)
gpg --sign --detach-sign --armor $(PKG)
git add $(PKG).asc
git commit $(PKG).asc -m "Added PGP signature for v$(VERSION)"
git push

.PHONY: verify
verify: $(PKG) $(SIG)
gpg --verify $(SIG) $(PKG)

.PHONY: clean
clean:
rm -f $(PKG) $(SIG)

.PHONY: all
all: $(PKG) $(SIG)

.PHONY: test
test:
fish test/runner.fish

.PHONY: tag
tag:
git push
git tag -s -m "Tagging $(VERSION)" v$(VERSION)
git push --tags

.PHONY: release
release: tag download sign

.PHONY: install
install:
for dir in $(INSTALL_DIRS); do mkdir -p $(PREFIX)/$$dir; done
for file in $(INSTALL_FILES); do cp $$file $(PREFIX)/$$file; done
mkdir -p $(DOC_DIR)
cp -r $(DOC_FILES) $(DOC_DIR)/

install -D -m644 $(CURDIR)/conf.d/fry.fish $(FISHDIR)/vendor_conf.d/
for i in $(COMPLETIONS_DIR_FILES:%='%'); do \
install -D -m644 $$i $(FISHDIR)/vendor_completions.d/; \
true; \
done;
for i in $(FUNCTIONS_DIR_FILES:%='%'); do \
install -D -m644 $$i $(FISHDIR)/vendor_functions.d/; \
true; \
done;

.PHONY: uninstall
uninstall:
for file in $(INSTALL_FILES); do rm -f $(PREFIX)/$$file; done
rm -rf $(DOC_DIR)
-rm -f $(FISHDIR)/vendor_conf.d/fry.fish
-if test -d $(FISHDIR)/vendor_completions.d; then \
for i in $(COMPLETIONS_DIR_FILES); do \
basename=`basename $$i`; \
if test -f $(FISHDIR)/vendor_completions.d/$$basename; then \
rm $(FISHDIR)/vendor_completions.d/$$basename; \
fi; \
done; \
fi;
-if test -d $(FISHDIR)/vendor_functions.d; then \
for i in $(FUNCTIONS_DIR_FILES); do \
basename=`basename $$i`; \
if test -f $(FISHDIR)/vendor_functions.d/$$basename; then \
rm $(FISHDIR)/vendor_functions.d/$$basename; \
fi; \
done; \
fi;

.DEFAULT_GOAL:=build
.PHONY: build download sign verify clean test tag release install uninstall all
2 changes: 1 addition & 1 deletion share/fry/completions/fry.fish → completions/fry.fish
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function __fish_fry_using_command
end

function __fish_fry
fry help | grep ' ' | sed 's|^ *||;s|[<[].*[]>] ||' | unexpand -t2
fry help | string match ' *' | string replace -r '^\s+(\w+)\s([<\[].*[\]>]\s)*\s+(.*)' '$1\t$3'
end

complete -f -c fry -n '__fish_fry_needs_command' -a '(__fish_fry)'
Expand Down
11 changes: 0 additions & 11 deletions share/fry/fry.fish → conf.d/fry.fish
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ set -q fry_rubies ; or set -U fry_rubies $HOME/.rubies

test -d $fry_rubies; or mkdir -p $fry_rubies

# Path
set -l fry_path (dirname (status -f))

if not contains $fry_path/functions $fish_function_path
set fish_function_path $fry_path/functions $fish_function_path
end

if not contains $fry_path/completions $fish_complete_path
set fish_complete_path $fry_path/completions $fish_complete_path
end

# Installer
function __fry_installer_toggle --on-variable fry_installer
set -l installer fry-installer-$fry_installer
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion script/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ppa=ppa:fish-shell/${FISH_PPA:-nightly-master}
sudo add-apt-repository -y $ppa
sudo apt-get update
sudo apt-get -y install fish
sudo apt-get -y install fish realpath

curl -Lso fish-tank-master.tar.gz https://github.com/terlar/fish-tank/archive/master.tar.gz
tar -zxf fish-tank-master.tar.gz
Expand Down
5 changes: 4 additions & 1 deletion test/helper.fish
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ function fry_after_all -e tank_finished
end

source $fish_tank
source (dirname (status -f))/../share/fry/fry.fish

set -l fry_project_path (realpath (dirname (status -f))/..)
set fish_function_path $fry_project_path/functions $fish_function_path
source $fry_project_path/conf.d/fry.fish
6 changes: 3 additions & 3 deletions test/test_fry-use.fish
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function suite_fry-use
mkdir -p $fry_rubies/rbx-2.2.6/bin
mkdir -p $fry_rubies/rbx-2.2.6/gems/bin

fry-use rbx-2.2.6 >/dev/null
fry-use rbx-2.2.6 ^/dev/null

refute_includes $fry_rubies/ruby-2.0/bin $PATH
assert_equal $fry_rubies/rbx-2.2.6/gems/bin $PATH[1]
Expand All @@ -68,7 +68,7 @@ function suite_fry-use
stub_var fry_prepend_path 0
set fish_user_paths (stub_dir)

fry-use ruby-1.9 >/dev/null
fry-use ruby-1.9 ^/dev/null

assert_equal $fry_rubies/ruby-1.9/bin $PATH[2]
end
Expand All @@ -77,7 +77,7 @@ function suite_fry-use
stub_var fry_prepend_path 1
set fish_user_paths (stub_dir)

fry-use ruby-1.9 >/dev/null
fry-use ruby-1.9 ^/dev/null

assert_equal $fry_rubies/ruby-1.9/bin $PATH[1]
end
Expand Down

0 comments on commit c881b4e

Please sign in to comment.