From cf87993a1c1acb37228122c8ce291c11014cef85 Mon Sep 17 00:00:00 2001 From: James Hodgkinson Date: Tue, 16 Jan 2024 11:30:52 +1000 Subject: [PATCH] Debian build fixes (also the book) (#2400) * betterer errors on things * Adding tpm-udev as a dependency of kanidm-unixd * fixing makefile arch error * adding jq to deb build deps * adding kanidm deb to autobuild * making the debian build script more resilient --- .github/workflows/debian_package_kanidm.yml | 2 +- .github/workflows/docker_build_kanidmd.yml | 18 +++++++++ .github/workflows/kanidm_book.yml | 7 ++-- platform/debian/Makefile | 2 +- platform/debian/build_kanidm.sh | 41 ++++++++++++++------- platform/debian/kanidm-unixd/control | 2 +- scripts/install_ubuntu_dependencies.sh | 1 + unix_integration/src/client_sync.rs | 15 ++++++-- 8 files changed, 66 insertions(+), 22 deletions(-) diff --git a/.github/workflows/debian_package_kanidm.yml b/.github/workflows/debian_package_kanidm.yml index 49ac223bc..131884a24 100644 --- a/.github/workflows/debian_package_kanidm.yml +++ b/.github/workflows/debian_package_kanidm.yml @@ -47,7 +47,7 @@ jobs: run: cargo install wasm-pack - name: Build packages (kanidm-unixd) run: make -f platform/debian/Makefile debs/kanidm-unixd - - name: Build packages (kanidm cli) + - name: Build packages (kanidm) run: make -f platform/debian/Makefile debs/kanidm - name: Upload debs diff --git a/.github/workflows/docker_build_kanidmd.yml b/.github/workflows/docker_build_kanidmd.yml index bffb71107..617746fc1 100644 --- a/.github/workflows/docker_build_kanidmd.yml +++ b/.github/workflows/docker_build_kanidmd.yml @@ -19,6 +19,24 @@ jobs: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + # images: | + # kanidm/kanidmd + # ghcr.io/username/app + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - name: Build kanidmd uses: docker/build-push-action@v5 with: diff --git a/.github/workflows/kanidm_book.yml b/.github/workflows/kanidm_book.yml index e29062fd8..32a7000e2 100644 --- a/.github/workflows/kanidm_book.yml +++ b/.github/workflows/kanidm_book.yml @@ -85,8 +85,6 @@ jobs: # yamllint disable-line rule:line-length if: ${{ github.ref == 'refs/heads/master' && github.repository == 'kanidm/kanidm' }} steps: - - name: Setup Pages - uses: actions/configure-pages@v4 - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -100,7 +98,7 @@ jobs: - name: Download individual artifact uses: actions/download-artifact@v4 with: - name: individual + name: ${{ needs.pre_deploy.outputs.latest}} path: ./docs/ env: ACTIONS_RUNNER_DEBUG: true @@ -124,11 +122,14 @@ jobs: rm docs/*.tar.gz env: ACTIONS_RUNNER_DEBUG: true + - name: Setup Pages + uses: actions/configure-pages@v4 - name: Upload pages artifacts uses: actions/upload-pages-artifact@v3 with: # Upload entire repository path: 'docs/' + - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 diff --git a/platform/debian/Makefile b/platform/debian/Makefile index 6b5b60ada..f124b5964 100644 --- a/platform/debian/Makefile +++ b/platform/debian/Makefile @@ -1,4 +1,4 @@ -ARCH ?= $(dpkg --print-architecture) +ARCH ?= $(shell dpkg --print-architecture) .DEFAULT: help diff --git a/platform/debian/build_kanidm.sh b/platform/debian/build_kanidm.sh index 3bc247587..111f42625 100755 --- a/platform/debian/build_kanidm.sh +++ b/platform/debian/build_kanidm.sh @@ -8,10 +8,11 @@ if [ -z "${ARCH}" ]; then ARCH="$(dpkg --print-architecture)" fi -if [ "${ARCH}" -ne "$(dpkg --print-architecture)" ]; then - echo "${ARCH} -ne $(dpkg --print-architecture), cross-compiling!" +if [ "${ARCH}" != "$(dpkg --print-architecture)" ]; then + echo "${ARCH} != $(dpkg --print-architecture), cross-compiling!" export PKG_CONFIG_ALLOW_CROSS=1 - +else + echo "Building for ${ARCH}" fi @@ -29,12 +30,16 @@ fi echo "Building ${PACKAGE}" -if [ -n "${GITHUB_WORKSPACE}" ]; then - SOURCE_DIR="${GITHUB_WORKSPACE}" -else - SOURCE_DIR="${HOME}/kanidm" +SOURCE_DIR="$(cargo metadata --format-version 1 | jq -r .workspace_root)" + +echo "Source dir ${SOURCE_DIR}" + +if [ ! -d "${SOURCE_DIR}" ]; then + echo "Can't find source dir ${SOURCE_DIR}!" + exit 1 fi -BUILD_DIR="$HOME/build" + +BUILD_DIR="$(mktemp -d)" if [ -z "${SKIP_DEPS}" ]; then PACKAGING=1 ./scripts/install_ubuntu_dependencies.sh @@ -42,14 +47,22 @@ else echo "SKIP_DEPS configured, skipping install of rust and packages" fi -#shellcheck disable=SC1091 -source "$HOME/.cargo/env" +if [ -f "${HOME}/.cargo/env" ]; then + # shellcheck disable=SC1091 + source "${HOME}/.cargo/env" +else + echo "Couldn't find cargo env in ${HOME}/.cargo/env that seems weird?" +fi # if we can't find cargo then need to update the path if [ "$(which cargo | wc -l)" -eq 0 ]; then if echo "$PATH" | grep -q '.cargo/bin'; then echo "Updating path to include local cargo dir" export PATH="$HOME/.cargo/bin:$PATH" + if [ "$(which cargo | wc -l)" -eq 0 ]; then + echo "Still couldn't find cargo, bailing!" + exit 1 + fi fi fi @@ -73,14 +86,16 @@ echo "Package Version: ${PACKAGE_VERSION}" echo "Updating package dir" rm -rf "${BUILD_DIR:?}/*" -echo "Copying source files to ${BUILD_DIR}" +echo "Copying source files from ${SOURCE_DIR} to ${BUILD_DIR}" rsync -a \ --exclude target \ - "${SOURCE_DIR}" \ + "${SOURCE_DIR}/" \ "${BUILD_DIR}/" echo "Copying the debian-specific build files" -cd "${BUILD_DIR}/kanidm" +cd "${BUILD_DIR}" +pwd +ls -la rm -rf debian && mkdir -p debian cp -R platform/debian/packaging/* debian/ diff --git a/platform/debian/kanidm-unixd/control b/platform/debian/kanidm-unixd/control index 24e1cda58..0f5683375 100644 --- a/platform/debian/kanidm-unixd/control +++ b/platform/debian/kanidm-unixd/control @@ -10,5 +10,5 @@ Rules-Requires-Root: no Package: kanidm-unixd Architecture: any -Depends: +Depends: tpm-udev Description: Kanidm Unix Tools diff --git a/scripts/install_ubuntu_dependencies.sh b/scripts/install_ubuntu_dependencies.sh index 5d76cb769..03826eb7a 100755 --- a/scripts/install_ubuntu_dependencies.sh +++ b/scripts/install_ubuntu_dependencies.sh @@ -18,6 +18,7 @@ ${SUDOCMD} apt-get install -y \ rsync \ git \ build-essential \ + jq if [ -z "${PACKAGING}" ]; then PACKAGING=0 diff --git a/unix_integration/src/client_sync.rs b/unix_integration/src/client_sync.rs index 99805f845..094650be3 100644 --- a/unix_integration/src/client_sync.rs +++ b/unix_integration/src/client_sync.rs @@ -15,7 +15,10 @@ impl DaemonClientBlocking { let stream = UnixStream::connect(path) .map_err(|e| { - error!("stream setup error -> {:?}", e); + error!( + "Unix socket stream setup error while connecting to {} -> {:?}", + path, e + ); e }) .map_err(Box::new)?; @@ -38,14 +41,20 @@ impl DaemonClientBlocking { match self.stream.set_read_timeout(Some(timeout)) { Ok(()) => {} Err(e) => { - error!("stream setup error -> {:?}", e); + error!( + "Unix socket stream setup error while setting read timeout -> {:?}", + e + ); return Err(Box::new(e)); } }; match self.stream.set_write_timeout(Some(timeout)) { Ok(()) => {} Err(e) => { - error!("stream setup error -> {:?}", e); + error!( + "Unix socket stream setup error while setting write timeout -> {:?}", + e + ); return Err(Box::new(e)); } };