From 1f3eb8d6eca0987dde68d6b1fa542814c77149a2 Mon Sep 17 00:00:00 2001
From: Eduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Date: Sun, 4 May 2008 21:25:52 -0500
Subject: [PATCH] Add update.latest

---
 extra/update/backup/backup.factor | 25 +++++++++++++++
 extra/update/latest/latest.factor | 53 +++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
 create mode 100644 extra/update/backup/backup.factor
 create mode 100644 extra/update/latest/latest.factor

diff --git a/extra/update/backup/backup.factor b/extra/update/backup/backup.factor
new file mode 100644
index 0000000000..bb6d17f6dd
--- /dev/null
+++ b/extra/update/backup/backup.factor
@@ -0,0 +1,25 @@
+
+USING: namespaces io.files bootstrap.image builder.util ;
+
+IN: update.backup
+
+: backup-boot-image ( -- )
+  my-boot-image-name
+  { "boot." my-arch "-" [ "datestamp" get ] ".image" } to-string  
+  move-file ;
+
+: backup-image ( -- )
+  "factor.image"
+  { "factor" "-" [ "datestamp" get ] ".image" } to-string
+  move-file ;
+
+: backup-vm ( -- )
+  "factor"
+  { "factor" "-" [ "datestamp" get ] } to-string
+  move-file ;
+
+: backup ( -- )
+  datestamp "datestamp" set
+  backup-boot-image
+  backup-image
+  backup-vm ;
diff --git a/extra/update/latest/latest.factor b/extra/update/latest/latest.factor
new file mode 100644
index 0000000000..df057422f9
--- /dev/null
+++ b/extra/update/latest/latest.factor
@@ -0,0 +1,53 @@
+
+USING: kernel namespaces system io.files bootstrap.image http.client
+       builder.util update update.backup ;
+
+IN: update.latest
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: git-pull-master ( -- )
+  image parent-directory
+    [
+      { "git" "pull" "git://factorcode.org/git/factor.git" "master" }
+      run-command
+    ]
+  with-directory ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: remote-latest-image ( -- url )
+  { "http://factorcode.org/images/latest/" my-boot-image-name } to-string ;
+
+: download-latest-image ( -- ) remote-latest-image download ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: rebuild-latest ( -- )
+  image parent-directory
+    [
+      backup
+      download-latest-image
+      make-clean
+      make
+      boot
+    ]
+  with-directory ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: update-latest ( -- )
+  image parent-directory
+    [
+      git-id
+      git-pull-master
+      git-id
+      = not
+        [ rebuild-latest ]
+      when
+    ]
+  with-directory ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+MAIN: update-latest
\ No newline at end of file