Hi,
I'm trying to create a Makefile that would automate remastering Knoppix distribution.
As a part of the process I am mounting using linux cloop device a compressed filesystem and copy the content out of it to separate dir. However during that process I need to preserve hard links and it seems it is not working.
I've tried using:
- cp -a --preserve=all
- rsync -a -H
- tar | tar version
All of them are making original hard-linked files a separate files.
The lines in the code are:
#sudo nice tar -C $(NAME).cloop -cf - . | sudo nice tar -C $(NAME).tree -xvpf -
sudo cp -av --preserve=all $(NAME).cloop $(NAME).tree
#sudo rsync -x -a -H --progress --delete $(NAME).cloop/ $(NAME).tree
Can you please advise what can be wrong?
Below is the full content of the Makefile
SITE=ftp://sunsite.icm.edu.pl/pub/Linux/distributions/knoppix/
NAME=KNOPPIX_V6.2.1CD-2010-01-31-EN
PWD=$(shell pwd)
.PHONY: all clean test test-orig
all: $(NAME)-cherry88.iso
$(NAME).iso:
wget -c -O $(NAME).iso.download $(SITE)/$(NAME).iso && mv $(NAME).iso.download $(NAME).iso
clean:
if [ ! -z "`mount | grep "$(PWD)/$(NAME).cloop"`" ]; then sudo umount $(NAME).cloop && rm -f $(NAME).cloop.mount || test 1=1; fi
if [ ! -z "`mount | grep "$(PWD)/$(NAME)"`" ]; then sudo umount $(NAME) && rm -f $(NAME).mount || test 1=1; fi
$(NAME).mount: $(NAME).iso
mkdir -p $(NAME)
if [ -z "`mount | grep "$(PWD)/$(NAME)"`" ]; then sudo mount -o loop $(NAME).iso $(NAME); fi
touch $(NAME).mount
$(NAME).cloop.iso: $(NAME).mount
nice extract_compressed_fs $(NAME)/KNOPPIX/KNOPPIX - > $(NAME).cloop.iso
touch $(NAME).cloop.iso
$(NAME).cloop.mount: $(NAME).cloop.iso
mkdir -p $(NAME).cloop
if [ -z "`mount | grep "$(PWD)/$(NAME).cloop"`" ]; then sudo mount -o loop $(NAME).cloop.iso $(NAME).cloop; fi
touch $(NAME).cloop.mount
$(NAME).cdtree.touch: $(NAME).mount
sudo mkdir -p $(NAME).cdtree
sudo rm -Rf $(NAME).cdtree
#sudo nice tar -C $(NAME) --exclude=KNOPPIX/KNOPPIX -cf - . | sudo nice tar -C $(NAME).cdtree -xvpf -
sudo nice cp -av --preserve=all $(NAME) $(NAME).cdtree
#sudo rsync -x -a -H --progress --delete $(NAME)/ $(NAME).cdtree
touch $(NAME).cdtree.touch
$(NAME).tree.touch: $(NAME).cloop.mount
sudo mkdir -p $(NAME).tree
sudo rm -Rf $(NAME).tree
#sudo nice tar -C $(NAME).cloop -cf - . | sudo nice tar -C $(NAME).tree -xvpf -
sudo cp -av --preserve=all $(NAME).cloop $(NAME).tree
#sudo rsync -x -a -H --progress --delete $(NAME).cloop/ $(NAME).tree
touch $(NAME).tree.touch
$(NAME).cdtree/KNOPPIX/KNOPPIX: $(NAME).tree.touch $(NAME).cdtree.touch $(NAME).cdtree.mods
#nice -n 5 create_compressed_fs - 65536 | \
#
sudo rm -f $(NAME).cdtree/KNOPPIX/KNOPPIX || test 1=1
nice mkisofs -R -U -V "KNOPPIX.net filesystem" -publisher "KNOPPIX www.knoppix.net" -v \
-hide-rr-moved -cache-inodes -pad $(NAME).tree | \
sudo nice -n 5 create_compressed_fs -B 65536 -f tmp - $(NAME).cdtree/KNOPPIX/KNOPPIX
$(NAME)-cherry88.iso: $(NAME).cdtree/KNOPPIX/KNOPPIX
sudo chmod a+w $(NAME).cdtree/KNOPPIX/sha1sums
cd $(NAME).cdtree; sudo find -type f -not -name sha1sums -not -name boot.cat -not -name isolinux.bin \
-exec sha1sum '{}' \; > KNOPPIX/sha1sums
sudo chmod a-w $(NAME).cdtree/KNOPPIX/sha1sums
sudo nice mkisofs -pad -l -r -J -v -V "KNOPPIX" -no-emul-boot -boot-load-size 4 \
-boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
-hide-rr-moved -o $(NAME)-cherry88.iso $(NAME).cdtree
$(NAME).cloop.md5sums: $(NAME).cloop.mount
cd $(NAME).cloop && sudo nice find . -type f -print0 | nice sort -z | sudo nice xargs -0 ls -l | awk '{ print $$1" "$$2" "$$3" "$$4" "$$8 }' > ../$(NAME).cloop.ls
cd $(NAME).cloop && sudo nice find . -type f -print0 | nice sort -z | sudo nice xargs -0 md5sum > ../$(NAME).cloop.md5sums
$(NAME).md5sums: $(NAME).mount
cd $(NAME) && sudo nice find . -type f -print0 | nice sort -z | sudo nice xargs -0 ls -l | awk '{ print $$1" "$$2" "$$3" "$$4" "$$8 }' > ../$(NAME).ls
cd $(NAME) && sudo nice find . -type f -print0 | nice sort -z | sudo nice xargs -0 md5sum > ../$(NAME).md5sums
$(NAME).cdtree.md5sums: $(NAME).cdtree.touch
cd $(NAME).cdtree && sudo nice find . -type f -print0 | nice sort -z | sudo nice xargs -0 ls -l | awk '{ print $$1" "$$2" "$$3" "$$4" "$$8 }'> ../$(NAME).cdtree.ls
cd $(NAME).cdtree && sudo nice find . -type f -print0 | nice sort -z | sudo nice xargs -0 md5sum > ../$(NAME).cdtree.md5sums
$(NAME).tree.md5sums: $(NAME).tree.touch
cd $(NAME).tree && sudo nice find . -type f -print0 | nice sort -z | sudo nice xargs -0 ls -l | awk '{ print $$1" "$$2" "$$3" "$$4" "$$8 }' > ../$(NAME).tree.ls
cd $(NAME).tree && sudo nice find . -type f -print0 | nice sort -z | sudo nice xargs -0 md5sum > ../$(NAME).tree.md5sums
# MODYFIKACJE
$(NAME).cdtree.mods: $(NAME).cdtree.touch
# no 3d
# sudo sed -i '' -e 's/window_manager=compiz/window_manager=openbox-lxde/g' $(NAME).tree/etc/xdg/lxsession/LXDE/desktop.conf
# touch
touch $(NAME).cdtree.mods
test: $(NAME)-cherry88.iso
qemu -m 512 -cdrom $(NAME)-cherry88.iso -boot d
test-orig:
qemu -m 512 -cdrom $(NAME).iso -boot d
changes: $(NAME).cloop.md5sums $(NAME).tree.md5sums
diff -u $(NAME).cloop.md5sums $(NAME).tree.md5sums > changes; test 1=1
diff -u $(NAME).cloop.ls $(NAME).tree.ls > changes-ls; test 1=1
changes-cd: $(NAME).md5sums $(NAME).cdtree.md5sums
diff -u $(NAME).md5sums $(NAME).cdtree.md5sums > changes-cd
diff -u $(NAME).ls $(NAME).cdtree.ls > changes-cd-ls
The command:
make changes
will work for a longer moment and produce changes file which is a diff of mounted cloop device and copyied tree content.