Use accurate build time only when publishing
This commit is contained in:
parent
8ace76978e
commit
184e803869
|
|
@ -98,6 +98,7 @@ jobs:
|
||||||
image: asterinas/asterinas:0.17.0-20251228
|
image: asterinas/asterinas:0.17.0-20251228
|
||||||
options: --privileged -v /dev:/dev -v ${{ github.workspace }}:/root/asterinas
|
options: --privileged -v /dev:/dev -v ${{ github.workspace }}:/root/asterinas
|
||||||
run: |
|
run: |
|
||||||
|
export ASTER_BUILD_TIMESTAMP=`date '+%a %b %e %H:%M:%S %Z %Y'`
|
||||||
make iso RELEASE=1 AUTO_INSTALL=false ARCH=${{ matrix.arch }}
|
make iso RELEASE=1 AUTO_INSTALL=false ARCH=${{ matrix.arch }}
|
||||||
iso_path=$(realpath ./target/nixos/iso_image/iso/*.iso)
|
iso_path=$(realpath ./target/nixos/iso_image/iso/*.iso)
|
||||||
echo "iso_path=$iso_path"
|
echo "iso_path=$iso_path"
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ dependencies = [
|
||||||
"bitvec",
|
"bitvec",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"component",
|
"component",
|
||||||
|
"const_format",
|
||||||
"controlled",
|
"controlled",
|
||||||
"core2",
|
"core2",
|
||||||
"cpio-decoder",
|
"cpio-decoder",
|
||||||
|
|
@ -522,6 +523,26 @@ dependencies = [
|
||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const_format"
|
||||||
|
version = "0.2.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad"
|
||||||
|
dependencies = [
|
||||||
|
"const_format_proc_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const_format_proc_macros"
|
||||||
|
version = "0.2.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "controlled"
|
name = "controlled"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
@ -1926,6 +1947,12 @@ version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "universal-hash"
|
name = "universal-hash"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,7 @@ volatile = "0.6.1"
|
||||||
# a capability it currently lacks.
|
# a capability it currently lacks.
|
||||||
aes-gcm = { version = "0.9.4", features = ["force-soft"] }
|
aes-gcm = { version = "0.9.4", features = ["force-soft"] }
|
||||||
bittle = "0.5.6"
|
bittle = "0.5.6"
|
||||||
|
const_format = "0.2.35"
|
||||||
ctr = "0.8.0"
|
ctr = "0.8.0"
|
||||||
font8x8 = { version = "0.2.5", default-features = false, features = [ "unicode" ] }
|
font8x8 = { version = "0.2.5", default-features = false, features = [ "unicode" ] }
|
||||||
getset = "0.1.2"
|
getset = "0.1.2"
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ bitflags.workspace = true
|
||||||
bitvec.workspace = true
|
bitvec.workspace = true
|
||||||
cfg-if.workspace = true
|
cfg-if.workspace = true
|
||||||
component.workspace = true
|
component.workspace = true
|
||||||
|
const_format.workspace = true
|
||||||
controlled.workspace = true
|
controlled.workspace = true
|
||||||
core2.workspace = true
|
core2.workspace = true
|
||||||
cpio-decoder.workspace = true
|
cpio-decoder.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use ostd::sync::RwMutexReadGuard;
|
use ostd::{const_assert, sync::RwMutexReadGuard};
|
||||||
use spin::Once;
|
use spin::Once;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -153,11 +153,29 @@ impl UtsName {
|
||||||
|
|
||||||
/// The version name.
|
/// The version name.
|
||||||
pub const VERSION: &str = {
|
pub const VERSION: &str = {
|
||||||
if let Some(version) = option_env!("OSDK_BUILD_TIMESTAMP") {
|
const BUILD_TIMESTAMP: &str = if let Some(timestamp) = option_env!("ASTER_BUILD_TIMESTAMP")
|
||||||
version
|
{
|
||||||
|
timestamp
|
||||||
} else {
|
} else {
|
||||||
"unknown"
|
const UNIX_EPOCH: &str = "Thu Jan 1 00:00:00 UTC 1970";
|
||||||
}
|
UNIX_EPOCH
|
||||||
|
};
|
||||||
|
|
||||||
|
// The definition of Linux's UTS_VERSION can be found at:
|
||||||
|
// <https://elixir.bootlin.com/linux/v6.18/source/init/Makefile#L37>.
|
||||||
|
// Linux specifies that the total length of this string must not exceed 64 bytes.
|
||||||
|
|
||||||
|
// In Linux, the BUILD_VERSION represents the compilation count, which
|
||||||
|
// increments each time the kernel is built within the same source tree.
|
||||||
|
// We use a fixed value of '1' here to ensure build determinism.
|
||||||
|
// Reference: <https://elixir.bootlin.com/linux/v6.18/source/scripts/build-version>.
|
||||||
|
const BUILD_VERSION: usize = 1;
|
||||||
|
const SMP_FLAGS: &str = "SMP ";
|
||||||
|
const PREEMPT_FLAGS: &str = "";
|
||||||
|
const VERSION: &str =
|
||||||
|
const_format::formatcp!("#{BUILD_VERSION} {SMP_FLAGS}{PREEMPT_FLAGS}{BUILD_TIMESTAMP}");
|
||||||
|
const_assert!(VERSION.len() <= 64);
|
||||||
|
VERSION
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The machine name.
|
/// The machine name.
|
||||||
|
|
|
||||||
|
|
@ -250,19 +250,7 @@ fn build_kernel_elf(
|
||||||
.unwrap_or_else(|_| "unknown".to_string())
|
.unwrap_or_else(|_| "unknown".to_string())
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
// Use system date command to get the formatted time string
|
|
||||||
let date_output = std::process::Command::new("date")
|
|
||||||
// Reference: <https://man7.org/linux/man-pages/man1/date.1.html>
|
|
||||||
.arg("+%a %b %e %H:%M:%S %Z %Y")
|
|
||||||
.output()
|
|
||||||
.ok()
|
|
||||||
.and_then(|output| {
|
|
||||||
String::from_utf8(output.stdout)
|
|
||||||
.ok()
|
|
||||||
.map(|s| s.trim().to_string())
|
|
||||||
})
|
|
||||||
.unwrap_or_else(|| "Thu Jan 1 00:00:00 UTC 1970".to_string());
|
|
||||||
command.env("OSDK_BUILD_TIMESTAMP", format!("#1 {}", date_output));
|
|
||||||
command.env("RUSTFLAGS", rustflags.join(" "));
|
command.env("RUSTFLAGS", rustflags.join(" "));
|
||||||
command.arg("build");
|
command.arg("build");
|
||||||
command.arg("--features").arg(features.join(" "));
|
command.arg("--features").arg(features.join(" "));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue