Skip to content

Commit

Permalink
packaging: add native debian package
Browse files Browse the repository at this point in the history
For development purposes, add native debian packaging.

- Add debian package metadata to /packaging/debian

- Add build-deb.sh to /scripts/ to build the debs

- Add github workflow to validate debs

Signed-off-by: Chris Patterson <[email protected]>
  • Loading branch information
cjp256 committed Jun 10, 2024
1 parent a20550e commit ce52d7f
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 4 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/debs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Debian Packaging CI
on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
defaults:
run:
shell: bash

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.sha }}
fetch-depth: 0
fetch-tags: true
- name: Get tags from upstream, if needed
if: github.repository != 'Azure/azure-nvme-utils'
run: |
git remote add upstream https://github.com/Azure/azure-nvme-utils.git
git fetch upstream --tags
- name: Setup
run: |
sudo apt update
sudo apt install gcc pandoc cmake devscripts debhelper -y
- name: Build debs
run: |
DEBEMAIL="Azure NVMe Utils CI <azure/[email protected]>" ./scripts/build-deb.sh
- name: Lintian check
run: |
lintian out/*.deb
- name: Install debs
run: |
sudo dpkg -i out/*.deb
- name: Verify installation
run: |
set -x
dpkg -L azure-nvme-utils
test -f /usr/share/man/man1/azure-nvme-id.1.gz
test -f /usr/sbin/azure-nvme-id
test -f /lib/udev/rules.d/80-azure-nvme.rules
azure-nvme-id --version
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
defaults:
Expand Down
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ _deps

# Compiled artifacts
azure-nvme-id
build/
udev/80-azure-nvme.rules
src/version.h
doc/azure-nvme-id.1
obj-*
/build/
/debian/
/doc/azure-nvme-id.1
/src/version.h
/udev/80-azure-nvme.rules
/out/
16 changes: 16 additions & 0 deletions packaging/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source: azure-nvme-utils
Section: utils
Priority: optional
Maintainer: Chris Patterson <[email protected]>
Build-Depends: cmake, pandoc, debhelper-compat (= 12)
Standards-Version: 4.5.0
Homepage: https://github.com/Azure/azure-nvme-utils
Rules-Requires-Root: no

Package: azure-nvme-utils
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: Utilities to assist managing NVMe devices on Azure
This package provides azure-nvme-id for NVMe device identification and udev
rules to provide symlinks using available identifiers.
27 changes: 27 additions & 0 deletions packaging/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: azure-nvme-utils
Upstream-Contact: https://github.com/Azure/azure-nvme-utils/issues
Source: https://github.com/Azure/azure-nvme-utils

Files: *
Copyright: 2024 Microsoft Corporation
License: Expat

License: Expat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
8 changes: 8 additions & 0 deletions packaging/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -Werror -Wextra
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
dh $@
1 change: 1 addition & 0 deletions packaging/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (native)
2 changes: 2 additions & 0 deletions packaging/debian/source/lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source: no-nmu-in-changelog
source: source-nmu-has-incorrect-version-number
30 changes: 30 additions & 0 deletions scripts/build-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -eux -o pipefail

project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
git_version="$(git describe --tags --always --dirty)"
git_ref="$(echo "${git_version}" | sed 's/.*-g//' | sed 's/-dirty/DIRTY/')"
deb_version="$(echo "${git_version}" | sed 's/^v//' | sed 's/-.*//')+git${git_ref}"
output_dir="${project_dir}/out"

echo "project root: $project_dir"
echo "project version: $git_version"

cd "$project_dir"
mkdir -p debian
rsync -a packaging/debian/. debian/.

rm -f debian/changelog
if [[ -z ${DEBEMAIL:-} ]]; then
git_user="$(git config user.name)"
git_email="$(git config user.email)"
export DEBEMAIL="${git_user} <${git_email}>"
fi
dch --create -v "${deb_version}" --package "azure-nvme-utils" "development build: ${git_version}"

debuild --no-tgz-check

mkdir -p "${output_dir}"
rm -f "${output_dir}"/*.deb
mv ../azure-nvme-utils*"${deb_version}"* "${output_dir}"/

0 comments on commit ce52d7f

Please sign in to comment.