]> gitweb.fluxo.info Git - hydra.git/commitdiff
Bootless: switching to git-annex
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 2 Sep 2013 02:26:20 +0000 (23:26 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 2 Sep 2013 02:26:20 +0000 (23:26 -0300)
share/hydra/bootless

index 8601ddd87594b72697112529de4f47ef2a96ca01..5b5300c96cd7b24d9314fa7aba6828253463228e 100755 (executable)
@@ -31,6 +31,15 @@ function hydra_bootless_folder {
   fi
 }
 
+# Sync bootless folder
+function hydra_bootless_rsync {
+  # Exclude git folder and follow git-annex symlinks
+  $sudo rsync -CLavz --exclude boot $1/ $2/
+
+  # Make sure there's a symlink to itself
+  ( cd $2 && ln -s . boot )
+}
+
 # Make a boot device
 function hydra_bootless_make {
   # Set folder
@@ -96,13 +105,23 @@ EOF
   
   # Copy data
   if [ "$rsync" == "true" ]; then
-    $sudo rsync -Cav ${BOOTLESS_DIR}/ ${tmpdir}/boot/
+    hydra_bootless_rsync ${BOOTLESS_DIR} ${tmpdir}/boot
   else
-    $sudo git clone --depth=1 file:///${BOOTLESS_DIR} ${tmpdir}/boot
+    #$sudo git clone --depth=1 file:///${BOOTLESS_DIR} ${tmpdir}/boot
+    $sudo git clone file:///${BOOTLESS_DIR} ${tmpdir}/boot
     if [ $? != 0 ]; then
       echo "Error: failed to clone repository \"${BOOTLESS_DIR}\" in \"${tmpdir}\" (errno: $?)."
       exit 1
     fi
+
+    (
+      cd ${tmpdir}/boot && git annex init && git annex untrust here && git annex sync && git annex get .
+    )
+
+    if [ $? != 0 ]; then
+      echo "Error: failed to get files into repository \"${BOOTLESS_DIR}\" in \"${tmpdir}\" (errno: $?)."
+      exit 1
+    fi
   fi
   
   # Grub legacy
@@ -171,9 +190,10 @@ function hydra_bootless_update {
 
   # Copy data
   if [ -d "${tmpdir}/boot/.git" ]; then
-    ( cd ${tmpdir}/boot && $sudo git pull origin master )
+    #( cd ${tmpdir}/boot && $sudo git pull origin master )
+    ( cd ${tmpdir}/boot && $sudo git annex sync && git annex get . )
   else
-    $sudo rsync -Cav ${BOOTLESS_DIR}/ ${tmpdir}/boot/
+    hydra_bootless_rsync ${BOOTLESS_DIR} ${tmpdir}/boot
   fi
 
   # Finalize
@@ -187,13 +207,16 @@ function hydra_bootless_init {
 
   if [ ! -z "$1" ]; then
     # Clone from url
-    git clone $1 $HYDRA_FOLDER/bootless
+    git clone $1 $HYDRA_FOLDER/bootless &&
+      ( cd $HYDRA_FOLDER/bootless && git annex init && git annex sync )
     exit $?
   fi
 
   # Create a fresh repository
   mkdir -p $HYDRA_FOLDER/bootless/{default,custom,grub}
   mkdir -p $HYDRA_FOLDER/bootless/default/{debian,memtest,ubuntu}
+  touch $HYDRA_FOLDER/bootless/{default,custom,grub}/.empty
+  touch $HYDRA_FOLDER/bootless/default/{debian,memtest,ubuntu}/.empty
   ( cd $HYDRA_FOLDER/bootless && ln -s . boot)
 
   if [ -f "/boot/memtest86+.bin" ]; then
@@ -243,7 +266,12 @@ EOF
   (
   cd $HYDRA_FOLDER/bootless
   git init
-  git add .
+  git annex init
+  git add boot
+  git add {default,custom,grub}/.empty
+  git add default/{debian,memtest,ubuntu}/.empty
+  git add grub/grub.cfg
+  git annex add .
   git commit -a -m "Initial import"
   )
 
@@ -345,7 +373,7 @@ function hydra_bootless_image {
 
   # Copy data
   tmpdir=`mktemp -d`
-  $sudo rsync -Cav ${BOOTLESS_DIR}/ ${tmpdir}/boot/
+  hydra_bootless_rsync ${BOOTLESS_DIR} ${tmpdir}/boot
 
   # Make rescue disk
   grub-mkrescue -o ${output} ${tmpdir}
@@ -390,7 +418,7 @@ function hydra_bootless_usage {
 }
 
 # Check for requirements
-for req in parted; do
+for req in parted git-annex; do
   hydra_install_package $req
 done