Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spksrc: Fully use DSM7 var directory #5163

Merged
merged 4 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mk/spksrc.configure.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ REAL_CONFIGURE_ARGS =
ifneq ($(strip $(GNU_CONFIGURE)),)
REAL_CONFIGURE_ARGS += $(TC_CONFIGURE_ARGS)
REAL_CONFIGURE_ARGS += --prefix=$(INSTALL_PREFIX)
# DSM7 appdir
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
REAL_CONFIGURE_ARGS += --localstatedir=$(INSTALL_PREFIX_VAR)
endif
endif
REAL_CONFIGURE_ARGS += $(CONFIGURE_ARGS)

configure_msg:
@$(MSG) "Configuring for $(NAME)"
@$(MSG) - Configure ARGS: $(CONFIGURE_ARGS)
@$(MSG) - Install prefix: $(INSTALL_PREFIX)
@$(MSG) - Install prefix [var]: $(INSTALL_PREFIX_VAR)

pre_configure_target: configure_msg

Expand Down
17 changes: 15 additions & 2 deletions mk/spksrc.copy.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,26 @@ endif
copy_msg:
@$(MSG) "Creating target installation dir of $(NAME)"
@rm -fr $(STAGING_DIR)
@mkdir $(STAGING_DIR)

pre_copy_target: copy_msg

copy_target: SHELL:=/bin/bash
copy_target: $(PRE_COPY_TARGET) $(INSTALL_PLIST)
(cd $(INSTALL_DIR)/$(INSTALL_PREFIX) && tar cpf - `cat $(INSTALL_PLIST) | cut -d':' -f2`) | \
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
@$(MSG) [DSM7+] Copy target to staging, discard var directory
@(mkdir -p $(STAGING_DIR) && cd $(INSTALL_DIR)/$(INSTALL_PREFIX) && tar cpf - `cat $(INSTALL_PLIST) | sed -e '/^.*:var\/.*/d' -e 's/^.*://g'`) | \
tar xpf - -C $(STAGING_DIR)
@$(MSG) "[DSM7+] Copy & merge var and target/var to $(STAGING_DIR)/var"
@if [ "`cat $(INSTALL_PLIST) | sed -n 's?^.*:var/??p'`" ] ; then \
mkdir -p $(STAGING_DIR)/var ; \
(cd $(INSTALL_DIR)/$(INSTALL_PREFIX) && tar cpf - $$(eval ls -d $$(cat $(INSTALL_PLIST) | sed -n 's?^.*:var/??p' | sed -e 's?^?{var,target/var}/?') 2>/dev/null)) | \
tar xpf - -C $(STAGING_DIR)/var --strip-components=1 --transform='s!^target/!!' ; \
fi
else
@$(MSG) Copy target to staging [DSM6]
@(mkdir -p $(STAGING_DIR) && cd $(INSTALL_DIR)/$(INSTALL_PREFIX) && tar cpf - `cat $(INSTALL_PLIST) | cut -d':' -f2`) | \
tar xpf - -C $(STAGING_DIR)
endif

post_copy_target: $(COPY_TARGET)

Expand Down
5 changes: 5 additions & 0 deletions mk/spksrc.cross-cmake-env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ CMAKE_ARGS += -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE
CMAKE_ARGS += -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE
CMAKE_ARGS += -DBUILD_SHARED_LIBS=ON

# DSM7 appdir
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
CMAKE_ARGS += -DCMAKE_INSTALL_LOCALSTATEDIR=$(INSTALL_PREFIX_VAR)
endif

# Use native cmake
ifeq ($(strip $(USE_NATIVE_CMAKE)),1)
BUILD_DEPENDS += native/cmake
Expand Down
23 changes: 21 additions & 2 deletions mk/spksrc.directories.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ endif
ifndef INSTALL_DIR
INSTALL_DIR = $(WORK_DIR)/install
endif
STAGING_DIR = $(WORK_DIR)/staging

ifndef INSTALL_PREFIX
ifneq ($(strip $(SPK_NAME)),)
Expand All @@ -51,6 +50,27 @@ ifeq ($(strip $(STAGING_INSTALL_PREFIX)),)
STAGING_INSTALL_PREFIX = $(INSTALL_DIR)$(INSTALL_PREFIX)
endif

