Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions scripts/make_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ elif [ "$#" -ge 4 ] && [ "$4" = "--reboot-required" ]; then
fi

START_DIR=$(pwd)
OUTPUT_ROOT_DIR="updates"
mkdir -p "$OUTPUT_ROOT_DIR"

info "checking required directories and tools"

Expand Down Expand Up @@ -145,6 +147,9 @@ fi
OLD_VERSION=${OLD_VERSION_DIR##*/}
NEW_VERSION=${NEW_VERSION_DIR##*/}

UPDATE_DIR="$OUTPUT_ROOT_DIR/${OLD_VERSION}-${NEW_VERSION}"
mkdir -p "$UPDATE_DIR"

# Strip the 'v'.
OLD_VERSION_NO_V=${OLD_VERSION#v}
NEW_VERSION_NO_V=${NEW_VERSION#v}
Expand Down Expand Up @@ -175,10 +180,10 @@ SIGNED_SHA256=$(sha256sum ./release.tar | awk '{print $1}')

info "generating @manifest.json"
RELEASE_DATE=$(date +%Y-%m-%d)
UPDATE_FILENAME="release-${OLD_VERSION}-${NEW_VERSION}.tar"
SIGNATURE_FILENAME="release-${OLD_VERSION}-${NEW_VERSION}.tar.sig"
UPDATE_FILENAME="release.tar"
SIGNATURE_FILENAME="release.tar.sig"

cat > "manifest-${OLD_VERSION}-${NEW_VERSION}.json" <<EOF
cat > "$UPDATE_DIR/manifest.json" <<EOF
{
"baseVersion": "${OLD_VERSION_NO_V}",
"version": "${NEW_VERSION_NO_V}",
Expand All @@ -204,11 +209,14 @@ cargo xtask build-firmware-image
cd "$START_DIR"

# Then copy the image over.
cp "$KEYOS_DIR/boot.img" "boot-$OLD_VERSION-$NEW_VERSION.img"
cp "$KEYOS_DIR/boot.img" "$UPDATE_DIR/boot.img"

info "compressing 'boot.img'"
gzip -c "boot-$OLD_VERSION-$NEW_VERSION.img" > "boot-$OLD_VERSION-$NEW_VERSION.img.gz"
gzip -c "$UPDATE_DIR/boot.img" > "$UPDATE_DIR/boot.img.gz"

mv release.tar "release-$OLD_VERSION-$NEW_VERSION.tar"
if [ -f release.tar.sig ]; then
mv release.tar.sig "$UPDATE_DIR/release.tar.sig"
fi
mv release.tar "$UPDATE_DIR/release.tar"

info "done"
24 changes: 23 additions & 1 deletion scripts/make_release_input_dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,36 @@ fi

cd "$KEYOS_DIR"

info "checking 'keyos' git status"

if [ ! -d .git ]; then
error "keyos directory at '$(pwd)' is not a git repository"
exit 1
fi

if [ -n "$(git status --porcelain)" ]; then
error "keyos repository at '$(pwd)' has uncommitted changes. Please commit or stash them before running this script."
exit 1
fi

KEYOS_COMMIT=$(git rev-parse HEAD)

info "generating firmware components in 'keyos'"
cargo xtask build-all --dont-sign
cargo xtask build --dont-sign --reproducible

cd "$START_DIR"

info "preparing release input directory"
mkdir "$FIRMWARE_VERSION"

COMMITS_FILE="$START_DIR/keyos-commits.txt"
if [ -f "$COMMITS_FILE" ]; then
tmp_file="${COMMITS_FILE}.tmp"
grep -v -F "$FIRMWARE_VERSION " "$COMMITS_FILE" > "$tmp_file" || true
mv "$tmp_file" "$COMMITS_FILE"
fi
echo "$FIRMWARE_VERSION $KEYOS_COMMIT" >> "$COMMITS_FILE"

cp "$KEYOS_DIR/target/armv7a-unknown-xous-elf/release/images/app.bin" "$FIRMWARE_VERSION"
cp -r "$KEYOS_DIR/target/armv7a-unknown-xous-elf/release/apps/" "$FIRMWARE_VERSION"

Expand Down
24 changes: 23 additions & 1 deletion tools/release-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ Please make sure it's in your PATH or specify the path where it is installed. Se
String::from_utf8_lossy(&output.stderr)
);

let patch_metadata = fs::metadata(&patch_file).with_context(|| {
format!("Reading patch file metadata: {}", abs_path(&patch_file))
})?;
let patch_size = patch_metadata.len();

let file = base_file.to_str().expect(PATH_TO_STR_ERROR).to_string();

actions.push(Action::Patch {
Expand All @@ -177,7 +182,11 @@ Please make sure it's in your PATH or specify the path where it is installed. Se
base_version: args.base_version.clone(),
new_version: args.new_version.clone(),
});
println!("[INFO] action/patch: {}", base_file.display());
println!(
"[INFO] action/patch ({}): {}",
format_size(patch_size),
base_file.display(),
);
}
}
}
Expand Down Expand Up @@ -343,3 +352,16 @@ fn abs_path<P: AsRef<Path>>(path: P) -> impl Display {
.to_string_lossy()
.to_string()
}

fn format_size(bytes: u64) -> String {
const KB: u64 = 1024;
const MB: u64 = KB * 1024;

if bytes >= MB {
format!("{:.2} MB", bytes as f64 / MB as f64)
} else if bytes >= KB {
format!("{:.0} KB", bytes as f64 / KB as f64)
} else {
format!("{bytes} B")
}
}