Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Manual merge of git-fs initramfs scripts from:

git diff 1164d83..master usr/share/initramfs-tools/scripts/live
  • Loading branch information...
commit 184d89921a91d8af90bc507b3b46f16e6a7078c1 1 parent 7d889c1
@kaihendry kaihendry authored
View
6 lib/live/boot/cmdline.sh
@@ -267,6 +267,12 @@ Cmdline ()
UNIONTYPE="${_PARAMETER#union=}"
export UNIONTYPE
;;
+
+ git-revision=*)
+ GIT_REVISION="${ARGUMENT#git-revision=}"
+ export GIT_REVISION
+ ;;
+
esac
done
View
3  lib/live/boot/misc-helpers.sh
@@ -8,7 +8,7 @@ is_live_path ()
if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
then
- for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
+ for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2 git
do
if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
then
@@ -86,6 +86,7 @@ mount_images_in_directory ()
match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
+ match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.git" ||
match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
then
[ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
View
39 lib/live/boot/mountroot.sh
@@ -159,6 +159,45 @@ mountroot ()
mount --move /live/image /root/live/image
fi
+
+# If the git-fs code made a bindmount of the git repo, make it available in the real rootfs.
+ if [ -d /.git ]
+ then
+ mkdir "${rootmnt}/.git"
+ # Try to make /.git read-write, by simply remounting it, or by
+ # using a second aufs. Note that mount will return success even
+ # if the filesystem is still ro, so we test for writeability
+ # using touch.
+ if ! (mount -o remount,rw /.git && touch /.git ) && [ "${UNIONTYPE}" = aufs ]
+ then
+ # Overlay a second aufs over /.git. Even though
+ # changes will be lost on reboots, you can still make
+ # a change and push it out before the reboot. We can't
+ # include this in the main aufs mount, since aufs
+ # doesn't handle (bind)mounts in subdirectories.
+ mkdir /cow-git
+ mount -o rw,noatime,mode=755 -t tmpfs tmpfs /cow-git
+ mount -t aufs -o noatime,dirs=/cow-git=rw:/.git=rr aufs "${rootmnt}/.git"
+ else
+ mount --move /.git "${rootmnt}/.git"
+ fi
+
+ # Make sure that HEAD corresponds to the commit
+ # mounted by git-fs
+ if [ -n "$GIT_REVISION" ]
+ then
+ # We don't do a normal (--mixed) reset, since
+ # that also scans the entire working copy to
+ # update the cached info in the index (which is
+ # slow on git-fs / aufs). Instead, we reset HEAD
+ # and the index separately.
+ chroot "${rootmnt}" git --git-dir "/.git" reset --soft "${GIT_REVISION}"
+ fi
+ # Reset the index
+ chroot "${rootmnt}" git --git-dir "/.git" read-tree HEAD
+ fi
+
+
# aufs2 in kernel versions around 2.6.33 has a regression:
# directories can't be accessed when read for the first the time,
# causing a failure for example when accessing /var/lib/fai
View
52 lib/live/boot/overlay.sh
@@ -55,7 +55,7 @@ setup_unionfs ()
done
else
# ${MODULE}.module does not exist, create a list of images
- for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
+ for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir git
do
for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
do
@@ -68,7 +68,7 @@ setup_unionfs ()
if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
then
- for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
+ for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir git
do
for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
do
@@ -98,7 +98,53 @@ setup_unionfs ()
run_scripts /scripts/live-realpremount
log_end_msg
- if [ -d "${image}" ]
+
+ if [ "${image##*.}" = "git" ]
+ then
+ _log_msg git
+ if [ "${UNIONTYPE}" != "unionmount" ]
+ then
+ mpoint="${croot}/${imagename}"
+ rofsstring="${mpoint}=${roopt}:${rofsstring}" && rofslist="${mpoint} ${rofslist}"
+ _log_msg mpoint: $mpoint
+ else
+ mpoint="${rootmnt}"
+ fi
+
+ mkdir -p "${mpoint}"
+ log_begin_msg "Mounting \"${image}\" on \"${mpoint}\" via git-fs"
+ # Replace /etc/mtab with a symlink to
+ # /proc/mounts. This prevents fuse from
+ # calling /bin/mount to update the mtab,
+ # using options that busybox mount does
+ # not understand...
+ ln -sf /proc/mounts /etc/mtab
+
+ # Make sure aufs and fuse both keep persistent inode numbers
+ # (i.e. disable noxino and add noforget), to not confuse
+ # git.
+ noxino_opt=""
+ gitfs_opt="$gitfs_opt,noforget"
+ # This will be later moved into the real rootfs (but we
+ # can't do that now, since the .git dir would end up
+ # underneath the aufs mount).
+ mkdir /.git
+ mount --bind ${image} /.git
+
+ if [ -n "$GIT_REVISION" ]; then
+ gitfs_opt="$gitfs_opt,rev=$GIT_REVISION"
+ fi
+
+ #ulimit -c unlimited # enable core dumps
+ #openvt -c 2 -- sh -c "git-fs -d -o allow_other${noforget_opt} \"${image}\" \"${mpoint}\" 2>&1 | tee /git-fs.log"
+ #sleep 2 # wait for git-fs to be mounted, since openvt returns immediately
+ git-fs -o allow_other${gitfs_opt} "${image}" "${mpoint}"
+
+ log_end_msg
+ #maybe_break gitfs
+ #openvt -c 3 -- /bin/sh
+
+ elif [ -d "${image}" ]
then
# it is a plain directory: do nothing
rofslist="${image} ${rofslist}"
Please sign in to comment.
Something went wrong with that request. Please try again.