-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport for pdf cleanup script (#3732)
- Loading branch information
1 parent
a8742b7
commit 42b3bed
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Define directories and variables | ||
BUILD_DIR="build" | ||
PDF_DIR="$BUILD_DIR/pdf" | ||
EN_PDF_DIR="$BUILD_DIR/en/pdf" | ||
LOCALES="ko ja zh_CN" | ||
KEEP_FILES="suse_manager_administration_guide.pdf suse_manager_client-configuration_guide.pdf suse_manager_installation-and-upgrade_guide.pdf suse_manager_specialized-guides_guide.pdf" | ||
|
||
echo "Starting PDF cleanup..." | ||
echo "BUILD_DIR is set to: $BUILD_DIR" | ||
echo "PDF_DIR is set to: $PDF_DIR" | ||
echo "EN_PDF_DIR is set to: $EN_PDF_DIR" | ||
|
||
# Ensure the target directory exists | ||
mkdir -p "$PDF_DIR/en" | ||
|
||
# Copy English PDFs if they exist | ||
if [ -d "$EN_PDF_DIR" ]; then | ||
echo "Copying English PDFs to $PDF_DIR/en/" | ||
cp -r "$EN_PDF_DIR/"* "$PDF_DIR/en/" 2>/dev/null || true | ||
else | ||
echo "Warning: English PDF directory not found. Skipping copy." | ||
fi | ||
|
||
# Process each locale | ||
for locale in $LOCALES; do | ||
SRC_LOCALE_PDF="$BUILD_DIR/$locale/pdf" | ||
DEST_LOCALE_PDF="$PDF_DIR/$locale" | ||
if [ -d "$SRC_LOCALE_PDF" ]; then | ||
echo "Processing PDFs for locale: $locale" | ||
mkdir -p "$DEST_LOCALE_PDF" | ||
for file in "$SRC_LOCALE_PDF"/*; do | ||
if [ -f "$file" ]; then | ||
filename=$(basename "$file") | ||
if echo "$KEEP_FILES" | grep -q "$filename"; then | ||
echo "Keeping $file" | ||
mv "$file" "$DEST_LOCALE_PDF/" | ||
else | ||
echo "Removing $file (not in keep list)" | ||
rm -f "$file" | ||
fi | ||
fi | ||
done | ||
# Remove the now empty pdf directory | ||
rmdir "$SRC_LOCALE_PDF" 2>/dev/null || true | ||
else | ||
echo "Locale awaiting build...: $locale" | ||
fi | ||
done | ||
|
||
echo "Cleaning up leftover PDF directories..." | ||
rm -rf "$EN_PDF_DIR" | ||
for locale in $LOCALES; do | ||
rm -rf "$BUILD_DIR/$locale/pdf" | ||
done | ||
|
||
echo "PDF cleanup complete." |