修改离线脚本

This commit is contained in:
Tian jianyong 2024-12-19 19:53:13 +08:00
parent 4e068dba50
commit f69e3eaba7

View File

@ -21,50 +21,16 @@ log_error() {
# Print usage
usage() {
echo "Usage: $0 [-a|--arch <x86_64|i686>]"
echo "Options:"
echo " -a, --arch Target architecture (default: $(uname -m))"
echo "Example:"
echo " $0 --arch x86_64 # Prepare packages for 64-bit systems"
echo " $0 --arch i686 # Prepare packages for 32-bit systems"
echo "Usage: $0"
echo "This script prepares packages"
}
# Parse command line arguments
TARGET_ARCH=$(uname -m) # Default to current system architecture
while [[ $# -gt 0 ]]; do
case $1 in
-a|--arch)
TARGET_ARCH="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
log_error "Unknown option: $1"
usage
exit 1
;;
esac
done
# Validate target architecture
case ${TARGET_ARCH} in
x86_64)
ARCH_SUFFIX="x86_64"
;;
i686|i386)
ARCH_SUFFIX="i686"
;;
*)
log_error "Unsupported architecture: ${TARGET_ARCH}"
log_error "Supported architectures: x86_64, i686"
exit 1
;;
esac
log_info "Target architecture: ${TARGET_ARCH}"
if [ $# -gt 0 ]; then
log_error "This script does not accept any arguments"
usage
exit 1
fi
# Check if running on CentOS
if [ ! -f /etc/centos-release ]; then
@ -87,8 +53,8 @@ if [ ! -f "${PROJECT_ROOT}/CMakeLists.txt" ] || \
exit 1
fi
# Create packages directory with architecture suffix
PACKAGES_DIR="${PROJECT_ROOT}/packages_${TARGET_ARCH}"
# Create packages directory
PACKAGES_DIR="${PROJECT_ROOT}/packages"
log_info "Creating packages directory: ${PACKAGES_DIR}"
mkdir -p "${PACKAGES_DIR}"
@ -216,7 +182,7 @@ cd "${PROJECT_ROOT}" || {
# Create archive of the project
log_info "Creating project archive..."
ARCHIVE_NAME="${PROJECT_NAME}_${TARGET_ARCH}.tar.gz"
ARCHIVE_NAME="${PROJECT_NAME}.tar.gz"
ARCHIVE_PATH="${PROJECT_ROOT}/../${ARCHIVE_NAME}"
tar czf "${ARCHIVE_PATH}" \
@ -231,7 +197,7 @@ log_info "Successfully created ${ARCHIVE_NAME}"
# Print summary
echo -e "\n${GREEN}Offline package preparation completed!${NC}"
echo "Created files for ${TARGET_ARCH} architecture:"
echo "Created files:"
echo " - ${PACKAGES_DIR}/offline-deps.txt (System package list)"
echo " - ${PACKAGES_DIR}/requirements.txt (Python package list)"
echo " - ${PACKAGES_DIR}/*.rpm (System packages)"