Find and Load Delta from Original to Modified Raspbian Image

Definition

A delta from original and modified Raspbian image can be created with diff(1), and used to economically create copies or further modified Raspian images.

Objective

To apply this procedure to produce a delta from original to modified Raspbian image suitable for copy or as a starting point for other modified Raspbian images.


Elements (chrononological) (uc)

  1. Mount the Raspian drive to compare.
          mount -t ext4 LABEL=Raspbian /mnt/Raspbian
    	  
  2. If necessary, extract the Raspian image from the original package.
          (cd /tmp; unzip /opt/Raspberry/original/2017-03-02-raspbian-jessie-lite.zip)
    	  
  3. Determine offset within image to Raspbian root partition.
          /sbin/fdisk -l /tmp/2017-03-02-jessie-lite.img
    	  	...
    	    /tmp/2017-03-02-raspbian-jessie-lite.img2      137216 2721791 2584576  1.2G 83 Linux
    	    ...
    	  
  4. Mount the original Raspbian image.
          sudo mkdir -p /mnt/Raspbian.orig
          sudo mount -t ext4 -o loop,offset=$[137216*512] /tmp/2017-03-02-raspbian-jessie-light.img /mnt/Raspbian.orig
          
  5. Compare directories.
          diff -wrq --no-dereference /mnt/Raspbian /mnt/Raspbian.orig >& /tmp/Raspbian.diff
          grep 'Only in /mnt/Raspbian/' /tmp/Raspbian.diff
    	    Only in /mnt/Raspbian/etc/default: hostapd.orig
    	    Only in /mnt/Raspbian/etc/hostapd: hostapd.conf
    	    Only in /mnt/Raspbian/etc/network/interfaces.d: 012_wlan0ap
    	    Only in /mnt/Raspbian/etc/network/disabled_interfaces.d: 011_wlan0
          grep 'Only in /mnt/Raspbian.orig/' /tmp/Raspbian.diff
    	    Only in /mnt/Raspbian/etc/network/interfaces.d: 011_wlan0
          grep -v 'Only in /mnt/' /tmp/Raspbian.diff | cut -d' ' -f2
    	    /mnt/Raspbian/etc/default/hostapd
          
  6. Copy delta.
          mkdir -p /opt/Raspberry/delta/{DELETIONS/Raspbian,Raspbian}
          mkdir -p /opt/Raspberry/delta/Raspbian/{etc,etc/network,etc/default,etc/hostapd}
          for f in Raspbian/etc/{default/hostapd}
          do sudo cp -apr /mnt"$f" /opt/Raspberry/delta"$f"
             sudo cp -apr /mnt"$f".orig /opt/Raspberry/delta"$f".orig
          done
          for f in Raspbian/etc/network/interfaces.d/{012_wlan0ap} \
                   etc/{hostapd/hostapd.conf}
          do sudo cp -apr /mnt"$f" /opt/Raspberry/delta"$f"
          done
          for f in Raspbian/etc/network/disabled_interfaces.d/011_wlan0
          do sudo cp -apr /mnt"$f" /opt/Raspberry/delta/DELETIONS/Raspbian"$f"
          done
          
  7. Apply delta. First use ls to test compatibility. Then uncomment sudo to actually perform.
          find /opt/Raspberry/delta/{boot,home,Raspbian} -type f |
            cut -d/ -f4- |
            grep -v '[.]orig$' |
            while read f
            do
              #sudo mv /mnt"$f"{,.orig}
              #sudo cp -apr /opt/Raspberry/delta"$f" /mnt"$f"
              ls /opt/Raspberry/delta"$f" /mnt"$f"
            done
          find /opt/Raspberry/delta/DELETIONS -type f |
            cut -d/ -f4- |
            grep -v '[.]orig$' |
            while read f
            do
              #sudo rm /mnt"$f"
              ls /mnt"$f"
            done
          

Equipment

Schedule (uc)


Errors (uc)

Instructor Actions (uc)

Student Actions (uc)


Completion Standards (uc)

Bibliography (uc)

(gcc)
pub by Free Software Foundation, Inc.
http://www.gnu.org/software/gcc/