Ticket #834: enter.patch

File enter.patch, 1.7 KB (added by EvanKroske, 23 months ago)

Simple patch for accessing exterior local repos from chroot dev environment.

Line 
160c60,105
2< exec sudo chroot "$CHROOT_PATH" su -l -c "$ENV_EXPORT exec \$SHELL $SU_CMD" build
3---
4> # Mount every local repository in the chroot's sources.list file that doesn't
5> # exist in the chroot file system.
6>
7> # All the local repositories mentioned in chroot's sources.list file
8> localReps=$(egrep -o '(file:[^[:space:]]+)' < "$CHROOT_PATH/etc/apt/sources.list" | sed 's/file://')
9>
10> for localRep in $localReps
11> do
12>     # If the directory doesn't exist in the chroot file system
13>     if [ ! -d "$CHROOT_PATH$localRep" ]
14>     then
15>         # If the directory does exist in the exterior file system
16>         if [ -d "$localRep" ]
17>         then
18>             # Make a mount dir and mount the exterior repository dir to it
19>             sudo mkdir "$CHROOT_PATH$localRep"
20>             sudo mount --bind "$localRep" "$CHROOT_PATH$localRep"
21>         fi
22>     fi
23> done
24>
25> sudo chroot "$CHROOT_PATH" su -l -c "$ENV_EXPORT exec \$SHELL $SU_CMD" build
26>
27> # Strip any useless trailing dots and slashes from the chroot path
28> trimmedChrootPath=$(echo $CHROOT_PATH | sed 's|/\.\?$||')
29>
30> for localRep in $localReps
31> do
32>     # If the local rep has a dir in the chroot fs
33>     if [ -d "$trimmedChrootPath$localRep" ]
34>     then
35>         # If the local rep dir in the chroot fs has been mounted
36>         if fgrep -q "$trimmedChrootPath$localRep" < "/etc/mtab"
37>         then
38>             # Unmount it
39>             sudo umount "$trimmedChrootPath$localRep" "$localRep"
40>         fi
41>         
42>         # If the local rep dir in the chroot fs is now empty
43>         if [ -z `ls $trimmedChrootPath$localRep` ]
44>         then
45>             # Delete it
46>             sudo rm -r "$trimmedChrootPath$localRep"
47>         fi
48>     fi
49> done