Skip to content

Feature/copy hard and soft links #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions create-changelog-to-go-from-old-to-new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ echo "List of changes necessary to go from old image contents to new: "
rsync -a -x --human-readable --delete-after --checksum --dry-run --itemize-changes --exclude .docker-image-diff "$RESTRICT_DIFF_TO_PATH/" "rsync://rsync@old/root$RESTRICT_DIFF_TO_PATH/" | tee $OUT/changes.rsync.log

# Add files to add to a tar archive
cat $OUT/changes.rsync.log | grep '^<f' | while read -a cols; do echo "$RESTRICT_DIFF_TO_PATH/"${cols[@]:1}; done > $OUT/files-to-add.list
tar -cf $OUT/files-to-add.tar -T $OUT/files-to-add.list 2>&1 | grep -v "Removing leading"
cat $OUT/changes.rsync.log | grep -E '^<f|^cL|^hf' | while read -a cols; do echo "$RESTRICT_DIFF_TO_PATH/"${cols[@]:1}; done > $OUT/files-to-add_2.list

# soft links (^cL in the grep above) have -> in the list which must be removed. Hard links ^hf have =>
cat $OUT/files-to-add_2.list | grep -oP '^\K.*?(?= ->| =>|$)' > $OUT/files-to-add.list
tar -C / -cf $OUT/files-to-add.tar -T $OUT/files-to-add.list 2>&1

# Add files to remove to a list
cat $OUT/changes.rsync.log | grep '^*deleting' | while read -a cols; do echo "$RESTRICT_DIFF_TO_PATH/"${cols[@]:1}; done > $OUT/files-to-remove.list
cat $OUT/changes.rsync.log | grep '^*deleting' | grep -v 'tmp\/\.rsyncd\.conf' | while read -a cols; do echo "$RESTRICT_DIFF_TO_PATH/"${cols[@]:1}; done > $OUT/files-to-remove.list

# Informational output
echo
Expand All @@ -20,6 +23,6 @@ echo "Number of files to remove: "
wc $OUT/files-to-remove.list
echo
echo "Changes not accounted for: "
cat $OUT/changes.rsync.log | grep -v '^<f' | grep -v '^*deleting'
cat $OUT/changes.rsync.log | grep -v -E '^<f|^cL|^hf' | grep -v '^*deleting'
echo
echo "Press CTRL-C to continue"
3 changes: 3 additions & 0 deletions expose-filesystem-root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
echo "[root]" > /tmp/.rsyncd.conf;
echo "path = /" >> /tmp/.rsyncd.conf;
echo "read only = false" >> /tmp/.rsyncd.conf;
echo "uid = 0" >> /tmp/.rsyncd.conf;
echo "gid = 0" >> /tmp/.rsyncd.conf;

rsync --daemon --port 873 --no-detach -vv --config /tmp/.rsyncd.conf
7 changes: 7 additions & 0 deletions shrink_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
echo "Usage shrink_images.sh <old_image> <new_image> <resultant_image> [RESTRICT_DIFF_TO_PATH]"
export RESTRICT_DIFF_TO_PATH=$4
export OLD_IMAGE=$1
export NEW_IMAGE=$2
docker-compose -f rsync-image-diff.docker-compose.yml up
docker-compose -f shell.docker-compose.yml -f process-image-diff.docker-compose.yml run --rm shell ./generate-dockerfile.sh
cd output; docker build -t $3 .; cd ..
2 changes: 1 addition & 1 deletion template.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ${OLD_IMAGE}
ADD files-to-add.tar /
ADD files-to-remove.list /.files-to-remove.list
RUN if [ -s /.files-to-remove.list ]; then xargs -d '\n' -a /.files-to-remove.list rm && rm /.files-to-remove.list; fi
RUN if [ -s /.files-to-remove.list ]; then xargs -d '\n' -a /.files-to-remove.list rm; fi; rm /.files-to-remove.list;