Skip to content

Commit 93a4121

Browse files
committed
[release] v4.1
0 parents  commit 93a4121

25 files changed

+1753
-0
lines changed

.github/workflows/build.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: criu-static build
2+
on:
3+
# Run on push events
4+
push:
5+
# Only run when code is pushed to these branches
6+
branches:
7+
- "master"
8+
# Avoid running when tags are pushed
9+
tags-ignore:
10+
- "**"
11+
# Avoid running when certain files are modified
12+
paths-ignore:
13+
- "docs/**"
14+
15+
# Run on pull request events
16+
pull_request:
17+
types:
18+
- opened
19+
- synchronize
20+
- reopened
21+
22+
# avoid running multiple copies of the same workflow in parallel
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
build-amd64:
29+
name: Build criu(amd64)
30+
runs-on: ubuntu-24.04
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4.2.2
34+
with:
35+
fetch-depth: 1
36+
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3.10.0
39+
40+
- name: Build criu
41+
uses: docker/build-push-action@v6
42+
with:
43+
context: .
44+
outputs: type=local,dest=./output
45+
file: Dockerfile
46+
push: false
47+
load: true
48+
tags: "criu-build-image-amd64"
49+
platforms: "linux/amd64"
50+
cache-from: type=gha,scope=criu-build-image-amd64
51+
cache-to: type=gha,mode=max,scope=criu-build-image-amd64
52+
53+
- name: Upload amd64 artifact
54+
uses: actions/upload-artifact@v4.6.2
55+
with:
56+
name: criu-amd64
57+
path: ./output
58+
59+
build-arm64:
60+
name: Build criu(arm64)
61+
runs-on: ubuntu-24.04-arm64
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4.2.2
65+
with:
66+
fetch-depth: 1
67+
68+
- name: Set up Docker Buildx
69+
uses: docker/setup-buildx-action@v3.10.0
70+
71+
- name: Build criu
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: .
75+
outputs: type=local,dest=./output
76+
file: Dockerfile
77+
push: false
78+
load: true
79+
tags: "criu-build-image-arm64"
80+
platforms: "linux/arm64"
81+
cache-from: type=gha,scope=criu-build-image-arm64
82+
cache-to: type=gha,mode=max,scope=criu-build-image-arm64
83+
84+
- name: Upload arm64 artifact
85+
uses: actions/upload-artifact@v4.6.2
86+
with:
87+
name: criu-arm64
88+
path: ./output
89+
90+
release:
91+
name: Release
92+
if: "contains(github.event.head_commit.message, '[release]') && ( github.event.ref=='refs/heads/master' || contains(github.event.ref, 'release') )"
93+
needs: [build-amd64, build-arm64]
94+
runs-on: ubuntu-24.04
95+
permissions:
96+
contents: write
97+
steps:
98+
- name: Checkout repository
99+
uses: actions/checkout@v4.2.2
100+
101+
- name: Download build artifacts (amd64)
102+
uses: actions/download-artifact@v4.3.0
103+
with:
104+
pattern: criu-amd64
105+
path: dist
106+
107+
- name: Download build artifacts (arm64)
108+
uses: actions/download-artifact@v4.3.0
109+
with:
110+
pattern: criu-arm64
111+
path: dist
112+
113+
- name: Setup Java for JReleaser
114+
uses: actions/setup-java@v1
115+
with:
116+
java-version: 11
117+
118+
- name: Version
119+
id: version
120+
run: |
121+
VERSION=$(cmake --preset static-release -LA | grep CRIU_VERSION | cut -d'=' -f2)
122+
echo "VERSION = $VERSION"
123+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
124+
125+
- name: Run JReleaser
126+
uses: jreleaser/release-action@v2
127+
env:
128+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
JRELEASER_PROJECT_VERSION: ${{ steps.version.outputs.VERSION }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/
2+
dist/
3+
CMakeCache.txt
4+
_CPack_Packages

CMakeLists.txt

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
cmake_minimum_required(VERSION 3.28)
2+
3+
project(criu-static VERSION 4.1)
4+
include(GNUInstallDirs)
5+
include(macros/dependencies.cmake)
6+
7+
# Upstream CRIU version and SHA256 checksum
8+
set(CRIU_VERSION "${PROJECT_VERSION}" CACHE STRING "CRIU version to build")
9+
set(CRIU_SHASUM "9a3094f3d0aa6cfa8bd5c9b92c05f4a566ad21ee20eb9b2fbc6129a74d1f6dc7")
10+
11+
# Force static building
12+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries" FORCE)
13+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
14+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
15+
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
16+
17+
set(ENV{CC} ${CMAKE_C_COMPILER})
18+
set(ENV{CXX} ${CMAKE_CXX_COMPILER})
19+
20+
set(SOURCE_DOWNLOADS_DIR ${CMAKE_BINARY_DIR}/downloads)
21+
22+
# Dependencies
23+
include(FetchContent)
24+
include(ExternalProject)
25+
include(dependencies/Zlib.cmake)
26+
include(dependencies/Libnl.cmake)
27+
include(dependencies/Libnet.cmake)
28+
include(dependencies/Libcap.cmake)
29+
include(dependencies/Libaio.cmake)
30+
include(dependencies/Protobuf.cmake)
31+
include(dependencies/ProtobufC.cmake)
32+
include(dependencies/Libmnl.cmake)
33+
include(dependencies/Libnftnl.cmake)
34+
include(dependencies/Libnftables.cmake)
35+
include(dependencies/UtilLinux.cmake)
36+
include(dependencies/Libintl.cmake)
37+
38+
# Get all dependency flags
39+
get_target_property(PROTOBUF_C_CFLAGS protobuf-c::static CONSUMER_CFLAGS)
40+
get_target_property(PROTOBUF_C_LDFLAGS protobuf-c::static CONSUMER_LDFLAGS)
41+
get_target_property(PROTOBUF_C_HEADER_DIR protobuf-c::static CONSUMER_HEADER_DIR)
42+
get_target_property(PROTOC_C_BIN_PATH protobuf-c::static CONSUMER_PROTOC_C_PATH)
43+
get_target_property(PROTOBUF_CFLAGS protobuf::static CONSUMER_CFLAGS)
44+
get_target_property(PROTOBUF_LDFLAGS protobuf::static CONSUMER_LDFLAGS)
45+
get_target_property(DESCRIPTOR_PROTO_FILE protobuf::static CONSUMER_DESCRIPTOR_PROTO_FILE)
46+
get_target_property(PROTOC_BIN_PATH protobuf::static CONSUMER_PROTOC_PATH)
47+
get_target_property(LIBNET_CFLAGS libnet::static CONSUMER_CFLAGS)
48+
get_target_property(LIBNET_LDFLAGS libnet::static CONSUMER_LDFLAGS)
49+
get_target_property(LIBNL_CFLAGS libnl::static CONSUMER_CFLAGS)
50+
get_target_property(LIBNL_LDFLAGS libnl::static CONSUMER_LDFLAGS)
51+
get_target_property(LIBCAP_CFLAGS libcap::static CONSUMER_CFLAGS)
52+
get_target_property(LIBCAP_LDFLAGS libcap::static CONSUMER_LDFLAGS)
53+
get_target_property(LIBAIO_CFLAGS libaio::static CONSUMER_CFLAGS)
54+
get_target_property(LIBAIO_LDFLAGS libaio::static CONSUMER_LDFLAGS)
55+
get_target_property(ZLIB_CFLAGS zlib::static CONSUMER_CFLAGS)
56+
get_target_property(ZLIB_LDFLAGS zlib::static CONSUMER_LDFLAGS)
57+
get_target_property(LIBMNL_CFLAGS libmnl::static CONSUMER_CFLAGS)
58+
get_target_property(LIBMNL_LDFLAGS libmnl::static CONSUMER_LDFLAGS)
59+
get_target_property(LIBNFTNL_CFLAGS libnftnl::static CONSUMER_CFLAGS)
60+
get_target_property(LIBNFTNL_LDFLAGS libnftnl::static CONSUMER_LDFLAGS)
61+
get_target_property(LIBNFTABLES_CFLAGS libnftables::static CONSUMER_CFLAGS)
62+
get_target_property(LIBNFTABLES_LDFLAGS libnftables::static CONSUMER_LDFLAGS)
63+
get_target_property(LIBUUID_CFLAGS uuid::static CONSUMER_CFLAGS)
64+
get_target_property(LIBUUID_LDFLAGS uuid::static CONSUMER_LDFLAGS)
65+
get_target_property(LIBINTL_CFLAGS libintl::static CONSUMER_CFLAGS)
66+
get_target_property(LIBINTL_LDFLAGS libintl::static CONSUMER_LDFLAGS)
67+
68+
# Prepare CRIU build flags
69+
set(CRIU_FEATURE_DEFINES "-DCONFIG_HAS_NFTABLES_LIB_API_1")
70+
set(CRIU_CFLAGS "${PROTOBUF_C_CFLAGS} ${CRIU_FEATURE_DEFINES} ${PROTOBUF_CFLAGS} ${LIBNET_CFLAGS} ${LIBNL_CFLAGS} ${LIBCAP_CFLAGS} ${LIBAIO_CFLAGS} ${ZLIB_CFLAGS} ${LIBNFTABLES_CFLAGS} ${LIBNFTNL_CFLAGS} ${LIBMNL_CFLAGS} ${LIBUUID_CFLAGS} ${LIBINTL_CFLAGS}")
71+
set(CRIU_LDFLAGS "-static ${PROTOBUF_C_LDFLAGS} ${PROTOBUF_LDFLAGS} ${LIBNET_LDFLAGS} ${LIBNL_LDFLAGS} ${LIBCAP_LDFLAGS} ${LIBAIO_LDFLAGS} ${ZLIB_LDFLAGS} ${LIBNFTABLES_LDFLAGS} ${LIBNFTNL_LDFLAGS} ${LIBMNL_LDFLAGS} ${LIBUUID_LDFLAGS} ${LIBINTL_LDFLAGS}")
72+
73+
message("-- criu CFLAGS ${CRIU_CFLAGS}")
74+
message("-- criu LDFLAGS ${CRIU_LDFLAGS}")
75+
76+
# CRIU build directories
77+
set(CRIU_BUILD_DIR ${CMAKE_BINARY_DIR}/criu-build)
78+
set(CRIU_INSTALL_DIR ${CMAKE_BINARY_DIR}/criu-install)
79+
80+
81+
set(CRIU_MAKE_VARS
82+
"PREFIX=${CRIU_INSTALL_DIR}"
83+
)
84+
85+
register_dependency(
86+
criu
87+
"https://github.com/checkpoint-restore/criu/archive/refs/tags/v${CRIU_VERSION}.tar.gz"
88+
"${CRIU_SHASUM}"
89+
"COPYING"
90+
)
91+
92+
ExternalProject_Add(criu
93+
URL ${DEP_criu_URL}
94+
URL_HASH SHA256=${DEP_criu_SHA256}
95+
UPDATE_DISCONNECTED 1
96+
PATCH_COMMAND patch -p1 -i ${CMAKE_SOURCE_DIR}/patch/criu-build.patch
97+
CONFIGURE_COMMAND ""
98+
DOWNLOAD_DIR ${SOURCE_DOWNLOADS_DIR}
99+
DOWNLOAD_NAME ${DEP_criu_FILENAME}
100+
BUILD_COMMAND
101+
${CMAKE_MAKE_PROGRAM} -C <SOURCE_DIR> ${CRIU_MAKE_VARS} mrproper
102+
COMMAND ${CMAKE_COMMAND} -E rm -f "<SOURCE_DIR>/images/google/protobuf/descriptor.proto"
103+
COMMAND ${CMAKE_COMMAND} -E copy "${DESCRIPTOR_PROTO_FILE}" "<SOURCE_DIR>/images/google/protobuf/descriptor.proto"
104+
COMMAND ${CMAKE_COMMAND} -E env
105+
"CFLAGS=${CRIU_CFLAGS}"
106+
"LDFLAGS=${CRIU_LDFLAGS}"
107+
"CC=${CMAKE_C_COMPILER}"
108+
"PATH=${PROTOC_BIN_PATH}:${PROTOC_C_BIN_PATH}:$ENV{PATH}"
109+
"SKIP_PIP_INSTALL=1"
110+
${CMAKE_MAKE_PROGRAM} -C <SOURCE_DIR> ${CRIU_MAKE_VARS} -j${CMAKE_BUILD_PARALLEL_LEVEL}
111+
CONFIG_AMDGPU=n
112+
lib/c/built-in.o
113+
criu
114+
INSTALL_COMMAND
115+
${CMAKE_COMMAND} -E make_directory ${CRIU_INSTALL_DIR}/lib
116+
COMMAND ${CMAKE_COMMAND} -E make_directory ${CRIU_INSTALL_DIR}/bin
117+
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/lib/c/built-in.o ${CRIU_INSTALL_DIR}/lib/libcriu.o
118+
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/lib/c/criu.h ${CRIU_INSTALL_DIR}/include/criu/criu.h
119+
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/criu/include/version.h ${CRIU_INSTALL_DIR}/include/criu/version.h
120+
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/images/rpc.pb-c.h ${CRIU_INSTALL_DIR}/include/criu/rpc.pb-c.h
121+
COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/criu/criu ${CRIU_INSTALL_DIR}/bin/criu
122+
BINARY_DIR ${CRIU_BUILD_DIR}
123+
DEPENDS protobuf::static protobuf-c::static libnet::static libnl::static libcap::static libaio::static zlib::static libmnl::static libnftnl::static libnftables::static uuid::static libintl::static
124+
)
125+
126+
install(FILES ${CRIU_INSTALL_DIR}/lib/libcriu.o DESTINATION lib)
127+
install(PROGRAMS ${CRIU_INSTALL_DIR}/bin/criu DESTINATION bin)
128+
install(DIRECTORY ${CRIU_INSTALL_DIR}/include/criu DESTINATION include)
129+
130+
install(DIRECTORY ${PROTOBUF_C_HEADER_DIR}/ DESTINATION include/)
131+
132+
message(STATUS "CRIU configuration completed")
133+
134+
# Install
135+
install(FILES CMakeLists.txt CMakePresets.json DESTINATION ${CMAKE_INSTALL_DOCDIR})
136+
137+
install(DIRECTORY patch/ DESTINATION ${CMAKE_INSTALL_DOCDIR}/patch)
138+
install(DIRECTORY macros/ DESTINATION ${CMAKE_INSTALL_DOCDIR}/macros)
139+
install(DIRECTORY dependencies/ DESTINATION ${CMAKE_INSTALL_DOCDIR}/dependencies)
140+
install(FILES CMakePresets.json package_deps_licenses.cmake.in DESTINATION ${CMAKE_INSTALL_DOCDIR})
141+
142+
include(check_musl.cmake)
143+
fetch_musl_license_if_needed()
144+
145+
if(REGISTERED_DEPENDENCIES)
146+
list(REMOVE_DUPLICATES REGISTERED_DEPENDENCIES)
147+
148+
set(CONSOLIDATED_LICENSE_FILE "${CMAKE_BINARY_DIR}/THIRD-PARTY-LICENSES.txt")
149+
150+
configure_file(
151+
"${CMAKE_SOURCE_DIR}/package_deps_licenses.cmake.in"
152+
"${CMAKE_BINARY_DIR}/package_deps_licenses.cmake"
153+
@ONLY
154+
)
155+
156+
install(SCRIPT "${CMAKE_BINARY_DIR}/package_deps_licenses.cmake")
157+
install(
158+
DIRECTORY "${SOURCE_DOWNLOADS_DIR}/"
159+
DESTINATION "${CMAKE_INSTALL_DOCDIR}/third_party/sources"
160+
)
161+
install(FILES "${CONSOLIDATED_LICENSE_FILE}" DESTINATION "${CMAKE_INSTALL_DOCDIR}/third_party")
162+
163+
message(STATUS "Dependency download script configured for installation.")
164+
endif()
165+
166+
# Detect target architecture
167+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)$")
168+
set(TARGET_ARCH "arm64")
169+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64)$")
170+
set(TARGET_ARCH "amd64")
171+
else()
172+
set(TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
173+
endif()
174+
175+
# Package
176+
set(CPACK_PACKAGE_NAME "criu-static")
177+
set(CPACK_PACKAGE_VERSION "${CRIU_VERSION}")
178+
set(CPACK_PACKAGE_VENDOR "The CRIU Authors")
179+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Static build of CRIU (Checkpoint/Restore In Userspace)")
180+
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
181+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
182+
set(CPACK_SOURCE_GENERATOR "TGZ;STGZ")
183+
set(CPACK_GENERATOR "TGZ;STGZ")
184+
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-linux-${TARGET_ARCH}")
185+
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-source")
186+
include(CPack)

CMakePresets.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "static-release",
6+
"displayName": "Static Release Build",
7+
"description": "Static build for release",
8+
"binaryDir": "${sourceDir}/build",
9+
"cacheVariables": {
10+
"CMAKE_BUILD_TYPE": "Release",
11+
"BUILD_SHARED_LIBS": "OFF",
12+
"CMAKE_C_COMPILER": "clang",
13+
"CMAKE_CXX_COMPILER": "clang++"
14+
}
15+
},
16+
{
17+
"name": "static-debug",
18+
"displayName": "Static Debug Build",
19+
"description": "Static build for debug",
20+
"binaryDir": "${sourceDir}/build-debug",
21+
"cacheVariables": {
22+
"CMAKE_BUILD_TYPE": "Debug",
23+
"BUILD_SHARED_LIBS": "OFF",
24+
"CMAKE_C_COMPILER": "clang",
25+
"CMAKE_CXX_COMPILER": "clang++"
26+
}
27+
}
28+
],
29+
"buildPresets": [
30+
{
31+
"name": "static-release",
32+
"configurePreset": "static-release",
33+
"jobs": 0
34+
},
35+
{
36+
"name": "static-debug",
37+
"configurePreset": "static-debug",
38+
"jobs": 0
39+
}
40+
]
41+
}

0 commit comments

Comments
 (0)