mirror of
				https://github.com/XRPLF/clio.git
				synced 2025-11-04 03:45:50 +00:00 
			
		
		
		
	feat: Generate Debian packages with CPack (#2282)
Builds the Linux packages with CPack. Generate them by running Conan with `--options:host "&:package=True" --options:host "&:static=True"` then after the build you can run `cpack .` in the build directory. @mathbunnyru Where do you think this should be built? QA needs a package per-commit. @godexsoft What to do with the `config.json` and service file. I can just remove them or strip the comment out but it still won't work out the box with the default `rippled.cfg`. Relates to #2191. --------- Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										6
									
								
								.github/actions/generate/action.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/actions/generate/action.yml
									
									
									
									
										vendored
									
									
								
							@@ -37,6 +37,10 @@ inputs:
 | 
			
		||||
    description: Whether to use mold linker
 | 
			
		||||
    required: true
 | 
			
		||||
    default: "false"
 | 
			
		||||
  package:
 | 
			
		||||
    description: Whether to generate Debian package
 | 
			
		||||
    required: true
 | 
			
		||||
    default: "false"
 | 
			
		||||
 | 
			
		||||
runs:
 | 
			
		||||
  using: composite
 | 
			
		||||
@@ -55,6 +59,7 @@ runs:
 | 
			
		||||
        BENCHMARK_OPTION: "${{ inputs.build_benchmark == 'true' && 'True' || 'False' }}"
 | 
			
		||||
        TIME_TRACE: "${{ inputs.time_trace == 'true' && 'True' || 'False' }}"
 | 
			
		||||
        USE_MOLD: "${{ inputs.use_mold == 'true' && 'True' || 'False' }}"
 | 
			
		||||
        PACKAGE: "${{ inputs.package == 'true' && 'True' || 'False' }}"
 | 
			
		||||
      run: |
 | 
			
		||||
        cd build
 | 
			
		||||
        conan \
 | 
			
		||||
@@ -70,6 +75,7 @@ runs:
 | 
			
		||||
          -o "&:coverage=${CODE_COVERAGE}" \
 | 
			
		||||
          -o "&:time_trace=${TIME_TRACE}" \
 | 
			
		||||
          -o "&:use_mold=${USE_MOLD}" \
 | 
			
		||||
          -o "&:package=${PACKAGE}" \
 | 
			
		||||
          --profile:all "${{ inputs.conan_profile }}"
 | 
			
		||||
 | 
			
		||||
    - name: Run cmake
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@@ -85,6 +85,23 @@ jobs:
 | 
			
		||||
    secrets:
 | 
			
		||||
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
 | 
			
		||||
 | 
			
		||||
  package:
 | 
			
		||||
    name: Build packages
 | 
			
		||||
 | 
			
		||||
    uses: ./.github/workflows/build_impl.yml
 | 
			
		||||
    with:
 | 
			
		||||
      runs_on: heavy
 | 
			
		||||
      container: '{ "image": "ghcr.io/xrplf/clio-ci:8ad111655c4d04bfedb7e7cb3bbfba6d4204852d" }'
 | 
			
		||||
      conan_profile: gcc
 | 
			
		||||
      build_type: Release
 | 
			
		||||
      disable_cache: false
 | 
			
		||||
      code_coverage: false
 | 
			
		||||
      static: true
 | 
			
		||||
      upload_clio_server: false
 | 
			
		||||
      package: true
 | 
			
		||||
      targets: package
 | 
			
		||||
      analyze_build_time: false
 | 
			
		||||
 | 
			
		||||
  check_config:
 | 
			
		||||
    name: Check Config Description
 | 
			
		||||
    needs: build-and-test
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								.github/workflows/build_and_test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.github/workflows/build_and_test.yml
									
									
									
									
										vendored
									
									
								
							@@ -63,6 +63,12 @@ on:
 | 
			
		||||
        type: string
 | 
			
		||||
        default: ""
 | 
			
		||||
 | 
			
		||||
      package:
 | 
			
		||||
        description: Whether to generate Debian package
 | 
			
		||||
        required: false
 | 
			
		||||
        type: boolean
 | 
			
		||||
        default: false
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
    uses: ./.github/workflows/build_impl.yml
 | 
			
		||||
@@ -78,6 +84,7 @@ jobs:
 | 
			
		||||
      targets: ${{ inputs.targets }}
 | 
			
		||||
      analyze_build_time: false
 | 
			
		||||
      expected_version: ${{ inputs.expected_version }}
 | 
			
		||||
      package: ${{ inputs.package }}
 | 
			
		||||
 | 
			
		||||
  test:
 | 
			
		||||
    needs: build
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								.github/workflows/build_impl.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								.github/workflows/build_impl.yml
									
									
									
									
										vendored
									
									
								
							@@ -59,6 +59,11 @@ on:
 | 
			
		||||
        type: string
 | 
			
		||||
        default: ""
 | 
			
		||||
 | 
			
		||||
      package:
 | 
			
		||||
        description: Whether to generate Debian package
 | 
			
		||||
        required: false
 | 
			
		||||
        type: boolean
 | 
			
		||||
 | 
			
		||||
    secrets:
 | 
			
		||||
      CODECOV_TOKEN:
 | 
			
		||||
        required: false
 | 
			
		||||
@@ -111,6 +116,7 @@ jobs:
 | 
			
		||||
          static: ${{ inputs.static }}
 | 
			
		||||
          time_trace: ${{ inputs.analyze_build_time }}
 | 
			
		||||
          use_mold: ${{ runner.os != 'macOS' }}
 | 
			
		||||
          package: ${{ inputs.package }}
 | 
			
		||||
 | 
			
		||||
      - name: Build Clio
 | 
			
		||||
        uses: ./.github/actions/build_clio
 | 
			
		||||
@@ -158,19 +164,26 @@ jobs:
 | 
			
		||||
          path: build/clio_server
 | 
			
		||||
 | 
			
		||||
      - name: Upload clio_tests
 | 
			
		||||
        if: ${{ !inputs.code_coverage && !inputs.analyze_build_time }}
 | 
			
		||||
        if: ${{ !inputs.code_coverage && !inputs.analyze_build_time && !inputs.package }}
 | 
			
		||||
        uses: actions/upload-artifact@v4
 | 
			
		||||
        with:
 | 
			
		||||
          name: clio_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
 | 
			
		||||
          path: build/clio_tests
 | 
			
		||||
 | 
			
		||||
      - name: Upload clio_integration_tests
 | 
			
		||||
        if: ${{ !inputs.code_coverage && !inputs.analyze_build_time }}
 | 
			
		||||
        if: ${{ !inputs.code_coverage && !inputs.analyze_build_time && !inputs.package }}
 | 
			
		||||
        uses: actions/upload-artifact@v4
 | 
			
		||||
        with:
 | 
			
		||||
          name: clio_integration_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
 | 
			
		||||
          path: build/clio_integration_tests
 | 
			
		||||
 | 
			
		||||
      - name: Upload Clio Linux package
 | 
			
		||||
        if: inputs.package
 | 
			
		||||
        uses: actions/upload-artifact@v4
 | 
			
		||||
        with:
 | 
			
		||||
          name: clio_deb_package_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
 | 
			
		||||
          path: build/*.deb
 | 
			
		||||
 | 
			
		||||
      - name: Save cache
 | 
			
		||||
        if: ${{ !inputs.disable_cache && github.ref == 'refs/heads/develop' }}
 | 
			
		||||
        uses: ./.github/actions/save_cache
 | 
			
		||||
 
 | 
			
		||||
@@ -94,8 +94,8 @@ if (docs)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
include(install/install)
 | 
			
		||||
if (packaging)
 | 
			
		||||
  include(cmake/packaging.cmake) # This file exists only in build runner
 | 
			
		||||
if (package)
 | 
			
		||||
  include(ClioPackage)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
if (snapshot)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								cmake/ClioPackage.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								cmake/ClioPackage.cmake
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
include("${CMAKE_CURRENT_LIST_DIR}/ClioVersion.cmake")
 | 
			
		||||
 | 
			
		||||
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/clio")
 | 
			
		||||
set(CPACK_PACKAGE_VERSION "${CLIO_VERSION}")
 | 
			
		||||
set(CPACK_STRIP_FILES TRUE)
 | 
			
		||||
 | 
			
		||||
include(pkg/deb)
 | 
			
		||||
include(CPack)
 | 
			
		||||
@@ -1,17 +0,0 @@
 | 
			
		||||
[Unit]
 | 
			
		||||
Description=Clio XRPL API server
 | 
			
		||||
Documentation=https://github.com/XRPLF/clio.git
 | 
			
		||||
 | 
			
		||||
After=network-online.target
 | 
			
		||||
Wants=network-online.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
Type=simple
 | 
			
		||||
ExecStart=@CLIO_INSTALL_DIR@/bin/clio_server @CLIO_INSTALL_DIR@/etc/config.json
 | 
			
		||||
Restart=on-failure
 | 
			
		||||
User=clio
 | 
			
		||||
Group=clio
 | 
			
		||||
LimitNOFILE=65536
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
@@ -1,13 +1,13 @@
 | 
			
		||||
set(CLIO_INSTALL_DIR "/opt/clio")
 | 
			
		||||
set(CMAKE_INSTALL_PREFIX ${CLIO_INSTALL_DIR})
 | 
			
		||||
set(CMAKE_INSTALL_PREFIX "${CLIO_INSTALL_DIR}" CACHE PATH "Install prefix" FORCE)
 | 
			
		||||
 | 
			
		||||
install(TARGETS clio_server DESTINATION bin)
 | 
			
		||||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
 | 
			
		||||
 | 
			
		||||
include(GNUInstallDirs)
 | 
			
		||||
 | 
			
		||||
install(TARGETS clio_server DESTINATION ${CMAKE_INSTALL_BINDIR})
 | 
			
		||||
 | 
			
		||||
file(READ docs/examples/config/example-config.json config)
 | 
			
		||||
string(REGEX REPLACE "./clio_log" "/var/log/clio/" config "${config}")
 | 
			
		||||
file(WRITE ${CMAKE_BINARY_DIR}/install-config.json "${config}")
 | 
			
		||||
install(FILES ${CMAKE_BINARY_DIR}/install-config.json DESTINATION etc RENAME config.json)
 | 
			
		||||
 | 
			
		||||
configure_file("${CMAKE_SOURCE_DIR}/cmake/install/clio.service.in" "${CMAKE_BINARY_DIR}/clio.service")
 | 
			
		||||
 | 
			
		||||
install(FILES "${CMAKE_BINARY_DIR}/clio.service" DESTINATION /lib/systemd/system)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								cmake/pkg/deb.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								cmake/pkg/deb.cmake
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
set(CPACK_GENERATOR "DEB")
 | 
			
		||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/XRPLF/clio")
 | 
			
		||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Ripple Labs Inc. <support@ripple.com>")
 | 
			
		||||
 | 
			
		||||
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
 | 
			
		||||
 | 
			
		||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
 | 
			
		||||
 | 
			
		||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_SOURCE_DIR}/cmake/pkg/postinst)
 | 
			
		||||
 | 
			
		||||
# We must replace "-" with "~" otherwise dpkg will sort "X.Y.Z-b1" as greater than "X.Y.Z"
 | 
			
		||||
string(REPLACE "-" "~" git "${CPACK_PACKAGE_VERSION}")
 | 
			
		||||
							
								
								
									
										46
									
								
								cmake/pkg/postinst
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										46
									
								
								cmake/pkg/postinst
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
USER_NAME=clio
 | 
			
		||||
GROUP_NAME="${USER_NAME}"
 | 
			
		||||
CLIO_EXECUTABLE="clio_server"
 | 
			
		||||
CLIO_PREFIX="/opt/clio"
 | 
			
		||||
CLIO_BIN="$CLIO_PREFIX/bin/${CLIO_EXECUTABLE}"
 | 
			
		||||
CLIO_CONFIG="$CLIO_PREFIX/etc/config.json"
 | 
			
		||||
 | 
			
		||||
case "$1" in
 | 
			
		||||
    configure)
 | 
			
		||||
        if ! id -u "$USER_NAME" >/dev/null 2>&1; then
 | 
			
		||||
            # Users who should not have a home directory should have their home directory set to /nonexistent
 | 
			
		||||
            # https://www.debian.org/doc/debian-policy/ch-opersys.html#non-existent-home-directories
 | 
			
		||||
            useradd \
 | 
			
		||||
                --system \
 | 
			
		||||
                --home-dir /nonexistent \
 | 
			
		||||
                --no-create-home \
 | 
			
		||||
                --shell /usr/sbin/nologin \
 | 
			
		||||
                --comment "system user for ${CLIO_EXECUTABLE}" \
 | 
			
		||||
                --user-group \
 | 
			
		||||
                ${USER_NAME}
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
        install -d -o "$USER_NAME" -g "$GROUP_NAME" /var/log/clio
 | 
			
		||||
 | 
			
		||||
        if [ -f "$CLIO_CONFIG" ]; then
 | 
			
		||||
            chown "$USER_NAME:$GROUP_NAME" "$CLIO_CONFIG"
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
        chown -R "$USER_NAME:$GROUP_NAME" "$CLIO_PREFIX"
 | 
			
		||||
 | 
			
		||||
        ln -sf "$CLIO_BIN" "/usr/bin/${CLIO_EXECUTABLE}"
 | 
			
		||||
 | 
			
		||||
        ;;
 | 
			
		||||
    abort-upgrade|abort-remove|abort-deconfigure)
 | 
			
		||||
        ;;
 | 
			
		||||
    *)
 | 
			
		||||
        echo "postinst called with unknown argument \`$1'" >&2
 | 
			
		||||
        exit 1
 | 
			
		||||
        ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
exit 0
 | 
			
		||||
@@ -16,7 +16,7 @@ class ClioConan(ConanFile):
 | 
			
		||||
        'integration_tests': [True, False],   # build integration tests; create `clio_integration_tests` binary
 | 
			
		||||
        'benchmark': [True, False],           # build benchmarks; create `clio_benchmarks` binary
 | 
			
		||||
        'docs': [True, False],                # doxygen API docs; create custom target 'docs'
 | 
			
		||||
        'packaging': [True, False],           # create distribution packages
 | 
			
		||||
        'package': [True, False],             # create distribution packages
 | 
			
		||||
        'coverage': [True, False],            # build for test coverage report; create custom target `clio_tests-ccov`
 | 
			
		||||
        'lint': [True, False],                # run clang-tidy checks during compilation
 | 
			
		||||
        'snapshot': [True, False],            # build export/import snapshot tool
 | 
			
		||||
@@ -43,7 +43,7 @@ class ClioConan(ConanFile):
 | 
			
		||||
        'tests': False,
 | 
			
		||||
        'integration_tests': False,
 | 
			
		||||
        'benchmark': False,
 | 
			
		||||
        'packaging': False,
 | 
			
		||||
        'package': False,
 | 
			
		||||
        'coverage': False,
 | 
			
		||||
        'lint': False,
 | 
			
		||||
        'docs': False,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user