Skip to content

Commit

Permalink
[debian] Packaging and testing for debian pkgs
Browse files Browse the repository at this point in the history
Initial start of building and testing the deb package

This will improve the overall testing of sos over the Ubuntu releases,
and also helps with the basis of thenadding further stagetwo testing in
the future. This will help to pick up issues automatically rather than
the manual testing.

Add ubuntu-latest for deb CI build and testing. Update the GCE images
for all ubuntu images for CI testing

Co-authored-by: Nikhil Kshirsagar <[email protected]>
Signed-off-by: Nikhil Kshirsagar <[email protected]>
Signed-off-by: Arif Ali <[email protected]>
  • Loading branch information
2 people authored and TurboTurtle committed Nov 12, 2023
1 parent 52c9237 commit 314cc50
Show file tree
Hide file tree
Showing 15 changed files with 426 additions and 9 deletions.
59 changes: 50 additions & 9 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:

DEBIAN_NAME: "debian-11"

UBUNTU_LATEST_NAME: "ubuntu-23.10"
UBUNTU_NAME: "ubuntu-22.04"
UBUNTU_PRIOR_NAME: "ubuntu-20.04"
UBUNTU_PRIOR2_NAME: "ubuntu-18.04"
Expand All @@ -27,10 +28,11 @@ env:
DEBIAN_IMAGE_NAME: "debian-11-bullseye-v20230809"
FEDORA_IMAGE_NAME: "fedora-cloud-base-gcp-38-1-6-x86-64"
FEDORA_PRIOR_IMAGE_NAME: "fedora-cloud-base-gcp-37-1-7-x86-64"
UBUNTU_IMAGE_NAME: "ubuntu-2204-jammy-v20230727"
UBUNTU_PRIOR_IMAGE_NAME: "ubuntu-2004-focal-v20230724"
UBUNTU_LATEST_IMAGE_NAME: "ubuntu-2310-mantic-amd64-v20231031"
UBUNTU_IMAGE_NAME: "ubuntu-2204-jammy-v20231030"
UBUNTU_PRIOR_IMAGE_NAME: "ubuntu-2004-focal-v20231101"
UBUNTU_PRIOR2_IMAGE_NAME: "ubuntu-1804-bionic-v20230605"
UBUNTU_SNAP_IMAGE_NAME: "ubuntu-2204-jammy-v20230727"
UBUNTU_SNAP_IMAGE_NAME: "ubuntu-2204-jammy-v20231030"

# Curl-command prefix for downloading task artifacts, simply add the
# the url-encoded task name, artifact name, and path as a suffix.
Expand Down Expand Up @@ -115,6 +117,27 @@ rpm_build_task:
path: ./sos_${BUILD_NAME}.rpm
type: application/octet-stream

