rpm.mk 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ifeq ($(_THEOS_PACKAGE_FORMAT_LOADED),)
  2. _THEOS_PACKAGE_FORMAT_LOADED := 1
  3. _THEOS_RPM_PACKAGE_SPEC_PATH := $(wildcard $(THEOS_PROJECT_DIR)/package.spec)
  4. _THEOS_RPM_CAN_PACKAGE := $(if $(_THEOS_RPM_PACKAGE_SPEC_PATH),$(_THEOS_TRUE),$(_THEOS_FALSE))
  5. _THEOS_PACKAGE_INC_VERSION_PREFIX :=
  6. _THEOS_PACKAGE_EXTRA_VERSION_PREFIX := +
  7. _THEOS_RPM_HAS_RPMBUILD := $(call __executable,rpmbuild)
  8. ifneq ($(_THEOS_RPM_HAS_RPMBUILD),$(_THEOS_TRUE))
  9. internal-package-check::
  10. @$(PRINT_FORMAT_ERROR) "$(MAKE) package requires rpmbuild." >&2; exit 1
  11. endif
  12. ifeq ($(_THEOS_RPM_CAN_PACKAGE),$(_THEOS_TRUE)) # Control file found (or layout/ found.)
  13. THEOS_PACKAGE_NAME := $(shell grep -i "^Name:" "$(_THEOS_RPM_PACKAGE_SPEC_PATH)" | cut -d':' -f2- | xargs)
  14. THEOS_PACKAGE_ARCH := $(shell grep -i "^BuildArch:" "$(_THEOS_RPM_PACKAGE_SPEC_PATH)" | cut -d':' -f2- | xargs)
  15. THEOS_PACKAGE_RPM_VERSION := $(shell grep -i "^Version:" "$(_THEOS_RPM_PACKAGE_SPEC_PATH)" | cut -d':' -f2- | xargs)
  16. ifeq ($(FINALPACKAGE),1)
  17. THEOS_PACKAGE_RELEASE_VERSION ?= $(shell grep -i "^Release:" "$(_THEOS_RPM_PACKAGE_SPEC_PATH)" | cut -d':' -f2- | xargs)
  18. else
  19. THEOS_PACKAGE_RELEASE_VERSION ?=
  20. endif
  21. THEOS_PACKAGE_BASE_VERSION := $(THEOS_PACKAGE_RELEASE_VERSION)
  22. before-package::
  23. $(ECHO_NOTHING)sed -e 's/[Rr]elease:.*/Release: $(_THEOS_INTERNAL_PACKAGE_VERSION)/g' -e '/^[Ss]ource0:/d' "$(_THEOS_RPM_PACKAGE_SPEC_PATH)" > "$(THEOS_OBJ_DIR)/package.spec"$(ECHO_END)
  24. $(ECHO_NOTHING)echo '%files' >> "$(THEOS_OBJ_DIR)/package.spec"$(ECHO_END)
  25. $(ECHO_NOTHING)echo '/*' >> "$(THEOS_OBJ_DIR)/package.spec"$(ECHO_END)
  26. _THEOS_RPM_PACKAGE_FILENAME = $(THEOS_PACKAGE_DIR)/$(THEOS_PACKAGE_NAME)-$(THEOS_PACKAGE_RPM_VERSION)-$(_THEOS_INTERNAL_PACKAGE_VERSION).$(THEOS_PACKAGE_ARCH).rpm
  27. internal-package::
  28. $(ECHO_NOTHING)COPYFILE_DISABLE=1 $(FAKEROOT) -r rpmbuild -bb "$(THEOS_OBJ_DIR)/package.spec" --buildroot "$(THEOS_STAGING_DIR)" --define "_rpmdir$(THEOS_OBJ_DIR)" $(STDERR_NULL_REDIRECT)$(STDOUT_NULL_REDIRECT)$(ECHO_END)
  29. $(ECHO_NOTHING)ln -f "$(THEOS_OBJ_DIR)/$(THEOS_PACKAGE_ARCH)/$(THEOS_PACKAGE_NAME)-$(THEOS_PACKAGE_RPM_VERSION)-$(_THEOS_INTERNAL_PACKAGE_VERSION).$(THEOS_PACKAGE_ARCH).rpm" "$(_THEOS_RPM_PACKAGE_FILENAME)"$(ECHO_END)
  30. $(ECHO_NOTHING)rm -r "$(THEOS_OBJ_DIR)/$(THEOS_PACKAGE_ARCH)"$(ECHO_END)
  31. # This variable is used in package.mk
  32. after-package:: __THEOS_LAST_PACKAGE_FILENAME = $(_THEOS_RPM_PACKAGE_FILENAME)
  33. else # _THEOS_RPM_CAN_PACKAGE == 0
  34. internal-package::
  35. @$(PRINT_FORMAT_ERROR) "$(MAKE) package requires you to have a package.spec file in the project directory." >&2; exit 1
  36. endif # _THEOS_RPM_CAN_PACKAGE
  37. endif # _THEOS_PACKAGE_FORMAT_LOADED