This commit is contained in:
Ahmed Messaoud 2024-02-07 22:42:30 +00:00
Родитель 3998f7f249
Коммит 44825bb431
18 изменённых файлов: 129 добавлений и 249 удалений

9
.github/actions/footprint-check/action.yml поставляемый
Просмотреть файл

@ -11,6 +11,10 @@ inputs:
arch:
description: The architecture of the binary
required: true
package-type:
description: The type of package (deb | rpm).
type: string
required: true
runs:
using: composite
@ -23,6 +27,7 @@ runs:
run: |
distroName=${{ inputs.distroName }}
arch=${{ inputs.arch }}
packageType=$(echo ${{ inputs.package-type }} | awk '{print tolower($0)}')
# Normalize distro name
case $distroName in
@ -30,6 +35,7 @@ runs:
("ubuntu20.04") distroName="ubuntu-20.04";;
("ubuntu22.04") distroName="ubuntu-22.04";;
("debian9") distroName="debian-9";;
("mariner2") distroName="mariner-2";;
esac
# Normalize architecture
@ -41,6 +47,7 @@ runs:
echo "distroName=${distroName}" >> $GITHUB_OUTPUT
echo "arch=${arch}" >> $GITHUB_OUTPUT
echo "packageType=${packageType}" >> $GITHUB_OUTPUT
shell: bash
- name: Footprint delta validation
@ -51,7 +58,7 @@ runs:
remoteSize=`echo $target | jq .sizeBytes | tr -d \"`
# Get local file
file=$(find ./build -name "*.deb" | head -n 1)
file=$(find ./build -name "*.${{ steps.normalize-distro-arch.outputs.packageType }}" | head -n 1)
echo Using $file
localSize=$(wc -c $file | awk '{print $1}')

6
.github/actions/sign-package/action.yml поставляемый
Просмотреть файл

@ -5,6 +5,9 @@ inputs:
artifact:
description: The artifact containing packages to sign
required: true
package-type:
description: The type of package to sign (deb | rpm)
required: true
runs:
using: composite
@ -33,7 +36,8 @@ runs:
opcode = os.environ['LINUX_OP_CODE'].strip()
source_location = 'unsigned'
files = glob.glob(os.path.join(source_location, "*.deb"))
package_filter = '*.${{ inputs.package-type }}'
files = glob.glob(os.path.join(source_location, package_filter.lower()))
print("Found files:")
pprint.pp(files)

14
.github/workflows/ci.yml поставляемый
Просмотреть файл

@ -1,6 +1,7 @@
name: CI
on: [pull_request]
on:
pull_request:
env:
BUILD_TYPE: Release
@ -14,13 +15,18 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, debian-10, debian-11]
# os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, debian-10, debian-11, mariner-2]
os: [mariner-2]
arch: [arm, arm64, amd64]
exclude:
- os: ubuntu-22.04
arch: arm
arch: arm
- os: ubuntu-22.04
arch: arm64
- os: mariner-2
arch: arm
- os: mariner-2
arch: arm64
steps:
- uses: actions/checkout@v3
@ -49,7 +55,7 @@ jobs:
container: ${{ steps.container.outputs.id }}
cmd: |
mkdir build && cd build
cmake ../src -DCMAKE_build-type=${{ env.BUILD_TYPE }} -Duse_prov_client=ON -Dhsm_type_symm_key=ON -DCOMPILE_WITH_STRICTNESS=ON -DBUILD_TESTS=ON -DBUILD_SAMPLES=ON -DBUILD_ADAPTERS=ON -G Ninja
cmake ../src -DCMAKE_build-type=${{ env.BUILD_TYPE }} -Duse_prov_client=ON -Dhsm_type_symm_key=ON -DCOMPILE_WITH_STRICTNESS=ON -DBUILD_TESTS=ON -DBUILD_SAMPLES=ON -DBUILD_ADAPTERS=ON ${{ matrix.os == 'mariner-2' && '-Duse_default_uuid=ON' || '' }} -G Ninja
- name: Build azure-osconfig
uses: ./.github/actions/container-exec

25
.github/workflows/insiders-fast.yml поставляемый
Просмотреть файл