#
# When building spk packages set var directory under
# target/../var to be consequent with the new directory
# structure using localstatedir flag. But only do so
# when invoking make from under spk/*. Setting var when
# test-building dependencies from under cross/* is unecessary.
#
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
ifeq ($(lastword $(subst /, ,$(INSTALL_PREFIX))),target)
INSTALL_PREFIX_VAR = $(INSTALL_PREFIX)/../var
endif
endif
ifeq ($(strip $(INSTALL_PREFIX_VAR)),)
INSTALL_PREFIX_VAR = $(INSTALL_PREFIX)/var
endif
STAGING_INSTALL_PREFIX_VAR = $(INSTALL_DIR)$(INSTALL_PREFIX_VAR)

ifeq ($(strip $(STAGING_DIR)),)
STAGING_DIR = $(WORK_DIR)/staging
endif

# python wheelhouse directories
ifndef WHEELHOUSE
WHEELHOUSE = $(WORK_DIR)/wheelhouse
Expand All @@ -63,4 +83,3 @@ endif
define create_target_dir
@mkdir -p `dirname $@`
endef

18 changes: 14 additions & 4 deletions mk/spksrc.install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ INSTALL_COOKIE = $(WORK_DIR)/.$(COOKIE_PREFIX)install_done
INSTALL_PLIST = $(WORK_DIR)/$(PKG_NAME).plist
PRE_INSTALL_PLIST = $(INSTALL_PLIST).tmp

# Define find search path for creating plist
ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
ifeq ($(lastword $(subst /, ,$(INSTALL_PREFIX))),target)
PLIST_SEARCH_PATH = $(INSTALL_DIR)/$(INSTALL_PREFIX)/../
endif
endif
ifeq ($(strip $(PLIST_SEARCH_PATH)),)
PLIST_SEARCH_PATH = $(INSTALL_DIR)/$(INSTALL_PREFIX)/
endif

$(PRE_INSTALL_PLIST): install_msg_target
ifeq ($(strip $(PRE_INSTALL_TARGET)),)
PRE_INSTALL_TARGET = pre_install_target
Expand All @@ -47,8 +57,8 @@ install_msg_target:

$(PRE_INSTALL_PLIST):
$(create_target_dir)
@mkdir -p $(INSTALL_DIR)/$(INSTALL_PREFIX)
find $(INSTALL_DIR)/$(INSTALL_PREFIX)/ \! -type d -printf '%P\n' | sort > $@
@mkdir -p $(INSTALL_DIR)/$(INSTALL_PREFIX) $(INSTALL_DIR)/$(INSTALL_PREFIX_VAR)
find $(PLIST_SEARCH_PATH) \! -type d -printf '%P\n' | sed 's?^target/??g' | sort > $@

pre_install_target: install_msg_target $(PRE_INSTALL_PLIST)

Expand All @@ -61,8 +71,8 @@ install_destdir_target: $(PRE_INSTALL_TARGET)
post_install_target: $(INSTALL_TARGET)

$(INSTALL_PLIST):
find $(INSTALL_DIR)/$(INSTALL_PREFIX)/ \! -type d -printf '%P\n' | sort | \
diff $(PRE_INSTALL_PLIST) - | grep '>' | cut -d' ' -f2- > $@
find $(PLIST_SEARCH_PATH)/ \! -type d -printf '%P\n' | sed 's?^target/??g' | sort | \
diff $(PRE_INSTALL_PLIST) - | grep '>' | sed 's?> ??g' > $@

install_correct_lib_files: $(INSTALL_PLIST)
@for pc_file in `grep -e "^lib/pkgconfig/.*\.pc$$" $(INSTALL_PLIST)` ; \
Expand Down
2 changes: 1 addition & 1 deletion mk/spksrc.spk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ $(DSM_LICENSE_FILE): $(LICENSE_FILE)
$(WORK_DIR)/package.tgz: icon service
$(create_target_dir)
@[ -f $@ ] && rm $@ || true
(cd $(STAGING_DIR) && tar cpzf $@ --owner=root --group=root *)
(cd $(STAGING_DIR) && find . -mindepth 1 -maxdepth 1 -not -empty | tar cpzf $@ --owner=root --group=root --files-from=/dev/stdin)
hgy59 marked this conversation as resolved.
Show resolved Hide resolved

DSM_SCRIPTS = $(addprefix $(DSM_SCRIPTS_DIR)/,$(DSM_SCRIPT_FILES))

Expand Down