Skip to content

Commit

Permalink
Use 'make install' for packaging
Browse files Browse the repository at this point in the history
Replace explicit 'file maps' for packaging with "make install"
invocations. This ensures that we always package the same files
that get installed when building from source.

The list of files to be packaged is still maintained separately as we
do split them into "libthemis" and "libthemis-dev" packages. Note that
the split is not entirely correct: the static libraries and symbolic
links should go into development package as well. However, for now we
keep the old split for compatibility.

We use the newly added DESTDIR capability to install into a temporary
staging directory and then collect the files from there. Now we also
no longer need to create symbolic links manually. However, stripping
binaries still has to be performed, and we still need to construct
pre- and postinstall scripts. Let's do it inline to save the trouble.
  • Loading branch information
ilammy committed Apr 10, 2019
1 parent 1971266 commit cbe1d8b
Showing 1 changed file with 26 additions and 45 deletions.
71 changes: 26 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -504,16 +504,6 @@ endif
@echo -n "pythemis install "
@$(BUILD_CMD_)

soter_collect_headers:
@mkdir -p $(BIN_PATH)/include/soter
@cd src/soter && find . -name \*.h -exec cp --parents {} ../../$(BIN_PATH)/include/soter/ \; && cd - > /dev/null

themis_collect_headers:
@mkdir -p $(BIN_PATH)/include/themis
@cd src/themis && find . -name \*.h -exec cp --parents {} ../../$(BIN_PATH)/include/themis/ \; && cd - > /dev/null

collect_headers: themis_collect_headers soter_collect_headers

unpack_dist:
@tar -xf $(THEMIS_DIST_FILENAME)

Expand Down Expand Up @@ -557,38 +547,28 @@ RPM_SUMMARY = Data security library for network communication and data storage.
PHP, Java / Android and iOS / OSX. It is designed with ease of use in mind, \
high security and cross-platform availability.

HEADER_DIRS = $(shell ls $(BIN_PATH)/include)

HEADER_FILES_MAP = $(foreach dir,$(HEADER_DIRS), $(BIN_PATH)/include/$(dir)/=$(PREFIX)/include/$(dir))

STATIC_LIBRARY_FILES = $(shell ls $(BIN_PATH)/ | egrep *\.a$$)
STATIC_BINARY_LIBRARY_MAP = $(foreach file,$(STATIC_LIBRARY_FILES),$(strip $(BIN_PATH)/$(file)=$(PREFIX)/lib/$(file)))

SHARED_LIBRARY_FILES = $(shell ls $(BIN_PATH)/ | egrep *\.$(SHARED_EXT)$$)
SHARED_BINARY_LIBRARY_MAP = $(foreach file,$(SHARED_LIBRARY_FILES),$(strip $(BIN_PATH)/$(file).$(LIBRARY_SO_VERSION)=$(PREFIX)/lib/$(file).$(LIBRARY_SO_VERSION) $(BIN_PATH)/$(file)=$(PREFIX)/lib/$(file)))

PKGCONFIG_FILES = $(shell ls $(BIN_PATH)/ | egrep *\.pc$$)
PKGCONFIG_MAP = $(foreach file,$(PKGCONFIG_FILES),$(strip $(BIN_PATH)/$(file)=$(PREFIX)/lib/pkgconfig/$(file)))

BINARY_LIBRARY_MAP = $(strip $(STATIC_BINARY_LIBRARY_MAP) $(SHARED_BINARY_LIBRARY_MAP))

POST_INSTALL_SCRIPT := $(BIN_PATH)/post_install.sh
POST_UNINSTALL_SCRIPT := $(BIN_PATH)/post_uninstall.sh

install_shell_scripts:
# run ldconfig to update ld.$(SHARED_EXT) cache
@printf "ldconfig" > $(POST_INSTALL_SCRIPT)
@cp $(POST_INSTALL_SCRIPT) $(POST_UNINSTALL_SCRIPT)
DEV_PACKAGE_FILES += $(includedir)/
DEV_PACKAGE_FILES += $(pkgconfigdir)/