@ -1,9 +1,9 @@
name: Publish (insiders-fast)
on:
workflow_dispatch: # TODO: Remove before checkin
schedule:
- cron: '0 8 * * *' # Every day at 8am UTC (12am PST)
workflow_dispatch:
jobs:
changes:
@ -33,19 +33,26 @@ jobs:
matrix:
target:
[
{ os: ubuntu, version: 18.04, dist: bionic },
{ os: ubuntu, version: 20.04, dist: focal },
{ os: ubuntu, version: 22.04, dist: jammy },
{ os: debian, version: 10, dist: buster },
{ os: debian, version: 11, dist: bullseye },
# { os: ubuntu, version: 18.04, dist: bionic, package-type: DEB, repo: microsoft-ubuntu-bionic-prod-apt },
# { os: ubuntu, version: 20.04, dist: focal, package-type: DEB, repo: microsoft-ubuntu-focal-prod-apt },
# { os: ubuntu, version: 22.04, dist: jammy, package-type: DEB, repo: microsoft-ubuntu-jammy-prod-apt },
# { os: debian, version: 10, dist: buster, package-type: DEB, repo: microsoft-debian-buster-prod-apt },
# { os: debian, version: 11, dist: bullseye, package-type: DEB, repo: microsoft-debian-bullseye-prod-apt },
{ os: mariner, version: 2, dist: azurelinux, package-type: RPM, repo: cbl-mariner-2.0-preview-Microsoft-x86_64-yum },
]
arch: [arm, arm64, amd64]
exclude:
- target: { os: ubuntu, version: 22.04, dist: jammy }
- target: { os: ubuntu, version: 22.04, dist: jammy, package-type: DEB, repo: microsoft-ubuntu-jammy-prod-apt }
arch: arm
- target: { os: mariner, version: 2, dist: azurelinux, package-type: RPM, repo: cbl-mariner-2.0-preview-Microsoft-x86_64-yum }
arch: arm
- target: { os: mariner, version: 2, dist: azurelinux, package-type: RPM, repo: cbl-mariner-2.0-preview-Microsoft-x86_64-yum }
arch: arm64
with:
target: ${{ matrix.target.os }}-${{ matrix.target.version }}
arch: ${{ matrix.arch }}
repo: microsoft-${{ matrix.target.os }}-${{ matrix.target.dist }}-prod-apt
dist: insiders-fast
repo: ${{ matrix.repo }}
dist: ${{ matrix.dist }}
channel: insiders-fast
package-type: ${{ matrix.target.package-type }}
secrets: inherit

13
.github/workflows/package-build.yml поставляемый
Просмотреть файл

