Improve DEB package extraction and repackaging logic

Enhanced the workflow to handle multiple data archive compression formats (xz, gz, zst) when extracting and repackaging DEB files. Added checks for the presence of the data archive and updated extraction and repackaging commands to match the detected format, improving robustness and compatibility.
This commit is contained in:
Your Name
2025-09-02 19:47:28 +03:00
parent aebe5f1aa6
commit 1b552c4ae8
+77 -35
View File
@@ -211,43 +211,85 @@ jobs:
# Extract the DEB package # Extract the DEB package
ar x "$GITHUB_WORKSPACE/$deb_file" ar x "$GITHUB_WORKSPACE/$deb_file"
# Extract the data archive # List extracted files to see what we have
mkdir -p data echo "Extracted DEB contents:"
cd data ls -la
tar xf ../data.tar.xz
# Ensure desktop files are properly placed # Find the data archive (could be data.tar.xz, data.tar.gz, data.tar.zst, etc.)
if [ ! -d "usr/share/applications" ]; then data_archive=""
mkdir -p usr/share/applications for ext in xz gz zst; do
if [ -f "data.tar.$ext" ]; then
data_archive="data.tar.$ext"
break
fi
done
if [ -z "$data_archive" ]; then
echo "Warning: Could not find data archive in DEB package"
cd "$GITHUB_WORKSPACE"
rm -rf "$temp_deb_dir"
else
echo "Found data archive: $data_archive"
# Extract the data archive
mkdir -p data
cd data
case "$data_archive" in
*.tar.xz)
tar xf "../$data_archive"
;;
*.tar.gz)
tar xzf "../$data_archive"
;;
*.tar.zst)
tar --zstd -xf "../$data_archive"
;;
esac
# Ensure desktop files are properly placed
if [ ! -d "usr/share/applications" ]; then
mkdir -p usr/share/applications
fi
if [ ! -d "usr/share/pixmaps" ]; then
mkdir -p usr/share/pixmaps
fi
# Copy desktop entry if it exists in the package but not in the right place
if [ -f "usr/lib/ytsage-${version}/share/applications/ytsage.desktop" ] && [ ! -f "usr/share/applications/ytsage.desktop" ]; then
cp "usr/lib/ytsage-${version}/share/applications/ytsage.desktop" "usr/share/applications/"
echo "Copied desktop entry to proper location"
fi
# Copy icon if it exists in the package but not in the right place
if [ -f "usr/lib/ytsage-${version}/share/pixmaps/ytsage.png" ] && [ ! -f "usr/share/pixmaps/ytsage.png" ]; then
cp "usr/lib/ytsage-${version}/share/pixmaps/ytsage.png" "usr/share/pixmaps/"
echo "Copied icon to proper location"
fi
# Repackage the data archive with the same compression
case "$data_archive" in
*.tar.xz)
tar cJf "../$data_archive" ./*
;;
*.tar.gz)
tar czf "../$data_archive" ./*
;;
*.tar.zst)
tar --zstd -cf "../$data_archive" ./*
;;
esac
cd ..
# Create the fixed DEB package
ar r "${GITHUB_WORKSPACE}/${deb_file}" debian-binary control.tar.* "$data_archive"
# Clean up
cd "$GITHUB_WORKSPACE"
rm -rf "$temp_deb_dir"
echo "DEB package desktop integration fixed"
fi fi
if [ ! -d "usr/share/pixmaps" ]; then
mkdir -p usr/share/pixmaps
fi
# Copy desktop entry if it exists in the package but not in the right place
if [ -f "usr/lib/ytsage-${version}/share/applications/ytsage.desktop" ] && [ ! -f "usr/share/applications/ytsage.desktop" ]; then
cp "usr/lib/ytsage-${version}/share/applications/ytsage.desktop" "usr/share/applications/"
echo "Copied desktop entry to proper location"
fi
# Copy icon if it exists in the package but not in the right place
if [ -f "usr/lib/ytsage-${version}/share/pixmaps/ytsage.png" ] && [ ! -f "usr/share/pixmaps/ytsage.png" ]; then
cp "usr/lib/ytsage-${version}/share/pixmaps/ytsage.png" "usr/share/pixmaps/"
echo "Copied icon to proper location"
fi
# Repackage the data archive
tar cJf ../data.tar.xz ./*
cd ..
# Create the fixed DEB package
ar r "${GITHUB_WORKSPACE}/${deb_file}" debian-binary control.tar.xz data.tar.xz
# Clean up
cd "$GITHUB_WORKSPACE"
rm -rf "$temp_deb_dir"
echo "DEB package desktop integration fixed"
fi fi
echo "Post-build directory listing:" echo "Post-build directory listing:"