strip:
@find . -name \*.$(SHARED_EXT)\.* -exec strip -o {} {} \;
LIB_PACKAGE_FILES += $(libdir)/$(LIBSOTER_A)
LIB_PACKAGE_FILES += $(libdir)/$(LIBSOTER_SO)
LIB_PACKAGE_FILES += $(libdir)/$(LIBSOTER_LINK)
LIB_PACKAGE_FILES += $(libdir)/$(LIBTHEMIS_A)
LIB_PACKAGE_FILES += $(libdir)/$(LIBTHEMIS_SO)
LIB_PACKAGE_FILES += $(libdir)/$(LIBTHEMIS_LINK)

deb: DESTDIR = $(BIN_PATH)/deb/root
deb: PREFIX = /usr

deb: soter_static themis_static soter_shared themis_shared soter_pkgconfig themis_pkgconfig collect_headers install_shell_scripts strip
@mkdir -p $(BIN_PATH)/deb
deb: install
@printf "ldconfig" > $(POST_INSTALL_SCRIPT)
@printf "ldconfig" > $(POST_UNINSTALL_SCRIPT)

@find $(DESTDIR) -name '*.$(SHARED_EXT)*' -exec strip -o {} {} \;

#libPACKAGE-dev
@fpm --input-type dir \
--output-type deb \
--name $(PACKAGE_NAME)-dev \
Expand All @@ -604,9 +584,8 @@ deb: soter_static themis_static soter_shared themis_shared soter_pkgconfig themi
--after-install $(POST_INSTALL_SCRIPT) \
--after-remove $(POST_UNINSTALL_SCRIPT) \
--category $(PACKAGE_CATEGORY) \
$(HEADER_FILES_MAP) $(PKGCONFIG_MAP)
$(foreach file,$(DEV_PACKAGE_FILES),$(DESTDIR)/$(file)=$(file))

#libPACKAGE
@fpm --input-type dir \
--output-type deb \
--name $(PACKAGE_NAME) \
Expand All @@ -622,16 +601,19 @@ deb: soter_static themis_static soter_shared themis_shared soter_pkgconfig themi
--after-remove $(POST_UNINSTALL_SCRIPT) \
--deb-priority optional \
--category $(PACKAGE_CATEGORY) \
$(BINARY_LIBRARY_MAP)
$(foreach file,$(LIB_PACKAGE_FILES),$(DESTDIR)/$(file)=$(file))

# it's just for printing .deb files
@find $(BIN_PATH) -name \*.deb

rpm: DESTDIR = $(BIN_PATH)/rpm/root
rpm: PREFIX = /usr

rpm: themis_static themis_shared themis_pkgconfig soter_static soter_shared soter_pkgconfig collect_headers install_shell_scripts strip
@mkdir -p $(BIN_PATH)/rpm
#libPACKAGE-devel
rpm: install
@printf "ldconfig" > $(POST_INSTALL_SCRIPT)
@printf "ldconfig" > $(POST_UNINSTALL_SCRIPT)

@find $(DESTDIR) -name '*.$(SHARED_EXT)*' -exec strip -o {} {} \;

@fpm --input-type dir \
--output-type rpm \
--name $(PACKAGE_NAME)-devel \
Expand All @@ -646,9 +628,8 @@ rpm: themis_static themis_shared themis_pkgconfig soter_static soter_shared sote
--package $(BIN_PATH)/rpm/$(PACKAGE_NAME)-devel-$(NAME_SUFFIX) \
--version $(RPM_VERSION) \
--category $(PACKAGE_CATEGORY) \
$(HEADER_FILES_MAP) $(PKGCONFIG_MAP)
$(foreach file,$(DEV_PACKAGE_FILES),$(DESTDIR)/$(file)=$(file))

#libPACKAGE
@fpm --input-type dir \
--output-type rpm \
--name $(PACKAGE_NAME) \
Expand All @@ -663,8 +644,8 @@ rpm: themis_static themis_shared themis_pkgconfig soter_static soter_shared sote
--package $(BIN_PATH)/rpm/$(PACKAGE_NAME)-$(NAME_SUFFIX) \
--version $(RPM_VERSION) \
--category $(PACKAGE_CATEGORY) \
$(BINARY_LIBRARY_MAP)
# it's just for printing .rpm files
$(foreach file,$(LIB_PACKAGE_FILES),$(DESTDIR)/$(file)=$(file))

@find $(BIN_PATH) -name \*.rpm

define PKGINFO
Expand Down

0 comments on commit cbe1d8b

Please sign in to comment.