@ -21,6 +21,10 @@ on:
description: The architecture to build for.
type: string
required: true
package-type:
description: The type of package to build (deb | rpm).
type: string
required: true
test:
description: Include test collateral in the artifact.
type: boolean
@ -75,7 +79,7 @@ jobs:
container: ${{ steps.container.outputs.id }}
working-directory: ${{ env.MOUNT }}/build
cmd: |
cmake ../src -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DTWEAK_VERSION=${{ steps.version.outputs.tweak }} -Duse_prov_client=ON -Dhsm_type_symm_key=ON -DCOMPILE_WITH_STRICTNESS=ON -DBUILD_TESTS=OFF -DBUILD_MODULETEST=ON -DBUILD_SAMPLES=OFF -DBUILD_ADAPTERS=ON -G Ninja
cmake ../src -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DTWEAK_VERSION=${{ steps.version.outputs.tweak }} -Duse_prov_client=ON -Dhsm_type_symm_key=ON -DCOMPILE_WITH_STRICTNESS=ON -DBUILD_TESTS=OFF -DBUILD_MODULETEST=ON -DBUILD_SAMPLES=OFF ${{ inputs.target == 'mariner-2' && '-Duse_default_uuid=ON' || '' }} -DBUILD_ADAPTERS=ON -G Ninja
- name: Build azure-osconfig
uses: ./.github/actions/container-exec
@ -89,7 +93,7 @@ jobs:
with:
container: ${{ steps.container.outputs.id }}
working-directory: ${{ env.MOUNT }}/build
cmd: cpack -G DEB
cmd: cpack -G ${{ inputs.package-type }}
- name: Binary footprint delta validation
uses: ./.github/actions/footprint-check
@ -97,13 +101,14 @@ jobs:
allowedDelta: 10
distroName: ${{ matrix.os }}
arch: ${{ matrix.variant.arch }}
package-type: ${{ inputs.package-type }}
- uses: actions/upload-artifact@v3
if: ${{ inputs.test }}
with:
name: ${{ inputs.artifact }}
path: |
./build/osconfig_*
./build/osconfig*
./build/modules/test/moduletest
./build/modules/bin/*.so
@ -111,4 +116,4 @@ jobs:
if: ${{ !inputs.test }}
with:
name: ${{ inputs.artifact }}
path: ./build/osconfig_*
path: ./build/osconfig*

4
.github/workflows/package-publish.yml поставляемый
Просмотреть файл

@ -6,7 +6,7 @@ on:
repo:
required: true
type: string
dist:
channel:
required: true
type: string
artifact:
@ -51,7 +51,7 @@ jobs:
- name: Update repo
uses: ./.github/actions/pmc
with:
command: repo package update --add-packages ${{ steps.upload.outputs.result }} ${{ inputs.repo }} ${{ inputs.dist }}
command: repo package update --add-packages ${{ steps.upload.outputs.result }} ${{ inputs.repo }} ${{ inputs.channel }}
- name: Publish package
uses: ./.github/actions/pmc

10
.github/workflows/package-sign.yml поставляемый
Просмотреть файл

@ -7,6 +7,13 @@ on:
description: The artifact containing the packages to be signed.
type: string
required: true
key-code:
description: The signing key-code to use.
type: string
required: true
package-type:
type: string
required: true
jobs:
sign:
@ -37,7 +44,8 @@ jobs:
uses: ./.github/actions/sign-package
env:
AAD_ID: ${{ secrets.ESRP_AAD_ID }}
LINUX_KEY_CODE: ${{ secrets.ESRP_LINUX_KEY_CODE }}
LINUX_KEY_CODE: ${{ inputs.key-code }}
LINUX_OP_CODE: ${{ secrets.ESRP_LINUX_OP_CODE }}
with:
artifact: ${{ inputs.artifact }}
package-type: ${{ inputs.package-type }}

13
.github/workflows/prod.yml поставляемый
Просмотреть файл

@ -13,21 +13,22 @@ jobs:
matrix:
target:
[
{ os: ubuntu, version: 18.04, dist: bionic },
{ os: ubuntu, version: 20.04, dist: focal },
{ os: ubuntu, version: 22.04, dist: jammy },
{ os: debian, version: 10, dist: buster },
{ os: debian, version: 11, dist: bullseye },
{ os: ubuntu, version: 18.04, dist: bionic, package-type: DEB },
{ os: ubuntu, version: 20.04, dist: focal, package-type: DEB },
{ os: ubuntu, version: 22.04, dist: jammy, package-type: DEB },
{ os: debian, version: 10, dist: buster, package-type: DEB },
{ os: debian, version: 11, dist: bullseye, package-type: DEB },
]
arch: [arm, arm64, amd64]
exclude:
- target: { os: ubuntu, version: 22.04, dist: jammy }
- target: { os: ubuntu, version: 22.04, dist: jammy, package-type: DEB }
arch: arm
with:
target: ${{ matrix.target.os }}-${{ matrix.target.version }}
arch: ${{ matrix.arch }}
repo: microsoft-${{ matrix.target.os }}-${{ matrix.target.dist }}-prod-apt
dist: ${{ matrix.target.dist }}
package-type: ${{ matrix.target.package-type }}
secrets: inherit
release:

13
.github/workflows/publish.yml поставляемый
Просмотреть файл

@ -9,10 +9,16 @@ on:
arch:
type: string
required: true
dist:
type: string
required: true
repo:
type: string
required: true
dist:
channel:
type: string
required: true
package-type:
type: string
required: true
@ -23,6 +29,7 @@ jobs:
target: ${{ inputs.target }}
arch: ${{ inputs.arch }}
artifact: ${{ inputs.target }}-${{ inputs.arch }}
package-type: ${{ inputs.package-type }}
release: true
sign:
@ -30,6 +37,8 @@ jobs:
needs: package
with:
artifact: ${{ inputs.target }}-${{ inputs.arch }}
key-code: ${{ inputs.dist == 'azurelinux' && 'CP-459159-Pgp' || 'CP-450779-Pgp' }}
package-type: ${{ inputs.package-type }}
secrets: inherit
publish:
@ -37,6 +46,6 @@ jobs:
needs: sign
with:
repo: ${{ inputs.repo }}
dist: ${{ inputs.dist }}
channel: ${{ inputs.channel }}
artifact: ${{ inputs.target }}-${{ inputs.arch }}-signed
secrets: inherit

Просмотреть файл

@ -1,102 +1,3 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# DO NOT EDIT osconfig.spec directly, changes are overwritten by osconfig.spec.in
Summary: @LONG_PROJECT_NAME@
Name: @PROJECT_NAME@
Version: @CPACK_PACKAGE_VERSION@
Release: 1%{?dist}
Source0: %{name}-%{version}-Source.tar.gz
License: MIT
Group: Applications/File
URL: https://mscodehub.visualstudio.com/AzOsConfig
Vendor: Microsoft
Distribution: Mariner
BuildRequires: cmake
BuildRequires: build-essential
BuildRequires: tar
BuildRequires: gcc
BuildRequires: gtest
BuildRequires: gtest-devel
BuildRequires: gmock
BuildRequires: gmock-devel
BuildRequires: azure-iot-sdk-c
BuildRequires: curl
BuildRequires: openssl
BuildRequires: rapidjson
%description
@LONG_PROJECT_NAME@
%prep
%setup -c
%build
pwd
cd %{name}-%{version}-Source
mkdir build
pushd build
cmake .. -Duse_prov_client=ON -Dhsm_type_symm_key=ON -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/
cmake --build .
popd
%install
pwd
cd %{name}-%{version}-Source
cd build
ls .
echo %{buildroot}
make install DESTDIR=%{buildroot}
ls -lR %{buildroot}
%clean
rm -rf $RPM_BUILD_ROOT
%preun
%systemd_preun osconfig.service
%systemd_preun osconfig-platform.service
%post
if [ ! -e /etc/aziot/identityd/config.d/osconfig.toml ]; then
mkdir -p /etc/aziot/identityd/config.d
cp /etc/osconfig/osconfig.toml /etc/aziot/identityd/config.d/
fi
%systemd_post osconfig-platform.service
%systemd_post osconfig.service
systemctl enable osconfig-platform.service
systemctl start osconfig-platform.service
systemctl enable osconfig.service
systemctl start osconfig.service
%postun
%systemd_postun osconfig.service
%systemd_postun osconfig-platform.service
rm /etc/aziot/identityd/config.d/osconfig.toml >/dev/null || true
%files
%defattr(-, root, root, -)
%{_bindir}/osconfig
%{_bindir}/osconfig-platform
/etc/osconfig/osconfig.conn
/etc/osconfig/osconfig.json
/etc/osconfig/osconfig.toml
/etc/systemd/system/osconfig.service
/etc/systemd/system/osconfig-platform.service
/usr/lib/osconfig/adhs.so
/usr/lib/osconfig/commandrunner.so
/usr/lib/osconfig/configuration.so
/usr/lib/osconfig/deliveryoptimization.so
/usr/lib/osconfig/deviceinfo.so
/usr/lib/osconfig/firewall.so
/usr/lib/osconfig/hostname.so
/usr/lib/osconfig/networking.so
/usr/lib/osconfig/pmc.so
/usr/lib/osconfig/tpm.so
/usr/lib/osconfig/ztsi.so
% changelog
* Fri Jan 27 2023 OSConfig Core Team <osconfigcore@microsoft.com> 1.0.5.20230127
- Documentation updates
- Moduletest fixes and refactoring

12
devops/rpm/postinst Executable file
Просмотреть файл

@ -0,0 +1,12 @@
# postinst script for osconfig
#
if [ ! -e /etc/aziot/identityd/config.d/osconfig.toml ]; then
mkdir -p /etc/aziot/identityd/config.d
cp /etc/osconfig/osconfig.toml /etc/aziot/identityd/config.d/
fi
%systemd_post osconfig-platform.service
%systemd_post osconfig.service
systemctl enable osconfig-platform.service
systemctl start osconfig-platform.service
systemctl enable osconfig.service
systemctl start osconfig.service

5
devops/rpm/postun Executable file
Просмотреть файл

@ -0,0 +1,5 @@
# post-uninstall script for osconfig
#
%systemd_postun osconfig.service
%systemd_postun osconfig-platform.service
rm /etc/aziot/identityd/config.d/osconfig.toml >/dev/null || true

4
devops/rpm/preun Executable file
Просмотреть файл

@ -0,0 +1,4 @@
# pre-uninstall script for osconfig
#
%systemd_preun osconfig.service
%systemd_preun osconfig-platform.service

Просмотреть файл

@ -69,6 +69,7 @@ set(OsConfigProjectName "osconfig")
set(OsConfigProjectLongName "Azure OSConfig")
set(OsConfigProjectVendor "Microsoft")
set(OsConfigProjectEmail "osconfigsupport@microsoft.com")
set(OsConfigProjectUrl "https://github.com/Azure/azure-osconfig/")
set(OsConfigHashAlgorithm "SHA256")
set(OsConfigVersionString ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}.${CMAKE_PROJECT_VERSION_TWEAK})
set(OsConfigProjectSourceArchiveFileNoExt "${OsConfigProjectName}-${OsConfigVersionString}-Source")
@ -111,13 +112,13 @@ if (BUILD_MODULES)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VENDOR ${OsConfigProjectVendor})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${OsConfigProjectEmail})
# Common packaging
set(CPACK_PACKAGE_NAME ${OsConfigProjectName})
set(CPACK_PACKAGE_HOMEPAGE_URL $(OsConfigProjectUrl))
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OsConfigProjectLongName})
set(CPACK_PACKAGE_VERSION ${OsConfigVersionString})
set(CPACK_PACKAGE_VENDOR ${OsConfigProjectVendor})
@ -135,31 +136,27 @@ set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES ${CPACK_EXCLUDES})
set(CPACK_VERBATIM_VARIABLES YES)
# RPM packaging
# RPM packaging - see /devops/rpm for postinst/postun/preun scripts
set(CPACK_RPM_BUILDREQUIRES "systemd, cmake, build-essential, tar, gcc, gtest, gtest-devel, gmock, gmock-devel, curl-devel, openssl, rapidjson")
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_SOURCE_DIR}/../devops/rpm/changelog")
set(CPACK_RPM_PACKAGE_AUTOREQ 1)
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_NAME ${OsConfigProjectName})
set(CPACK_RPM_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
set(CPACK_RPM_PACKAGE_REQUIRES "")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST ${CPACK_EXCLUDES})
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/../devops/rpm/postinst")
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/../devops/rpm/postun")
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/../devops/rpm/preun")
# Debian packaging - see /debian for postinst/prerm scripts
# Debian packaging - see /devops/debian for postinst/postrm/prerm scripts
# https://www.debian.org/doc/manuals/maint-guide/
set(CPACK_DEBIAN_PACKAGE_NAME ${OsConfigProjectName})
set(CPACK_DEBIAN_PACKAGE_VERSION ${OsConfigVersionString})
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "aziot-identity-service (>= 1.2.0)")
set(CPACK_DEBIAN_PACKAGE_PREDEPENDS "")
set(CPACK_DEBIAN_FILE_NAME ${OsConfigProjectName}_${OsConfigVersionString}_${LSB_RELEASE_CODENAME_SHORT}_${CMAKE_SYSTEM_PROCESSOR}.deb)
set(CPACK_DEBIAN_EXCLUDE_FROM_AUTO_FILELIST ${CPACK_EXCLUDES})
set(CPACK_PACKAGE_VENDOR ${OsConfigProjectVendor})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${OsConfigProjectEmail})
set(CPACK_DEBIAN_FILE_NAME ${OsConfigProjectName}_${OsConfigVersionString}_${LSB_RELEASE_CODENAME_SHORT}_${CMAKE_SYSTEM_PROCESSOR}.deb)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/../devops/debian/postinst;${CMAKE_SOURCE_DIR}/../devops/debian/prerm;${CMAKE_SOURCE_DIR}/../devops/debian/postrm;")
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${OsConfigProjectEmail})
set(CPACK_DEBIAN_PACKAGE_NAME ${OsConfigProjectName})
set(CPACK_DEBIAN_PACKAGE_PREDEPENDS "")
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "aziot-identity-service (>= 1.2.0)")
set(CPACK_DEBIAN_PACKAGE_VERSION ${OsConfigVersionString})
include(CPack)
include(GenerateSourceDistribution)
generate_source_distribution(
NAME ${OsConfigProjectName}
LONG_NAME ${OsConfigProjectLongName}
OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist
SOURCES
"${OsConfigProjectSourceArchiveFile}")

Просмотреть файл

@ -1,52 +0,0 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# GenerateSourceDistribution.cmake
# This CMake script exposes the `generate_source_distribution` function which creates a `dist` target.
# The `dist` target creates the needed files required for building source distributions, see
# GenerateSourceDistribution.cmake for more info.
include(CMakeParseArguments)
function(generate_source_distribution)
cmake_parse_arguments(
PARSED_ARGS # prefix of output variables
"" # list of names of the boolean arguments (only defined ones will be true)
"NAME;LONG_NAME;OUTPUT_DIR" # list of names of mono-valued arguments
"SOURCES" # list of names of multi-valued arguments (output variables are lists)
${ARGN} # arguments of the function to parse, here we take the all original ones
)
if (NOT PARSED_ARGS_NAME)
message(FATAL_ERROR "NAME must be provided.")
endif (NOT PARSED_ARGS_NAME)
if (NOT PARSED_ARGS_LONG_NAME)
message(FATAL_ERROR "LONG_NAME must be provided.")
endif (NOT PARSED_ARGS_LONG_NAME)
if (NOT PARSED_ARGS_OUTPUT_DIR)
message(FATAL_ERROR "OUTPUT_DIR must be provided.")
endif (NOT PARSED_ARGS_OUTPUT_DIR)
if (NOT PARSED_ARGS_SOURCES)
message(FATAL_ERROR "SOURCES must be provided.")
endif (NOT PARSED_ARGS_SOURCES)
set(_NAME ${PARSED_ARGS_NAME})
set(_LONG_NAME ${PARSED_ARGS_LONG_NAME})
set(_OUTPUT_DIR ${PARSED_ARGS_OUTPUT_DIR})
set(_SOURCES ${PARSED_ARGS_SOURCES})
configure_file(
${CMAKE_TEMPLATES_DIR}GenerateSourceDistributionDelegate.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/spec/GenerateSourceDistributionDelegate.cmake
@ONLY)
add_custom_target(dist
COMMAND
"${CMAKE_COMMAND}" --build . --target package_source
COMMAND
"${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/spec/GenerateSourceDistributionDelegate.cmake
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Building source package with specfile"
VERBATIM
)
endfunction(generate_source_distribution)

Просмотреть файл

@ -1,40 +0,0 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# GenerateSourceDistributionDelegate.cmake
# This CMake script creates a source distribution which consists of the following:
# * Source package (tar.gz)
# * sha256 hash the SOURCES files
# * RPM spec file needed to generate an RPM from the source package
set(BIN_DIR "@CMAKE_BINARY_DIR@")
set(CPACK_PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@")
set(CMAKE_TEMPLATES_DIR "@CMAKE_TEMPLATES_DIR@")
# Project specific variables
set(PROJECT_NAME "@_NAME@")
set(LONG_PROJECT_NAME "@_LONG_NAME@")
set(OUTPUT_DIR "@_OUTPUT_DIR@")
set(SOURCES "@_SOURCES@")
set(STAGING_DIR ${BIN_DIR}/dist)
# Generate spec file
message(STATUS "Generating spec for '${PROJECT_NAME}'.")
configure_file("${CMAKE_TEMPLATES_DIR}${PROJECT_NAME}.spec.in" "${STAGING_DIR}/${PROJECT_NAME}.spec" @ONLY)
# Collect sha256 signatures for each SOURCES file
message(STATUS "Generating sha256 signatures for '${PROJECT_NAME}' SOURCES.")
set(SOURCES_SIGNATURES "")
foreach(src ${SOURCES})
file(SHA256 "${BIN_DIR}/${src}" SRC_CHECKSUM)
list(APPEND SOURCES_SIGNATURES "\"${src}\": \"${SRC_CHECKSUM}\"")
endforeach(src)
configure_file("${CMAKE_TEMPLATES_DIR}/projectname.signatures.json.in" "${STAGING_DIR}/${PROJECT_NAME}.signatures.json" @ONLY)
# Copy all assets (SOURCES + spec + signatures) if different from OUTPUT_DIR
foreach(src ${SOURCES})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${BIN_DIR}/${src}" "${OUTPUT_DIR}/SOURCES/${src}")
endforeach(src)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${STAGING_DIR}/${PROJECT_NAME}.spec" "${OUTPUT_DIR}/${PROJECT_NAME}.spec")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${STAGING_DIR}/${PROJECT_NAME}.signatures.json" "${OUTPUT_DIR}/${PROJECT_NAME}.signatures.json")

Просмотреть файл

@ -1,5 +0,0 @@
{
"Signatures": {
@SOURCES_SIGNATURES@
}
}

Просмотреть файл

@ -19,6 +19,7 @@ using namespace std;
class CommonUtilsTest : public ::testing::Test
{
protected:
const char* m_osId = "/etc/os-release";
const char* m_path = "~test.test";
const char* m_data = "`-=~!@#$%^&*()_+,./<>?'[]\\{}| qwertyuiopasdfghjklzxcvbnm 1234567890 QWERTYUIOPASDFGHJKLZXCVBNM";
const char* m_dataWithEol = "`-=~!@#$%^&*()_+,./<>?'[]\\{}| qwertyuiopasdfghjklzxcvbnm 1234567890 QWERTYUIOPASDFGHJKLZXCVBNM\n";
@ -55,6 +56,11 @@ class CommonUtilsTest : public ::testing::Test
return true;
}
bool IsMarinerDistro()
{
return 0 == FindTextInFile(m_osId, "CBL-Mariner/Linux", nullptr);
}
};
TEST_F(CommonUtilsTest, LoadStringFromFileInvalidArgument)
@ -236,7 +242,7 @@ TEST_F(CommonUtilsTest, ExecuteCommandWithStdErrOutput)
char* textResult = nullptr;
EXPECT_EQ(127, ExecuteCommand(nullptr, "hh", false, true, 100, 0, &textResult, nullptr, nullptr));
EXPECT_NE(nullptr, strstr(textResult, "sh: 1: hh: not found\n"));
EXPECT_NE(nullptr, strstr(textResult, "not found")) << "Text result: '" << textResult << "'";
if (nullptr != textResult)
{
@ -244,7 +250,7 @@ TEST_F(CommonUtilsTest, ExecuteCommandWithStdErrOutput)
}
EXPECT_EQ(127, ExecuteCommand(nullptr, "blah", true, true, 100, 0, &textResult, nullptr, nullptr));
EXPECT_NE(nullptr, strstr(textResult, "sh: 1: blah: not found "));
EXPECT_NE(nullptr, strstr(textResult, "not found")) << "Text result: '" << textResult << "'";
FREE_MEMORY(textResult);
}
@ -1178,6 +1184,11 @@ TEST_F(CommonUtilsTest, CheckFileSystemMountingOption)
TEST_F(CommonUtilsTest, CheckInstallUninstallPackage)
{
if (IsMarinerDistro())
{
GTEST_SKIP() << "Skipping test on CBL-Mariner (RPM-based)";
}
EXPECT_EQ(EINVAL, CheckPackageInstalled(nullptr, nullptr));
EXPECT_EQ(EINVAL, InstallPackage(nullptr, nullptr));
EXPECT_EQ(EINVAL, UninstallPackage(nullptr, nullptr));