#!/bin/bash CWD="$PWD" clean=true HARDLINKED_SFS_unextracted=puli7.3_x86_64-ungoogled-hardlinked.sfs EXTRACTED_SFS=puli7.3_x86_64-ungoogled-hardlinked.sfs.extracted NEW_SFS=puli7.3_x86_64-ungoogled-hardlinked-new.sfs FR_SOURCE_ARCHIVE=/mnt/+mnt+sda5+test_save+ext2/firstRIB_lgo/00fwmods_focalpup64.sfs FR_SOURCE_ORIG=/mnt/+mnt+sda5+test_save+ext2/firstRIB_lgo/01firstrib_rootfs.sfs.extracted [ "$clean" = true ] && rm -rf "$EXTRACTED_SFS" FR_SOURCE="$CWD"/"$EXTRACTED_SFS"/cont/01firstrib_lgo_rootfs if [ ! -d $EXTRACTED_SFS ] || [ ! "$(ls -A $EXTRACTED_SFS)" ] ; then #mkdir -p "$EXTRACTED_SFS" uextract $HARDLINKED_SFS_unextracted || { echo "failed to extract $HARDLINKED_SFS_unextracted" && exit; } if [[ "${HARDLINKED_SFS_unextracted}.extracted" != "$EXTRACTED_SFS" ]]; then mv ${$HARDLINKED_SFS_unextracted}.extracted $EXTRACTED_SFS fi fi EXTRACTED_SFS="$(realpath "$EXTRACTED_SFS")" || { echo "failed realpath \"$HARDLINKED_SFS\"" && exit; } TARGET="$EXTRACTED_SFS"/cont; mkdir -p "$TARGET" MV_LOC="$TARGET/xenial-moved"; mkdir -p $MV_LOC #See: https://forum.puppylinux.com/viewtopic.php?f=53&t=1397&p=15016&hilit=hardlinked#p15016 HL_LOC="$EXTRACTED_SFS"; mkdir -p "$HL_LOC" USE_MULTI_ARCH_DIRS=yes WARN_MV_ARCH=true if [ ! -d "$TARGET" ]; then mkdir -p "$TARGET" rsync -rltDv --link-dest="${HL_LOC}/" "${HL_LOC}/" "${TARGET}/" fi if [ ! -d "$FR_SOURCE_ORIG" ]; then uextract -o "$FR_SOURCE_ORIG" "$FR_SOURCE_ARCHIVE" || { echo "failed to extract $HARDLINKED_SFS_unextracted" && exit; } fi if [ ! -d "$FR_SOURCE_ORIG" ]; then cp -Ra "$FR_SOURCE_ORIG" "$FR_SOURCE" fi if [ ! -d "$FR_SOURCE" ]; then cp -Ra "$FR_SOURCE_ORIG" "$FR_SOURCE" fi #FR_SOURCE=/mnt/+mnt+sda5+test_save+ext2/firstRIB_lego/01firstrib_rootfs.sfs.extracted #Move no longer needed core libs if [ "$USE_MULTI_ARCH_DIRS" = yes ]; then while read arch_dir_rel; do target_arch_dir="$TARGET/$arch_dir_rel" arch_dir="$(basename "$arch_dir_rel")" parent_dir_rel="$(dirname "${arch_dir_rel}")" target_arch_parent="$TARGET/$parent_dir_rel" parent_of_arch_dir="$TARGET/$parent_dir_rel" fp_arch_dir="$parrent_dir/arch_dir" #if [ ! -d "$target_arch_dir" ]; then #source_dir="$FR_SOURCE/$a_dir" source_arch_dir="$FR_SOURCE/$arch_dir_rel" if [ ! -d "$source_arch_dir" ]; then [ -e "$target_arch_dir" ] && rm "$target_arch_dir" ; mkdir -p "$target_arch_dir" else #the read in this warn section causes the outer loop to be skipped so comment out until fixed. #if [ "$WARN_MV_ARCH" = true ]; then #Debugging code #set +x #echo "about to:" #echo " #cd \"$FR_SOURCE\" #echo ./\"${arch_dir_rel}\" | \ #cpio -pdu \"$TARGET\" )" #read -p "Press enter to continue" #set -x #fi ( cd "$FR_SOURCE" echo "./${arch_dir_rel}" | \ cpio -pdu "$TARGET" ) fi #fi while read b_name; do #the read in this warn section causes the outer loop to be skipped so comment out until fixed. #if [ "$WARN_MV_ARCH" = true ]; then #Debugging code #set +x #echo "about to:" #echo " #mv \"$target_arch_parent/$b_name\" \"$target_arch_dir/$b_name\" #( cd \"$target_arch_parent\"; ln -s \"$b_name\" \"$arch_dir/$b_name\" ) " #read -p "Press enter to continue" #set -x #fi rel_path="$(dirname "$arch_dir_rel")/$b_name" case "$rel_path" in lib/lsb|lib/systemd|lib/terminfo) continue; ;; usr/lib/apt|usr/lib/debootstrap|usr/lib/dpkg) continue; ;; usr/lib/locale|usr/lib/mime|usr/lib/NetworkManager) continue; ;; usr/lib/pm-utils|usr/lib/ssl|usr/lib/tmpfiles.d) continue; ;; esac [[ "$target_arch_parent/$b_name" = "$target_arch_dir" ]] && continue mv "$target_arch_parent/$b_name" "$target_arch_dir/$b_name" ( cd "$target_arch_parent"; ln -s "$arch_dir/$b_name" "$b_name" ) done < <(find $target_arch_parent -mindepth 1 -maxdepth 1 -type d | xargs -n 1 basename) done <> "$TARGET/etc/ld.so.conf" export $PATH="$PATH":/usr/local/firstrib/bin >> /etc/profile #maybe do this in /root/.profile while read a_file; do cp -af "$FR_SOURCE/etc/$a_file" "$TARGET/etc/$a_file" done <