# Make sure a user can manually build a deb from the checkout
deb_build_task:
alias: "deb_build"
name: "deb Build From Checkout"
gce_instance:
image_project: "${UBUNTU_PROJECT}"
image_name: "${UBUNTU_LATEST_IMAGE_NAME}"
type: e2-medium
setup_script: |
apt update --allow-releaseinfo-change
apt -y install devscripts equivs python3-pip
mk-build-deps
apt -y install ./sosreport-build-deps*.deb
pip3 install avocado-framework==94.0 --break-system-packages
main_script: |
dpkg-buildpackage -b -us -uc -rfakeroot -m --build-by="[email protected]"
prep_artifacts_script: mv ../*.deb ./sos_cirrus.deb
packages_artifacts:
path: ./sos_cirrus.deb
type: application/octet-stream

# Make sure a user can manually build a snap from the checkout
snap_build_task:
alias: "snap_build"
Expand Down Expand Up @@ -146,6 +169,7 @@ report_stageone_task:
depends_on:
- rpm_build
- snap_build
- deb_build
gce_instance: *standardvm
matrix:
- env: *centos9
Expand All @@ -156,24 +180,38 @@ report_stageone_task:
PROJECT: ${UBUNTU_PROJECT}
BUILD_NAME: ${UBUNTU_NAME}
VM_IMAGE_NAME: ${UBUNTU_IMAGE_NAME}
PKG: "snap"
- env: &ubuntuprior
PROJECT: ${UBUNTU_PROJECT}
BUILD_NAME: ${UBUNTU_PRIOR_NAME}
VM_IMAGE_NAME: ${UBUNTU_PRIOR_IMAGE_NAME}
PKG: "snap"
- env: &ubuntuprior2
PROJECT: ${UBUNTU_PROJECT}
BUILD_NAME: ${UBUNTU_PRIOR2_NAME}
VM_IMAGE_NAME: ${UBUNTU_PRIOR2_IMAGE_NAME}
PKG: "snap"
- env: &ubuntu-latest
PROJECT: ${UBUNTU_PROJECT}
BUILD_NAME: ${UBUNTU_LATEST_NAME}
VM_IMAGE_NAME: ${UBUNTU_LATEST_IMAGE_NAME}
PKG: "deb"
setup_script: &setup |
if [ $(command -v apt) ]; then
echo "$ARTCURL/snap%20Build%20From%20Checkout/packages/sosreport_test_amd64.snap"
$ARTCURL/snap%20Build%20From%20Checkout/packages/sosreport_test_amd64.snap
apt -y purge sosreport
apt update --allow-releaseinfo-change
apt -y install python3-pip snapd
systemctl start snapd
snap install ./sosreport_test_amd64.snap --classic --dangerous
snap alias sosreport.sos sos
if [ ${PKG} == "snap" ] ; then
echo "$ARTCURL/snap%20Build%20From%20Checkout/packages/sosreport_test_amd64.snap"
$ARTCURL/snap%20Build%20From%20Checkout/packages/sosreport_test_amd64.snap
systemctl start snapd
snap install ./sosreport_test_amd64.snap --classic --dangerous
snap alias sosreport.sos sos
elif [ ${PKG} == "deb" ]; then
echo "$ARTCURL/deb%20Build%20From%20Checkout/packages/sos_cirrus.deb"
$ARTCURL/deb%20Build%20From%20Checkout/packages/sos_cirrus.deb
apt -y install ./sos_cirrus.deb
fi
fi
if [ $(command -v dnf) ]; then
echo "$ARTCURL/rpm%20Build%20From%20Checkout%20-%20${BUILD_NAME}/packages/sos_${BUILD_NAME}.rpm"
Expand All @@ -182,7 +220,9 @@ report_stageone_task:
dnf -y install python3-pip ethtool
dnf -y install ./sos_${BUILD_NAME}.rpm
fi
pip3 install avocado-framework==94.0
PIP_EXTRA=""
[[ $(pip3 install --help | grep break-system) ]] && PIP_EXTRA="--break-system-packages"
pip3 install avocado-framework==94.0 ${PIP_EXTRA}
# run the unittests separately as they require a different PYTHONPATH in
# order for the imports to work properly under avocado
unittest_script: PYTHONPATH=. avocado run tests/unittests/
Expand All @@ -205,6 +245,7 @@ report_stagetwo_task:
- env: *centos8
- env: *fedora
- env: *ubuntu
- env: *ubuntu-latest
setup_script: *setup
install_pexpect_script: |
if [ $(command -v apt) ]; then
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ docs/_build

# Pycharm
.idea/

# debian files
debian/sosreport*
debian/files
debian/.debhelper
debian/debhelper-build-stamp
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sosreport (4.6.0-0ubuntu1) mantic; urgency=medium

* New 4.6.0 upstream.

-- Nikhil Kshirsagar <[email protected]> Thu, 17 Aug 2023 08:17:20 +0000
28 changes: 28 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Source: sosreport
Maintainer: Nikhil Kshirsagar <[email protected]>
Section: admin
Priority: optional
Standards-Version: 4.5.1
Build-Depends:
debhelper-compat (= 13),
dh-python,
gettext,
python3-all,
python3-coverage,
python3-nose,
python3-setuptools,
python3-sphinx,
python3-magic,
python3-pexpect,
Homepage: https://github.com/sosreport/sos
Vcs-Browser: https://salsa.debian.org/sosreport-team/sosreport
Vcs-Git: https://salsa.debian.org/sosreport-team/sosreport.git

Package: sosreport
Architecture: any
Depends: ${python3:Depends}, ${misc:Depends}, python3-pexpect, python3-magic
Description: Set of tools to gather troubleshooting data from a system
Sos is a set of tools that gathers information about system
hardware and configuration. The information can then be used for
diagnostic purposes and debugging. Sos is commonly used to help
support technicians and developers.
23 changes: 23 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: sosreport
Upstream-Contact: Jake Hunsaker <[email protected]>
Source: https://github.com/sosreport/sos

License: GPL-2+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
USA.
.
On Debian systems, the complete text of the GNU General Public
License, version 2, can be found in /usr/share/common-licenses/GPL-2.
5 changes: 5 additions & 0 deletions debian/dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/etc/sos
/etc/sos/cleaner
/etc/sos/extras.d
/etc/sos/groups.d
/etc/sos/presets.d
1 change: 1 addition & 0 deletions debian/docs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md AUTHORS
1 change: 1 addition & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sos.conf etc/sos/
11 changes: 11 additions & 0 deletions debian/patches/0001-debian-change-tmp-dir-location.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Description: Change default location to /tmp
--- a/sos.conf
+++ b/sos.conf
@@ -7,6 +7,7 @@
#verify = yes
#batch = yes
#log-size = 15
+tmp-dir = /tmp

[report]
# Options that will apply to any `sos report` run should be listed here.
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0001-debian-change-tmp-dir-location.patch
15 changes: 15 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/make -f

export PYBUILD_NAME=sosreport

%:
dh $@ --with python3 --buildsystem=pybuild

override_dh_install:
# Move config file to the right location.
mv debian/sosreport/usr/config/sos.conf debian/sosreport/etc/sos/sos.conf
# Remove unnecessary unused dir.
rm -rf debian/sosreport/usr/config

override_dh_auto_test:
nosetests3 -v --with-cover --cover-package=sos tests/unittests
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
3 changes: 3 additions & 0 deletions debian/tests/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Tests: simple.sh
Depends: sosreport
Restrictions: needs-root, allow-stderr, isolation-machine
Loading

0 comments on commit 314cc50

Please sign in to comment.