From ebf27a9ff3d6b27caab12b6ae351729ce73bcb6f Mon Sep 17 00:00:00 2001 From: Rajiv Date: Tue, 13 Mar 2018 14:43:14 +0530 Subject: [PATCH 1/9] Delete empty preinst file --- deb/DEBIAN/preinst | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 deb/DEBIAN/preinst diff --git a/deb/DEBIAN/preinst b/deb/DEBIAN/preinst deleted file mode 100755 index e69de29b..00000000 From 7c40c3cb3f3231e63f1a033f3843df77750f0d5b Mon Sep 17 00:00:00 2001 From: Rajiv Date: Tue, 13 Mar 2018 14:44:17 +0530 Subject: [PATCH 2/9] Fix for installing on Docker Centos7 Fixes #44 - XCollector fails to start on docker centos7 --- rpm/xcollector.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/rpm/xcollector.spec b/rpm/xcollector.spec index 459b8926..50d6d546 100644 --- a/rpm/xcollector.spec +++ b/rpm/xcollector.spec @@ -24,6 +24,7 @@ License: LGPLv3+ Summary: XCollector - Data collection agent for apptuit.ai URL: http://apptuit.ai/xcollector.html Provides: xcollector = @PACKAGE_VERSION@-@RPM_REVISION@_@GIT_SHORTSHA1@ +Requires: initscripts Requires: python(abi) >= @PYTHON_VERSION@ Requires: python-devel Requires: MySQL-python From f60447c046deffd6b48992223a40fa9bc45c64f3 Mon Sep 17 00:00:00 2001 From: Rajiv Date: Tue, 13 Mar 2018 14:45:16 +0530 Subject: [PATCH 3/9] Some rpmlint love --- rpm/xcollector.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpm/xcollector.spec b/rpm/xcollector.spec index 50d6d546..ab78950b 100644 --- a/rpm/xcollector.spec +++ b/rpm/xcollector.spec @@ -24,6 +24,7 @@ License: LGPLv3+ Summary: XCollector - Data collection agent for apptuit.ai URL: http://apptuit.ai/xcollector.html Provides: xcollector = @PACKAGE_VERSION@-@RPM_REVISION@_@GIT_SHORTSHA1@ +Packager: XCollector Maintainers Requires: initscripts Requires: python(abi) >= @PYTHON_VERSION@ Requires: python-devel @@ -187,6 +188,7 @@ chown -R $XCOLLECTOR_USER.$XCOLLECTOR_GROUP /var/log/xcollector if [ "$1" = "0" ]; then # stop service before starting the uninstall service xcollector stop + chkconfig --del xcollector fi %postun From 5efe866b34abe17f515e19c39e98db304ea5ace5 Mon Sep 17 00:00:00 2001 From: Rajiv Date: Tue, 13 Mar 2018 14:46:23 +0530 Subject: [PATCH 4/9] Run lint on deb/rpm packages Fixes #33 - Enable lint on deb and rpm files --- .travis.yml | 18 +++++++++++++++++- deb/Makefile | 3 +++ rpm/Makefile | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fea16e54..bd2f6b1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,22 @@ python: - "3.5" - "3.6" +cache: + directories: + - '$HOME/.rpmlint/' + +before_install: + - | + wget -O ~/.rpmlint/rpmlint-1.9.tar.gz https://github.com/rpm-software-management/rpmlint/archive/rpmlint-1.9.tar.gz; + tar xvfz ~/.rpmlint/rpmlint-1.9.tar.gz -C ~/.rpmlint; + BUILDER=$USER sudo make install -C ~$BUILDER/.rpmlint/rpmlint-rpmlint-1.9 + + install: - sudo apt-get -qq update - - sudo apt-get install -y rpm + - sudo apt-get install -y rpm python-rpm + - sudo apt-get install -y lintian +# - sudo apt-get install -y rpmlint - if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then pip install pylint; fi - pip install ordereddict pyyaml mysqlclient @@ -26,6 +39,9 @@ script: - make -C rpm - make -C deb +after_success: + - make lint -C rpm + - make lint -C deb before_deploy: - PACKAGE_DATE=$(git log -1 --pretty="format:%ad" $TRAVIS_TAG --date=short); diff --git a/deb/Makefile b/deb/Makefile index 23c04697..193c07a1 100644 --- a/deb/Makefile +++ b/deb/Makefile @@ -73,6 +73,9 @@ deb: cd build; find . -type f ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums dpkg-deb -b build dist/$(DEB) +lint: + lintian --no-tag-display-limit dist/$(DEB) + clean: rm -rf build dist diff --git a/rpm/Makefile b/rpm/Makefile index 7b557844..6f9dd016 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -57,6 +57,9 @@ rpm: rpmbuild --define "_topdir %(pwd)/build" -bb build/xcollector-t.spec if test -f build/RPMS/$(RPM_TARGET)/$(RPM); then mv build/RPMS/$(RPM_TARGET)/$(RPM) ./dist/; else mv xcollector.$(RPM_TARGET).rpm $(RPM); fi +lint: + rpmlint dist/$(RPM) + clean: rm -rf build dist From 11f310c32b46c566b3e4cd461ce8eda3faf283ab Mon Sep 17 00:00:00 2001 From: Rajiv Date: Tue, 13 Mar 2018 15:40:17 +0530 Subject: [PATCH 5/9] Consolidate all conditions using $IS_PRIMARY_MATRIX_JOB variable --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd2f6b1d..ec2fc4ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,9 +27,11 @@ install: - pip install ordereddict pyyaml mysqlclient before_script: + - if [[ "$TRAVIS_PYTHON_VERSION" = "2.7" ]]; then export IS_PRIMARY_MATRIX_JOB=true; fi - if [[ $TRAVIS_TAG == apptuit-v* ]]; then export PACKAGE_VERSION=${TRAVIS_TAG#apptuit-v}; fi - echo $TRAVIS_TAG - echo $PACKAGE_VERSION + - echo $IS_PRIMARY_MATRIX_JOB script: - python -c "import sys; print('python version:%s' % sys.version);" @@ -58,11 +60,11 @@ deploy: key: "$BINTRAY_API_KEY" on: tags: true - condition: $PACKAGE_VERSION != "" && $TRAVIS_PYTHON_VERSION == "2.7" && $BINTRAY_API_KEY != "" + condition: $PACKAGE_VERSION != "" && $IS_PRIMARY_MATRIX_JOB == "true" && $BINTRAY_API_KEY != "" - provider: bintray file: "rpm/bintray-descriptor.json" user: "$BINTRAY_USER" key: "$BINTRAY_API_KEY" on: tags: true - condition: $PACKAGE_VERSION != "" && $TRAVIS_PYTHON_VERSION == "2.7" && $BINTRAY_API_KEY != "" \ No newline at end of file + condition: $PACKAGE_VERSION != "" && $IS_PRIMARY_MATRIX_JOB == "true" && $BINTRAY_API_KEY != "" \ No newline at end of file From 498dd0f9bdad8259d07fe4efd2a3b75fb81fb19f Mon Sep 17 00:00:00 2001 From: Rajiv Date: Tue, 13 Mar 2018 16:35:04 +0530 Subject: [PATCH 6/9] Print failure message on installation error Trap any errors and show installation failure message in red text. Fixes #43 - Need a better error message if XCollector installation fails --- install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e743e4f2..2ce1f15f 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -eE function setup_log () { logfile="xcollector-install.log" @@ -135,6 +135,10 @@ function post_complete () { print_message "success" "Installation completed successfully\n" } +function post_error () { + print_message "error" "Installation failed\n" +} + function check_time_diff () { print_message "Verifying time offset\n" @@ -161,6 +165,7 @@ Metrics might now show up in the correct time window when you query\n" fi } +trap post_error ERR setup_log if [ -n "$XC_ACCESS_TOKEN" ]; then From 1fd0506cbb8d14ae30cf67c13fb3c8915141ba0c Mon Sep 17 00:00:00 2001 From: Rajiv Date: Wed, 14 Mar 2018 18:42:02 +0530 Subject: [PATCH 7/9] Ignore case while checking http headers Fixes #45 - installer unable to verify time offset on fedora --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 2ce1f15f..38e08ecc 100755 --- a/install.sh +++ b/install.sh @@ -144,9 +144,9 @@ function check_time_diff () { local server_header="" if [ $(command -v curl) ]; then - server_header=$(curl -s --head https://www.google.com/humans.txt | grep '^\s*Date:\s*' | sed 's/\s*Date:\s*//g') + server_header=$(curl -s --head https://www.google.com/humans.txt | grep -i '^\s*Date:\s*' | sed 's/\s*Date:\s*//Ig') elif [ $(command -v wget) ]; then - server_header=$(wget -S --spider https://www.google.com/humans.txt 2>&1 | grep '^\s*Date:\s*' | sed 's/\s*Date:\s*//g') + server_header=$(wget -S --spider https://www.google.com/humans.txt 2>&1 | grep -i '^\s*Date:\s*' | sed 's/\s*Date:\s*//Ig') fi if [ "$server_header" == "" ]; then From 0ed82afac606f9701b831e39002376e34b094759 Mon Sep 17 00:00:00 2001 From: Rajiv Date: Thu, 22 Mar 2018 17:33:43 +0530 Subject: [PATCH 8/9] Fix typo --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 38e08ecc..96edb45a 100755 --- a/install.sh +++ b/install.sh @@ -161,7 +161,7 @@ Please verify that the local server time is accurate manually.\n" if [ $time_delta -ge 300 -o $time_delta -le -300 ]; then print_message "warn" "There is too much time difference between local time and Apptuit. -Metrics might now show up in the correct time window when you query\n" +Metrics might not show up in the correct time window when you query\n" fi } From 11bcef6e9ec9b3410dc02bdb953d7c92760871d1 Mon Sep 17 00:00:00 2001 From: Rajiv Date: Thu, 22 Mar 2018 18:10:48 +0530 Subject: [PATCH 9/9] Skip cleanup of git so that changes to bintray descriptor is not lost --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ec2fc4ca..5d43cbe3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,6 +55,7 @@ before_deploy: deploy: - provider: bintray + skip_cleanup: true file: "deb/bintray-descriptor.json" user: "$BINTRAY_USER" key: "$BINTRAY_API_KEY" @@ -62,6 +63,7 @@ deploy: tags: true condition: $PACKAGE_VERSION != "" && $IS_PRIMARY_MATRIX_JOB == "true" && $BINTRAY_API_KEY != "" - provider: bintray + skip_cleanup: true file: "rpm/bintray-descriptor.json" user: "$BINTRAY_USER" key: "$BINTRAY_API_KEY"