From 841084ca97d1c8c5c317bbe85c30cf89b5b5b2bb Mon Sep 17 00:00:00 2001 From: mid-kid Date: Mon, 14 Aug 2017 20:12:28 +0200 Subject: [PATCH] Updated astronautpkg - still requires some testing --- astronaut/astronautpkg | 90 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 10 deletions(-) diff --git a/astronaut/astronautpkg b/astronaut/astronautpkg index d8b7c64..d1fefbe 100755 --- a/astronaut/astronautpkg +++ b/astronaut/astronautpkg @@ -36,15 +36,15 @@ _astronaut_wrapper_post() { fi if [ -d "$dir_install/$dir_prefix/$dir_infodir" ]; then rm -f "$dir_install/$dir_prefix/$dir_infodir/dir" - gzip -9 -r "$dir_install/$dir_prefix/$dir_infodir" + find "$dir_install/$dir_prefix/$dir_infodir" -type f -name '*.info' -exec gzip -9 '{}' \; fi # Strip binaries - find "$dir_install" | xargs file | grep -e "executable" -e "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null | true + find "$dir_install" | xargs file | grep -e "executable" -e "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true # Generate slack-desc for proper compliance, even if it's completely redundant #mkdir -p "$dir_install/install" - #cat > "$dir_install/install/slack-desc" << EOF +#cat > "$dir_install/install/slack-desc" << EOF ## HOW TO EDIT THIS FILE: ## The "handy ruler" below makes it easier to edit a package description. Line ## up the first '|' above the ':' following the base package name, and the '|' @@ -69,24 +69,94 @@ _astronaut_wrapper_post() { # Move configuration files to .new and install them for proper compliance. if [ -d "$dir_install/$dir_prefix/$dir_sysconfdir" ]; then mkdir -p "$dir_install/install" - cat > "$dir_install/install/doinst.sh" << EOF +cat >> "$dir_install/install/doinst.sh" << 'EOF' config() { - NEW="\$1" - OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)" + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" # If there's no config file by that name, mv it over: - if [ ! -r \$OLD ]; then - mv \$NEW \$OLD - elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then # toss the redundant copy - rm \$NEW + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy + rm $NEW fi # Otherwise, we leave the .new copy for the admin to consider... } + EOF find "$dir_install/$dir_prefix/$dir_sysconfdir" -type f -printf '%P\n' | while IFS= read file; do mv "$dir_install/$dir_prefix/$dir_sysconfdir/$file" "$dir_install/$dir_prefix/$dir_sysconfdir/$file.new" echo "config '$dir_prefix/$dir_sysconfdir/$file.new'" >> "$dir_install/install/doinst.sh" done + echo >> "$dir_install/install/doinst.sh" + fi + + # Update desktop database if new files were added + if [ -d "$dir_install/$dir_prefix/$dir_datadir/applications" ]; then + mkdir -p "$dir_install/install" +cat >> "$dir_install/install/doinst.sh" << EOF +if [ -x /$dir_prefix/$dir_bindir/update-desktop-database ]; then + /$dir_prefix/$dir_bindir/update-desktop-database -q $dir_prefix/$dir_datadir/applications >/dev/null 2>&1 +fi + +EOF + fi + + # Update mime database if new files were added + if [ -d "$dir_install/$dir_prefix/$dir_datadir/mime" ]; then + mkdir -p "$dir_install/install" +cat >> "$dir_install/install/doinst.sh" << EOF +if [ -x /$dir_prefix/$dir_bindir/update-mime-database ]; then + /$dir_prefix/$dir_bindir/update-mime-database $dir_prefix/$dir_datadir/mime >/dev/null 2>&1 +fi + +EOF + fi + + # Update icon cache if new files were added + if [ -d "$dir_install/$dir_prefix/$dir_datadir/icons/hicolor" ]; then + mkdir -p "$dir_install/install" +cat >> "$dir_install/install/doinst.sh" << EOF +if [ -e $dir_prefix/$dir_datadir/icons/hicolor/icon-theme.cache ]; then + if [ -x /$dir_prefix/$dir_bindir/gtk-update-icon-cache ]; then + /$dir_prefix/$dir_bindir/gtk-update-icon-cache -f $dir_prefix/$dir_datadir/icons/hicolor >/dev/null 2>&1 + fi +fi + +EOF + fi + + # Compile schemas if new files were added + if [ -d "$dir_install/$dir_prefix/$dir_datadir/glib-2.0/schemas" ]; then + mkdir -p "$dir_install/install" +cat >> "$dir_install/install/doinst.sh" << EOF +if [ -e $dir_prefix/$dir_datadir/glib-2.0/schemas ]; then + if [ -x /$dir_prefix/$dir_datadir/glib-compile-schemas ]; then + /$dir_prefix/$dir_datadir/glib-compile-schemas $dir_prefix/$dir_datadir/glib-2.0/schemas >/dev/null 2>&1 + fi +fi + +EOF + fi + + # Query gio modules if new files were added + if [ -d "$dir_install/$dir_prefix/$dir_libdir/gio/modules" ]; then + mkdir -p "$dir_install/install" +cat >> "$dir_install/install/doinst.sh" << EOF +chroot . /$dir_prefix/$dir_bindir/gio-querymodules $dir_prefix/$dir_libdir/gio/modules/ 1> /dev/null 2> /dev/null + +EOF + fi + + # Install new info files if they were added + if [ -d "$dir_install/$dir_prefix/$dir_infodir" ]; then + mkdir -p "$dir_install/install" + echo "if [ -x /$dir_prefix/$dir_bindir/install-info ]; then" >> "$dir_install/install/doinst.sh" + find "$dir_install/$dir_prefix/$dir_infodir" -type f -name '*.info.gz' -printf '%P\0' | while read -d '' -r file; do + echo " chroot . /$dir_prefix/$dir_bindir/install-info --info-dir=/$dir_prefix/$dir_infodir /$file 2> /dev/null" >> "$dir_install/install/doinst.sh" + done + echo 'fi' >> "$dir_install/install/doinst.sh" + echo >> "$dir_install/install/doinst.sh" fi # Create the package