diff --git a/Makefile b/Makefile index dde9d8cb3..21490caee 100644 --- a/Makefile +++ b/Makefile @@ -376,10 +376,12 @@ include $(ROOT_DIR)/package/$(UNAME).mk # Source for distribution # ############################## -$(DIST_VER_INFO): .git/index | $(DIST_DIR) +FORCE: + +$(DIST_VER_INFO): FORCE | $(DIST_DIR) $(V1) $(VERSION_INFO) --jsonpath="$(DIST_DIR)" -$(DIST_TAR): $(DIST_VER_INFO) .git/index | $(DIST_DIR) +$(DIST_TAR): $(DIST_VER_INFO) | $(DIST_DIR) @$(ECHO) " SOURCE FOR DISTRIBUTION $(call toprel, $(DIST_TAR))" $(V1) git archive --prefix="$(PACKAGE_NAME)/" -o "$(DIST_TAR)" HEAD $(V1) tar --append --file="$(DIST_TAR)" \ diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 47d94a1ce..a06e96b21 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -252,8 +252,29 @@ class Repo: json_data['dirty'] = False json_path = os.path.join(path, 'version-info.json') - with open(json_path, 'w') as json_file: - json.dump(json_data, json_file) + + write_if_different(json_path, json.dumps(json_data)) + + +def write_if_different(out_name, out): + """Write ouput to file only if it differs from current""" + + # Check if output file already exists + try: + of = open(out_name, "rb") + except IOError: + # No file - create new + of = open(out_name, "wb") + of.write(out) + of.close() + else: + # File exists - overwite only if content is different + inp = of.read() + of.close() + if inp != out: + of = open(out_name, "wb") + of.write(out) + of.close() def escape_dict(dictionary): """Escapes dictionary values for C""" @@ -300,22 +321,8 @@ def file_from_template(tpl_name, out_name, dictionary): # Replace placeholders using dictionary out = Template(tpl).substitute(dictionary) - # Check if output file already exists - try: - of = open(out_name, "rb") - except IOError: - # No file - create new - of = open(out_name, "wb") - of.write(out) - of.close() - else: - # File exists - overwite only if content is different - inp = of.read() - of.close() - if inp != out: - of = open(out_name, "wb") - of.write(out) - of.close() + write_if_different(out_name, out) + def sha1(file): """Provides C source representation of sha1 sum of file""" diff --git a/package/linux/deb.mk b/package/linux/deb.mk index 79668b0ca..0412dfcf6 100644 --- a/package/linux/deb.mk +++ b/package/linux/deb.mk @@ -9,6 +9,7 @@ endif DEB_NAME := $(ORG_SMALL_NAME) DEB_ORIG_SRC := $(PACKAGE_DIR)/$(DEB_NAME)_$(UPSTREAM_VER).orig.tar.gz DEB_ORIG_FW := $(PACKAGE_DIR)/$(DEB_NAME)_$(UPSTREAM_VER).orig-firmware.tar.gz +DEB_SRC_CHANGES := $(PACKAGE_DIR)/$(DEB_NAME)_$(UPSTREAM_VER)-$(DEB_REV)_source.changes DEB_PACKAGE_DIR := $(PACKAGE_DIR)/$(DEB_NAME)-$(UPSTREAM_VER) DEB_ARCH := $(shell dpkg --print-architecture) DEB_PACKAGE_NAME := $(DEB_NAME)_$(UPSTREAM_VER)-$(DEB_REV)_$(DEB_ARCH) @@ -37,7 +38,7 @@ package: debian @$(ECHO) "Building Linux package, please wait..." $(V1) sed -i -e "$(PACKAGE_DEPS_SED)" debian/control $(V1) sed -i -e 's,config_new.*, --help > /dev/null,' debian/rules - $(V1) dpkg-buildpackage -b -us -uc -nc $(DPKG_BUILDPACKAGE_OPTS) + $(V1) dpkg-buildpackage -b -us -uc -nc $(V1) mv $(ROOT_DIR)/../$(DEB_PACKAGE_NAME).deb $(BUILD_DIR) $(V1) mv $(ROOT_DIR)/../$(DEB_PACKAGE_NAME).changes $(BUILD_DIR) $(V1) rm -r debian @@ -56,8 +57,23 @@ ifeq ($(DEB_DIST), trusty) endif .PHONY: package_src -package_src: $(DEB_ORIG_SRC_NAME) $(DEB_PACKAGE_DIR) - $(V1) cd $(DEB_PACKAGE_DIR) && dpkg-buildpackage -S -us -uc $(DPKG_BUILDPACKAGE_OPTS) +package_src: $(DEB_SRC_CHANGES) + +.PHONY: package_src_upload +package_src_upload: $(DEB_SRC_CHANGES) + $(V1) debsign $(DEB_SRC_CHANGES) + $(V1) dput $(DPUT_URL) $(DEB_SRC_CHANGES) + +# Only include the orig if it we haven't alreadly built it, +# because if we have it is likely to be uploaded already +ifeq ($(wildcard $(DEB_ORIG_SRC)),) +DPKG_INCLUDE_ORIG := -sa +else +DPKG_INCLUDE_ORIG := -sd +endif + +$(DEB_SRC_CHANGES): $(DEB_ORIG_SRC_NAME) $(DEB_PACKAGE_DIR) + $(V1) cd $(DEB_PACKAGE_DIR) && dpkg-buildpackage -S -us -uc $(DPKG_INCLUDE_ORIG) $(DEB_ORIG_SRC): $(DIST_TAR_GZ) | $(PACKAGE_DIR) $(V1) cp $(DIST_TAR_GZ) $(DEB_ORIG_SRC) diff --git a/package/linux/rpm.mk b/package/linux/rpm.mk index 53a544ff9..4528bcdd7 100644 --- a/package/linux/rpm.mk +++ b/package/linux/rpm.mk @@ -25,7 +25,7 @@ SPEC_FILE_IN := $(ROOT_DIR)/package/linux/rpmspec.in .PHONY: rpmspec rpmspec: $(SPEC_FILE) -$(SPEC_FILE): $(SPEC_FILE_IN) | $(RPM_DIRS) +$(SPEC_FILE): $(SPEC_FILE_IN) $(DIST_VER_INFO) | $(RPM_DIRS) $(V1) cp -f $(SPEC_FILE_IN) $(SPEC_FILE) $(V1) $(SED_SCRIPT) $(SPEC_FILE) @@ -38,6 +38,10 @@ $(RPM_PACKAGE_FILE): RPMBUILD_OPTS := -bb package_src: $(RPM_PACKAGE_SRC) $(RPM_PACKAGE_SRC): RPMBUILD_OPTS := -bs +.PHONY: package_src_upload +package_src_upload: $(RPM_PACKAGE_SRC) + copr-cli build --nowait $(COPR_PROJECT) $(RPM_PACKAGE_SRC) + $(RPM_PACKAGE_FILE) $(RPM_PACKAGE_SRC): $(SPEC_FILE) $(DIST_TAR_GZ) $(FW_DIST_TAR_GZ) | $(RPM_DIRS) @$(ECHO) "Building $(call toprel,$@), please wait..." $(V1) ln -sf $(DIST_TAR_GZ) $(PACKAGE_DIR)/SOURCES diff --git a/package/linux/rpmspec.in b/package/linux/rpmspec.in index d175b4d26..330a36f7b 100644 --- a/package/linux/rpmspec.in +++ b/package/linux/rpmspec.in @@ -24,6 +24,8 @@ BuildRequires: qt5-qtserialport-devel BuildRequires: qt5-qtsvg-devel BuildRequires: qt5-qttools-devel BuildRequires: qt5-qttranslations +BuildRequires: OpenSceneGraph-devel +%{!?fc22:BuildRequires: osgearth-devel} BuildRequires: dwz BuildRequires: pkgconfig BuildRequires: python @@ -38,6 +40,8 @@ Requires: qt5-qtmultimedia Requires: qt5-qtscript Requires: qt5-qtserialport Requires: qt5-qtsvg +Requires: OpenSceneGraph-libs +%{!?fc22:Requires: osgearth} %description @@ -55,7 +59,8 @@ make config_new \ prefix=%{_prefix} \ QMAKE=qmake-qt5 \ udevrulesdir=%{_udevrulesdir} \ - WITH_PREBUILT_FW=$(pwd)/build/firmware + WITH_PREBUILT_FW=$(pwd)/build/firmware \ + GCS_EXTRA_CONF='osg%{!?fc22: osgearth}' make %{?_smp_mflags} opfw_resource gcs @@ -77,26 +82,10 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %doc README.md CREDITS.txt WHATSNEW.txt %doc GPLv3.txt -%{_bindir}/librepilot-gcs -%{_udevrulesdir}/45-librepilot.rules -%{_datadir}/applications/librepilot.desktop -%{_datadir}/librepilot-gcs/* -%{_datadir}/pixmaps/librepilot.png -%{_libdir}/librepilot-gcs/plugins/LibrePilot/*.pluginspec -%{_libdir}/librepilot-gcs/plugins/LibrePilot/*.so -# -%{_libdir}/librepilot-gcs/libAggregation.so.1* -%{_libdir}/librepilot-gcs/libExtensionSystem.so.1* -%{_libdir}/librepilot-gcs/libGLC_lib.so.1* -%{_libdir}/librepilot-gcs/libopmapwidget.so.1* -%{_libdir}/librepilot-gcs/libQScienceSpinBox.so.1* -%{_libdir}/librepilot-gcs/libQtConcurrent.so.1* -%{_libdir}/librepilot-gcs/libQwt.so.1* -%{_libdir}/librepilot-gcs/libsdlgamepad.so.1* -%{_libdir}/librepilot-gcs/libUtils.so.1* -%{_libdir}/librepilot-gcs/libVersionInfo.so.1* -# -%{_libdir}/librepilot-gcs/lib*.so +%{_bindir}/* +%{_udevrulesdir}/* +%{_datadir}/* +%{_libdir}/* %changelog