From acf98c23563dec9ad2158a1da7b2ffb33dd53f69 Mon Sep 17 00:00:00 2001 From: jackeyji Date: Mon, 4 Nov 2024 14:57:26 +0800 Subject: [PATCH] update script for rpm-upgrade Signed-off-by: jackeyji --- gen_tarball.sh | 71 ++++++++++++++++++++++++++++++++++++++++ python-cryptography.spec | 6 +++- up.yaml | 5 +++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100755 gen_tarball.sh create mode 100644 up.yaml diff --git a/gen_tarball.sh b/gen_tarball.sh new file mode 100755 index 0000000..562076b --- /dev/null +++ b/gen_tarball.sh @@ -0,0 +1,71 @@ +#!/bin/bash +######################################################### +# Function :Generate tarball for upgrade # +# Platform :Linux Platform # +# Version :1.0 # +# Date :2024-08-21 # +# Author :gordonwwang # +######################################################### + +# Function to handle errors +handle_error() { + echo "$1" + exit "$2" +} + +# Function to check and install tools +check_tools() { + if ! command -v rpmspec &> /dev/null; then + dnf install /usr/bin/rpmspec -yq || handle_error 'Failed to install rpmspec' 1 + fi + # cargo only for rust + if ! command -v cargo &> /dev/null; then + dnf install cargo -yq || handle_error 'Failed to install cargo' 1 + fi +} + +# Function tears down +tear_down() { + cd "$cur_dir" + rm -rf "$dir_name" + rm -f ./tmp_spec + echo "tears down before script exit." +} + +# Function to generate the tarball +generate_tarball() { + # Get name, version, and source from spec + specname=$(basename "$PWD") + rpmspec -P "${specname}.spec" > ./tmp_spec + [ $? -eq 0 ] || handle_error "spec parse failed" 2 + + name=$(grep '^Name:' ./tmp_spec | awk '{print $2}') + version=$(grep '^Version:' ./tmp_spec | awk '{print $2}') + source0=$(grep '^Source0:' ./tmp_spec | awk '{print $2}') + source1=$(grep '^Source1:' ./tmp_spec | awk '{print $2}') + cur_dir=$(pwd) + + # Download and unzip tarball + tarball_name=$(basename "${source0}") + wget "${source0}" -q --show-progress -O "${tarball_name}" + [ $? -eq 0 ] || handle_error "Failed to download source" 3 + tar -xzf "${tarball_name}" + + dir_name="${name}-${version}" + cd "$dir_name"/src/rust + # Run cargo vendor + cargo vendor + [ $? -eq 0 ] || handle_error "cargo vendor failed" 4 + + # Tar and compress + echo "Generate vendor ..." + vendor_file=$(basename "${source1}") # e.g., "${name}-${version}-vendor.tar.bz2" + tar -cjf "${vendor_file}" vendor + mv "${vendor_file}" "$cur_dir" +} + +# Ensure tear_down is called on script exit +trap tear_down EXIT + +check_tools +generate_tarball diff --git a/python-cryptography.spec b/python-cryptography.spec index f192a79..34b7de1 100644 --- a/python-cryptography.spec +++ b/python-cryptography.spec @@ -6,7 +6,7 @@ Summary: PyCA's cryptography library Name: python-%{srcname} Version: 41.0.4 -Release: 8%{?dist} +Release: 9%{?dist} License: ASL 2.0 or BSD URL: https://cryptography.io/en/latest/ Source0: https://github.com/pyca/cryptography/archive/%{version}/%{srcname}-%{version}.tar.gz @@ -78,6 +78,10 @@ PYTHONPATH=${PWD}/vectors:%{buildroot}%{python3_sitearch} \ %{python3_sitearch}/%{srcname}-%{version}-py*.egg-info %changelog +* Mon Nov 04 2024 jackeyji - 41.0.4-9 +- [Type] other +- [DESC] update script for rpm-upgrade + * Thu Sep 26 2024 OpenCloudOS Release Engineering - 41.0.4-8 - Rebuilt for clarifying the packages requirement in BaseOS and AppStream diff --git a/up.yaml b/up.yaml new file mode 100644 index 0000000..806eab1 --- /dev/null +++ b/up.yaml @@ -0,0 +1,5 @@ +Source: + item: + - "Source1" + command: + - "sh gen_tarball.sh" \ No newline at end of file -- Gitee