6085 comments
2357 subscribers
6223 on Twitter
Subscribe! Feed reader E-mail

sacha/fix-tla-log {{04.04.21,EmacsHacks}} 11:17

(defun sacha/fix-tla-log ()
  "Correct a wrong commit.
Run this inside the arch subdirectory for the patch in your
repository, not your project tree."
  ;; Copy the log file
   (let*
       ((directory (car (file-expand-wildcards "*.patches")))
        modes
        (log-file
         (car
          (file-expand-wildcards
           (concat (file-name-as-directory directory)
                   "new-files-archive/{arch}/*/*/*/sacha@free.net.ph--main/patch-log/patch-*"))))
        (tar-file
         (car (file-expand-wildcards "*.tar.gz")))
        log-md5 tar-md5)
     (when directory
       (if (file-newer-than-file-p "log" log-file)
           (progn
             (delete-file log-file)
             (copy-file "log" log-file))
         (delete-file "log")
         (copy-file log-file "log"))
       ;; Recreate the tar.gz
       (delete-file tar-file)
       (call-process "tar" nil nil nil "zcvf" tar-file directory)
       ;; Calculate checksums
       (with-temp-buffer
         (call-process "md5sum" nil t nil "log" tar-file)
         (goto-char (point-min))
         (re-search-forward "^\\([^ ]+\\)\\s-+log" nil t)
         (setq log-md5 (match-string 1))
         (re-search-forward "^\\([^ ]+\\)" nil t)
         (setq tar-md5 (match-string 1)))
       (with-temp-buffer
         (setq modes (file-modes "checksum"))
         (insert-file-contents "checksum")
         (goto-char (point-min))
         (re-search-forward "^Signature-for")
         (delete-region (point-min) (match-beginning 0))
         (re-search-forward "^md5\\s-+log\\s-+\\([^ ]+\\)$")
         (replace-match log-md5 t t nil 1)
         (re-search-forward "^md5\\s-+.+?\\.tar\\.gz\\s-+\\([^ ]+\\)$")
         (replace-match tar-md5 t t nil 1)
         (when (re-search-forward "BEGIN PGP SIGNATURE" nil t)
           (delete-region (line-beginning-position) (point-max)))
         (let ((pgg-output-buffer (current-buffer)))
           (pgg-sign t))
         (delete-file "checksum")
         ;; Sign the checksum
         (write-file "checksum")
         (set-file-modes "checksum" modes)))))
Short URL: http://sachachua.com/blog/p/1986

On This Day...

  • 2013: Weekly review: Week ending April 19, 2013 — 修正した:もっと丁寧です! いろいろな事を準備しました。来週は忙しくなりそうんです。日曜日から火曜日まで会議で図をかきます。木曜日も働きます。でも、土曜日にマッサージがあります。楽しみにしています。 私と主人は日本語を勉強します。主人は平仮名を覚えています。私は漢字を復習しています。私達は今年日本へ行きたいです。日本語は難しいですが、がんばります! 私の下手な日本語ですみません。改善するために、練習しなければなりません。誤りがあれば訂正お願いします。^_^ We prepared various things because next week is going to be busy. I’ll be drawing at a conference from Sunday [...]
  • 2012: Waking up with barcodes — I’d been looking for a wake-up alarm that was good at getting me up and out of bed. It turned [...]
  • 2011: Compost magic and happiness — The compost heap steamed in the afternoon sun. “I’d never seen it do that before,” said W-. Neither had I. [...]
  • 2010: Being visible — A colleague asked me to write about the benefits of being visible. I want to share the experience of it. [...]
  • 2009: Q1 2009 Newsletter — This is a quarterly email with my favorite blog posts, books, links, and personal updates. You received this newsletter because [...]
  • 2009: My financial network map and virtual envelope system — Taking Bargaineering‘s advice to map out my financial network, I decided to diagram how my accounts relate to each other: I [...]
  • 2006: Life on a sugar high — Stephen gave me the leftover Timbits (munchkins that say “eh”) for lunch earlier. He probably regretted that decision, though, as I [...]
  • 2006: Happy girl — Again, very fun day at IBM. =) It’s so much fun working on something exciting and new, and blogging has helped [...]
  • 2006: Solved the SPAM problem — Somehow, I managed to completely scan past it. Blanked out. It was right on the shelf. Okay, well, it was on [...]
  • 2006: Dum da dum dum… — Imagine Beethoven’s 5th playing right now. My hard disk is Not Happy! I restored my contacts file from the automatic numbered backups [...]
  • 2006: The case of the missing SPAM — I seem to have woken up in a freakish alternate universe. I don’t understand. I simply don’t understand. Did I _imagine_ [...]
  • 2005: Google search changes — http://www.google.com.ph ‘s “I’m Feeling Lucky” button has changed from “Maganda ang Kutob Ko” to “Heto na ang pinakahinahanap-hanap ko!”. =) On Technorati: filipino, tagalog, [...]
  • 2005: Hipster PDA — 3×5 index cards totally rock. On Technorati: hipster, hipsterpda, organizer あなたは黒い猫が好きですか。 Do you like a black cat?
  • 2005: sacha/planner-add-recent — (defun sacha/planner-add-recent () "Add the current note to the list of recent entries, trimmed at 10." (interactive) [...]
  • 2005: sacha/emacs-wiki-markup-string — (defun sacha/emacs-wiki-markup-string (string) "Mark up STRING according to `emacs-wiki-publishing-rules'. No header or footer is added." (let ((emacs-wiki-project emacs-wiki-current-project)) [...]
  • 2005: Mensa Qualifying Session — From http://aisrael.multiply.com/calendar/item/53 : Start May 7, ’05 9:00a End May 7, ’05 3:00p Location Private Room, Oakwood Premier Mensa Philippines is an emerging national Mensa under the [...]
  • 2005: Sticky notes hack — 43 folders is collecting neat Post-it hacks. I love using Post-it notes to organize my articles and presentations, writing down keywords [...]
  • 2005: Running Linux on G-mail — http://www.hackaday.com/entry/1234000990039809/ and http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html describe how to mount your Gmail account as a filesystem under Linux. Interesting… 猫はじゅうたんをひっかき始めた。 The cat started scratching to scratch the carpet. On [...]
  • 2004: emacs-wiki-link-url: return relative links — (defadvice emacs-wiki-link-url (around sacha activate) "Return relative links if possible." ad-do-it (when ad-return-value (unless [...]

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging