bug 882635: move tools from https://mxr.mozilla.org/mozilla/source/tools/release/bin/ to hg. r=nthomas
authorBen Hearsum <bhearsum@mozilla.com>
Fri, 14 Jun 2013 10:36:49 -0400
changeset 3769 ba16c14cf17e3ebdb29c23612e9ab7bab88b4ac1
parent 3768 aacc1faa8ffeae2754aa69d6f458e5394c5af3fb
child 3770 3b7d5f7cb545ab412e48ec28311e2d34153b1149
child 3774 527d8af0a31bab9e291acb00cdcfb805bb303a63
push id2732
push userbhearsum@mozilla.com
push dateFri, 14 Jun 2013 14:36:55 +0000
reviewersnthomas
bugs882635
bug 882635: move tools from https://mxr.mozilla.org/mozilla/source/tools/release/bin/ to hg. r=nthomas
release/add-promptWaitTime.py
release/backupsnip
release/backupsnip-nightly
release/pushsnip
new file mode 100755
--- /dev/null
+++ b/release/add-promptWaitTime.py
@@ -0,0 +1,48 @@
+#! /usr/bin/env python
+
+import os
+import sys
+from optparse import OptionParser
+
+parser = OptionParser()
+parser.add_option("-p", "--path", action="store", dest="basepath",
+                  help="Path to process")
+parser.add_option("-w", "--wait", action="store", type="int", dest="wait",
+                  help="Path to process")
+(options, args) = parser.parse_args()
+
+if not options.basepath or not os.path.isdir(options.basepath):
+    print "Error: path must be specified"
+    sys.exit(1)
+
+if not options.wait or options.wait < 0:
+    print "Error: wait time must be an integer greater than 0"
+    sys.exit(1)
+
+mod_count = 0
+total_count = 0
+
+for root, dirs, files in os.walk(options.basepath):
+    for f in files:
+      fullpath = os.path.join(root, f)
+      total_count += 1
+
+      # leave empty files alone
+      if os.path.getsize(fullpath) == 0:
+          continue
+
+      content = open(fullpath).readlines()
+
+      # bail if this is version=1 snippet
+      if 'version=1' in content[0]:
+          continue
+
+      if 'promptWaitTime' not in content:
+          content.append('promptWaitTime=%i' % options.wait)
+          mod_count += 1
+
+          fd = open(fullpath,'w')
+          fd.writelines(content)
+          fd.close
+
+print "modified %s of %s files" % (mod_count, total_count)
new file mode 100755
--- /dev/null
+++ b/release/backupsnip
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+set -e
+#set -v
+
+LIVE_SNIPPET_DIR=/opt/aus2/incoming/3
+BACKUP_DIR=/opt/aus2/snippets/backup
+STAGING_DIR=/opt/aus2/snippets/staging
+
+WC=/usr/bin/wc
+DATE=/bin/date
+TAR=/bin/tar
+SED=/bin/sed
+GREP=/bin/grep
+
+if test -z $1; then 
+   echo Usage: $0 [snippet-directory-to-sync-in from $STAGING_DIR]
+   exit 1
+fi
+
+newSnippetDir=`echo $1 | $SED -e 's/\///'g`
+
+if ! test -d $STAGING_DIR/$newSnippetDir; then
+   echo Usage: $0 [snippet-directory-to-sync-in from $STAGING_DIR]
+   exit 1
+fi
+
+currentDate=`$DATE +%Y%m%d`
+
+## We use the shell's expansion capabilites to get a list of other snippet
+## directories we may have pushed today... kinda lame, but it works.
+
+pushd $BACKUP_DIR > /dev/null
+preDirCount=`echo $currentDate-?-pre-* | $GREP -v \? | $WC -w`
+popd > /dev/null
+
+## Increment the count by one, for the new snippet backup directory we're
+## about to create
+let nextPreDirCount=$preDirCount+1
+#echo $nextPreDirCount
+backupDirName=$currentDate-$nextPreDirCount-pre-$newSnippetDir
+
+### Find list of directories that change
+absNewSnippetDir=$STAGING_DIR/$newSnippetDir
+changedDirs=$(find $absNewSnippetDir -maxdepth 4 -mindepth 4 -type d | $SED s,$absNewSnippetDir/,,g)
+args=""
+### Skip directories that don't exist in the live snippets directory
+### no need to back them up, since they don't exist yet!
+for d in $changedDirs; do
+    if [ ! -d $LIVE_SNIPPET_DIR/$d ]; then
+        echo Ignoring $d
+    else
+        args="$args $d"
+    fi
+done
+
+if [ -z "$args" ]; then
+    echo
+    echo 'Nothing to backup. There could be something wrong, or you could'
+    echo 'be creating new directories (eg test snippets for a major update).'
+    exit 0
+fi
+
+pushd $LIVE_SNIPPET_DIR > /dev/null
+echo Running /usr/bin/time -p -o $BACKUP_DIR/$backupDirName.time $TAR cfvz $BACKUP_DIR/$backupDirName.tar.gz $args
+/usr/bin/time -p -o $BACKUP_DIR/$backupDirName.time $TAR cfvz $BACKUP_DIR/$backupDirName.tar.gz $args
+popd > /dev/null
+
+exit 0
new file mode 100755
--- /dev/null
+++ b/release/backupsnip-nightly
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+set -e
+#set -v
+
+LIVE_SNIPPET_DIR=/opt/aus2/incoming/3
+BACKUP_DIR=/opt/aus2/snippets/backup
+
+WC=/usr/bin/wc
+DATE=/bin/date
+TAR=/bin/tar
+GREP=/bin/grep
+SCP=/usr/bin/scp
+
+currentDate=`$DATE +%Y%m%d`
+
+## We use the shell's expansion capabilites to get a list of other snippet
+## directories we may have pushed today... kinda lame, but it works.
+
+pushd $BACKUP_DIR > /dev/null
+backupDirCount=`echo $currentDate-nightly-?.* | $GREP -v \? | $WC -w`
+popd > /dev/null
+
+## Increment the count by one, for the new snippet backup directory we're
+## about to create
+let backupDirCount=$backupDirCount+1
+backupDirName=$currentDate-nightly-$backupDirCount
+
+# Make the backup. This takes forever, thanks NFS!
+# don't forget to update check-sync if you extend the exclude list
+pushd $LIVE_SNIPPET_DIR > /dev/null
+/usr/bin/time -p -o $BACKUP_DIR/$backupDirName.time $TAR cfj $BACKUP_DIR/$backupDirName.tar.bz2 . \
+  --exclude 'Firefox/1.5*' --exclude 'Firefox/2.0*' --exclude 'Firefox/3.0*' \
+  --exclude 'Firefox/3.1*' --exclude 'Firefox/3.5*' --exclude 'Thunderbird/1.5*'
+popd > /dev/null
+
+# push the file over to Phoenix to aid checking all is in sync there
+if [[ 'dm-ausstage01.mozilla.org' == `uname -n` ]]; then
+  $SCP -q $BACKUP_DIR/$backupDirName.tar.bz2 dp-ausstage01:$BACKUP_DIR/
+fi
+
+exit 0
new file mode 100755
--- /dev/null
+++ b/release/pushsnip
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+set -e
+#set -v
+
+unset SSH_AUTH_SOCK
+
+LIVE_SNIPPET_DIR=/opt/aus2/incoming/3
+STAGING_DIR=/opt/aus2/snippets/staging
+PUSHED_DIR=/opt/aus2/snippets/pushed
+
+RSYNC=/usr/bin/rsync
+SED=/bin/sed
+
+## Reincarnate when SCL3 has aus dist setup, ignore for now
+if [[ 'dm-ausstage01.mozilla.org' == `uname -n` ]]; then
+  UPDATE_PHX=1
+  PHX_HOST=dp-ausstage01.phx.mozilla.com
+  PHX_USER=ffxbld
+  PHX_KEY=~/.ssh/auspush
+else
+  UPDATE_PHX=0
+fi
+
+if test -z $1; then 
+   echo Usage: $0 [snippet-directory-to-sync-in from $STAGING_DIR]
+   exit 1
+fi
+
+newSnippetDir=`echo $1 | $SED -e 's/\///'g`
+
+if ! test -d $STAGING_DIR/$newSnippetDir; then
+   echo Usage: $0 [snippet-directory-to-sync-in from $STAGING_DIR]
+   exit 1
+fi
+
+# publish the new snippets
+echo "---------------------------------------------------------------------------"
+echo Updating PHX1:
+echo Running /usr/bin/time -p -o $PUSHED_DIR/$1.time $RSYNC -PaO $STAGING_DIR/$1/* $LIVE_SNIPPET_DIR
+/usr/bin/time -p -o $PUSHED_DIR/$1.time $RSYNC -PaO $STAGING_DIR/$1/* $LIVE_SNIPPET_DIR
+echo
+for d in `ls $STAGING_DIR/$1/`; do
+  echo Touching $LIVE_SNIPPET_DIR/$d
+  touch $LIVE_SNIPPET_DIR/$d
+done
+
+## Reincarnate when SCL3 has aus dist setup, ignore for now
+if [[ $UPDATE_PHX -eq 1 ]]; then
+  echo "---------------------------------------------------------------------------"
+  echo Updating PHX:
+  echo Running time $RSYNC -e \"ssh -i $PHX_KEY\" -PaO $STAGING_DIR/$1/ ${PHX_USER}@${PHX_HOST}:$LIVE_SNIPPET_DIR
+  time $RSYNC -e "ssh -i $PHX_KEY" -PaO $STAGING_DIR/$1/ ${PHX_USER}@${PHX_HOST}:$LIVE_SNIPPET_DIR
+  echo 
+  echo Running ssh -i $PHX_KEY ${PHX_USER}@${PHX_HOST} touch $LIVE_SNIPPET_DIR
+  ssh -i $PHX_KEY ${PHX_USER}@${PHX_HOST} touch $LIVE_SNIPPET_DIR
+  echo "---------------------------------------------------------------------------"
+fi
+
+mv $STAGING_DIR/$1 $PUSHED_DIR/
+
+exit 0