#!/bin/bash CWD="$PWD" clean=true #OVERWRITE_TARGET=yes OVERWRITE_MODE=overwrite #overwrite, keep-original, or move USE_NON_FULL_VERSIONS=yes USE_BB_FOR_nonFULL=yes FULL_UTILS=(tar realpath) #HARDLINKED_SFS_unextracted="$(realpath ../puppy_upupgg+d_20.10.sfs)" HARDLINKED_SFS_unextracted="$(realpath ../spup-443.sfs)" EXTRACTED_SFS="$(basename "$HARDLINKED_SFS_unextracted")".extracted BUILTIN_FILE_LIST_PATCH="$CWD/patches/builtin_files" NEW_SFS=2headed_groovyKal.sfs FR_SOURCE_ARCHIVE="$(realpath ../kalipup_CLI_0.0003.sfs)" FR_SOURCE_EXTRACTED=$CWD/"$(basename ${FR_SOURCE_ARCHIVE})".extracted FR_SOURCE_ORIG="${FR_SOURCE_EXTRACTED}" [ "$clean" = true ] && rm -rf "$EXTRACTED_SFS" EXTRACTED_SFS_FP="$CWD"/"$EXTRACTED_SFS" FR_SOURCE="$CWD"/"$EXTRACTED_SFS"/kali/cli if [ ! -d $EXTRACTED_SFS ] || [ ! "$(ls -A $EXTRACTED_SFS)" ] ; then #mkdir -p "$EXTRACTED_SFS" uextract -o . $HARDLINKED_SFS_unextracted || { echo "failed to extract $HARDLINKED_SFS_unextracted" && exit; } if [[ "$(basename ${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"/kali; mkdir -p "$TARGET" #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 [ ! -d "$TARGET" ] && mkdir -p "$TARGET" [ ! "$(ls -A "$TARGET")" ] && rsync -rltDv --exclude /kali --link-dest="${HL_LOC}/" "${HL_LOC}/" "${TARGET}/" MV_LOC="$TARGET/GG-moved"; mkdir -p $MV_LOC #set +x #read -p "press enter to continue" #set -x if [ ! -d "$FR_SOURCE_ORIG" ]; then uextract -o . "$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" mv "$FR_SOURCE_EXTRACTED" "$FR_SOURCE_ORIG" fi if [ ! -d "$FR_SOURCE" ]; then cp -Ra "$FR_SOURCE_ORIG" "$FR_SOURCE" fi set -x cd "$TARGET" if [ -d ./root/.packages ]; then #mkdir -p ./var/packages mv ./root/.packages ./var/packages cd ./root ln -s ../var/packages .packages cd "$CWD" fi [ ! -z "$BUILTIN_FILE_LIST_PATCH" ] && cp -arfv --remove-destination "${BUILTIN_FILE_LIST_PATCH}"/* "$TARGET" CHROOT_DIR="$TARGET" bash -x ./remove_builtin.sh --pkg-list uninstallsfs "$TARGET" set +x #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" echo "/lib/x86_64-linux-gnu" >> "$TARGET/etc/ld.so.conf" echo "/usr/local/lib/x86_64-linux-gnu" >> "$TARGET/etc/ld.so.conf" echo "/usr/lib/x86_64-linux-gnu" >> "$TARGET/etc/ld.so.conf" echo "include /etc/ld.so.conf.d/*.conf" >> "$TARGET/etc/ld.so.conf" sed -i '/^$/d' "$TARGET/etc/ld.so.conf" echo "export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:/usr/local/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH" > "$TARGET/etc/profile" echo "export $PATH=$PATH:/usr/local/firstrib/bin" >> "$TARGET/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 < /etc/profile cd "$CWD" ./sync_file_lists.sh ./sync_dpkg_fm_builtin.sh mksquashfs "$EXTRACTED_SFS" "$NEW_SFS"