修改离线脚本的错误
This commit is contained in:
parent
d730151bd6
commit
4983a7fe69
@ -93,10 +93,15 @@ fi
|
||||
PACKAGES_DIR="${PROJECT_ROOT}/packages_${TARGET_ARCH}"
|
||||
log_info "Creating packages directory: ${PACKAGES_DIR}"
|
||||
mkdir -p "${PACKAGES_DIR}"
|
||||
cd "${PACKAGES_DIR}" || {
|
||||
log_error "Failed to enter packages directory"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Install yum-plugin-downloadonly if not already installed
|
||||
if ! rpm -q yum-plugin-downloadonly &>/dev/null; then
|
||||
log_info "Installing yum-plugin-downloadonly..."
|
||||
yum install -y yum-plugin-downloadonly || {
|
||||
log_error "Failed to install yum-plugin-downloadonly"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Function to get package dependencies
|
||||
get_dependencies() {
|
||||
@ -138,15 +143,32 @@ sort -u "$TEMP_PKGS" -o "$TEMP_PKGS"
|
||||
|
||||
# Download all packages
|
||||
log_info "Downloading packages..."
|
||||
DOWNLOAD_FAILED=0
|
||||
while read -r pkg; do
|
||||
log_info "Downloading $pkg..."
|
||||
yum ${YUM_ARCH} install --downloadonly --downloaddir=. "$pkg" || {
|
||||
log_warn "Failed to download $pkg, continuing..."
|
||||
}
|
||||
if ! yum ${YUM_ARCH} install --downloadonly --downloaddir="${PACKAGES_DIR}" "$pkg"; then
|
||||
log_error "Failed to download $pkg"
|
||||
DOWNLOAD_FAILED=1
|
||||
fi
|
||||
done < "$TEMP_PKGS"
|
||||
|
||||
rm "$TEMP_PKGS"
|
||||
|
||||
# Check if any RPM files were downloaded
|
||||
cd "${PACKAGES_DIR}" || {
|
||||
log_error "Failed to enter packages directory"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! "$(ls -A *.rpm 2>/dev/null)" ]; then
|
||||
if [ $DOWNLOAD_FAILED -eq 1 ]; then
|
||||
log_error "Failed to download some packages. Please check your network connection and yum repository configuration."
|
||||
else
|
||||
log_error "No RPM packages were downloaded. Please check your yum configuration."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create Python requirements file
|
||||
log_info "Creating Python requirements file..."
|
||||
cat > requirements.txt << EOL
|
||||
@ -164,25 +186,29 @@ mkdir -p "${PYTHON_PACKAGES_DIR}"
|
||||
|
||||
# Download Python packages
|
||||
log_info "Downloading Python packages..."
|
||||
pip3 download -r requirements.txt -d "${PYTHON_PACKAGES_DIR}" || {
|
||||
if ! pip3 download -r requirements.txt -d "${PYTHON_PACKAGES_DIR}"; then
|
||||
log_error "Failed to download Python packages"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Create package list
|
||||
log_info "Creating package list..."
|
||||
ls *.rpm > offline-deps.txt || {
|
||||
log_error "Failed to create package list"
|
||||
if ! ls *.rpm > offline-deps.txt 2>/dev/null; then
|
||||
log_error "No RPM packages found in the directory"
|
||||
log_error "Please check the previous error messages"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
# Sort package list to handle dependencies
|
||||
log_info "Sorting package list for dependency order..."
|
||||
# Move boost packages to the beginning of the list
|
||||
grep "boost-.*\.rpm" offline-deps.txt > boost-deps.txt
|
||||
grep -v "boost-.*\.rpm" offline-deps.txt > other-deps.txt
|
||||
cat boost-deps.txt other-deps.txt > offline-deps.txt
|
||||
rm boost-deps.txt other-deps.txt
|
||||
if ! grep "boost-.*\.rpm" offline-deps.txt > boost-deps.txt 2>/dev/null; then
|
||||
log_warn "No boost packages found"
|
||||
fi
|
||||
if ! grep -v "boost-.*\.rpm" offline-deps.txt > other-deps.txt 2>/dev/null; then
|
||||
log_warn "No non-boost packages found"
|
||||
fi
|
||||
cat boost-deps.txt other-deps.txt > offline-deps.txt 2>/dev/null
|
||||
rm -f boost-deps.txt other-deps.txt
|
||||
|
||||
# Return to project root directory
|
||||
cd "${PROJECT_ROOT}" || {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user