Skip to content

Commit

Permalink
working .deb package generation
Browse files Browse the repository at this point in the history
  • Loading branch information
benzap committed Jun 14, 2018
1 parent c87ea63 commit 3f8ab43
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 36 deletions.
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Main makefile for building distributable packages of fif executable

FIF_EXISTS := $(shell which fif >/dev/null && echo "True" || echo "False")

# Use fif to retrieve the project version, since it's faster
ifeq ($(FIF_EXISTS), True)
FIF_VERSION := $(shell fif -e \"project.clj\" read-file first 2 nth println)
else
FIF_VERSION := $(shell lein project-version)
endif

FIF_EXE_NAME := fif-$(FIF_VERSION)

PROJ_FIF_EXE := bin/$(FIF_EXE_NAME)

# default
all: clean build-native


# Generate `fif` native executable
build-native: $(PROJ_FIF_EXE)


$(PROJ_FIF_EXE):
./build-native.sh


# Generate .deb Package for native executable
dpkg: $(PROJ_FIF_EXE)
make -C dist_config/dpkg/ dpkg


install: $(PROJ_FIF_EXE)
cp $(PROJ_FIF_EXE) /usr/bin/$(FIF_EXE_NAME)
rm -f /usr/bin/fif
ln -s /usr/bin/$(FIF_EXE_NAME) fif


clean:
rm -f $(PROJ_FIF_EXE)


distclean:
rm -f /usr/bin/$(FIF_EXE_NAME)
rm -f /usr/bin/fif
3 changes: 2 additions & 1 deletion build-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ echo "Post Configuration..."
mkdir -p bin
chmod 744 fif
mv fif-$FIF_VERSION ./bin/
rm ./bin/fif
ln -s ./bin/fif-$FIF_VERSION ./bin/fif
echo ""

echo "Built executable can be found at ./bin/fif"
echo "Built executable can be found at ./bin/fif-${FIF_VERSION}"
56 changes: 34 additions & 22 deletions dist_config/dpkg/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Makefile for generating dpkgs for the native-image compiled 'fif' executable
# Requires: leiningen
# Optional: fif

EMAIL := [email protected]

Expand All @@ -21,47 +23,57 @@ endif

FIF_EXE_NAME := fif-$(FIF_VERSION)

DMAKE_DIR := $(DIST_DIR)/dpkg/$(ARCH)/$(FIF_EXE_NAME)

DEB_NAME := $(FIF_EXE_NAME)-$(ARCH)
DEB_VERSION := 1

DMAKE_DIR := $(DIST_DIR)/dpkg/$(DEB_NAME)
PROJ_FIF_EXE := $(PROJECT_ROOT_DIR)/bin/$(FIF_EXE_NAME)
DPKG_FIF_EXE := $(DMAKE_DIR)/$(FIF_EXE_NAME)
DPKG_FIF_EXE := $(DMAKE_DIR)/usr/bin/$(FIF_EXE_NAME)

init:
mkdir -p $(DMAKE_DIR)
cd $(DMAKE_DIR) && dh_make --copyright custom \
--copyrightfile $(PROJECT_ROOT_DIR)/LICENSE \
--email $(EMAIL) \
--single --native --yes
rm -f $(DMAKE_DIR)/debian/README
rm -f $(DMAKE_DIR)/debian/*.ex
cp dbuild.mk.template $(DMAKE_DIR)/Makefile
sed -i "s/FIF_NAME_EXE/$(FIF_EXE_NAME)/g" $(DMAKE_DIR)/Makefile

sed -i "s/Section:.*/Section: interpreters/" $(DMAKE_DIR)/debian/control
sed -i "s/Homepage:.*/Homepage: http:\/\/github.com\/benzap\/fif/" $(DMAKE_DIR)/debian/control
sed -i "s/Architecture:.*/Architecture: any-$(ARCH)/" $(DMAKE_DIR)/debian/control
sed -i "s/Description:.*/Description: Interpreter and Repl for the fif language/" \
$(DMAKE_DIR)/debian/control
sed -i "s/ <insert long description.*//g" $(DMAKE_DIR)/debian/control

mkdir -p $(DMAKE_DIR)/DEBIAN
touch $(DMAKE_DIR)/DEBIAN/control
echo "Package: fif" >> $(DMAKE_DIR)/DEBIAN/control
echo "Version: $(FIF_VERSION)-$(DEB_VERSION)" >> $(DMAKE_DIR)/DEBIAN/control
echo "Section: interpreters" >> $(DMAKE_DIR)/DEBIAN/control
echo "Priority: optional" >> $(DMAKE_DIR)/DEBIAN/control
echo "Homepage: http://github.com/benzap/fif" >> $(DMAKE_DIR)/DEBIAN/control
echo "Architecture: $(ARCH)" >> $(DMAKE_DIR)/DEBIAN/control
echo "Maintainer: Benjamin Zaporzan <[email protected]>" >> $(DMAKE_DIR)/DEBIAN/control
echo "Description: Interpreter and Repl for the fif language" >> $(DMAKE_DIR)/DEBIAN/control

cp prerm.template $(DMAKE_DIR)/DEBIAN/prerm
chmod 775 $(DMAKE_DIR)/DEBIAN/prerm
sed -i "s/FIF_EXE_NAME/$(FIF_EXE_NAME)/g" $(DMAKE_DIR)/DEBIAN/prerm

cp postinst.template $(DMAKE_DIR)/DEBIAN/postinst
chmod 775 $(DMAKE_DIR)/DEBIAN/postinst
sed -i "s/FIF_EXE_NAME/$(FIF_EXE_NAME)/g" $(DMAKE_DIR)/DEBIAN/postinst

cp $(PROJECT_ROOT_DIR)/LICENSE $(DMAKE_DIR)/DEBIAN/license

$(PROJ_FIF_EXE):
echo "Building Native Image..."
cd $(PROJECT_ROOT_DIR) && ./build-native.sh


$(DPKG_FIF_EXE): $(PROJ_FIF_EXE)
mkdir -p $(DMAKE_DIR)/usr/bin
cp $(PROJ_FIF_EXE) $(DPKG_FIF_EXE)
chmod 755 $(DPKG_FIF_EXE)


prepare: $(DPKG_FIF_EXE)
find $(DMAKE_DIR) -type d | xargs chmod 755




build:
dpkg-deb --build $(DMAKE_DIR)

clean:
rm -rf $(DMAKE_DIR)


dpkg: clean init prepare
dpkg: clean init prepare build

13 changes: 0 additions & 13 deletions dist_config/dpkg/dbuild.mk.template

This file was deleted.

5 changes: 5 additions & 0 deletions dist_config/dpkg/postinst.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -e
chmod 755 /usr/bin/FIF_EXE_NAME
rm -f /usr/bin/fif
ln -s /usr/bin/FIF_EXE_NAME /usr/bin/fif
5 changes: 5 additions & 0 deletions dist_config/dpkg/prerm.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -e
rm -f /usr/bin/FIF_EXE_NAME
rm -f /usr/bin/fif

0 comments on commit 3f8ab43

Please sign in to comment.