/[soft]/mga-gnome/trunk/mga-gnome
ViewVC logotype

Diff of /mga-gnome/trunk/mga-gnome

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3120 by ovitters, Tue Feb 28 13:02:47 2012 UTC revision 3449 by ovitters, Tue Mar 13 21:57:09 2012 UTC
# Line 1  Line 1 
1  #!/usr/bin/python  #!/usr/bin/python -u
2    
3  # A lot of the code comes from ftpadmin, see  # A lot of the code comes from ftpadmin, see
4  #   http://git.gnome.org/browse/sysadmin-bin/tree/ftpadmin  #   http://git.gnome.org/browse/sysadmin-bin/tree/ftpadmin
# Line 43  from email.mime.text import MIMEText Line 43  from email.mime.text import MIMEText
43  # to be able to sleep for a while  # to be able to sleep for a while
44  import time  import time
45    
46    # version freeze
47    import datetime
48    
49  MEDIA="Core Release Source"  MEDIA="Core Release Source"
50  URL="http://download.gnome.org/sources/"  URL="http://download.gnome.org/sources/"
51  PKGROOT='~/pkgs'  PKGROOT='~/pkgs'
# Line 89  def judge_version_increase(version_old, Line 92  def judge_version_increase(version_old,
92          compare = version_cmp(version_new, version_old)          compare = version_cmp(version_new, version_old)
93    
94          if compare == 0:          if compare == 0:
95                # 1.0.0 -> 1.0.1
96              return (-2, "Already at version %s!" % (version_old))              return (-2, "Already at version %s!" % (version_old))
97    
98          if compare != 1:          if compare != 1:
99                # 1.0.1 -> 1.0.0
100              return (-3, "Version %s is older than current version %s!" % (version_new, version_old))              return (-3, "Version %s is older than current version %s!" % (version_new, version_old))
101    
102          # Version is newer, but we don't want to see if it follows the GNOME versioning scheme          # Version is newer, but we don't want to see if it follows the GNOME versioning scheme
# Line 112  def judge_version_increase(version_old, Line 117  def judge_version_increase(version_old,
117          # Major+minor the same? Then go ahead and upgrade!          # Major+minor the same? Then go ahead and upgrade!
118          if majmins[0] == majmins[1]:          if majmins[0] == majmins[1]:
119              # Majmin of both versions are the same, looks good!              # Majmin of both versions are the same, looks good!
120                # 1.1.x -> 1.1.x or 1.0.x -> 1.0.x
121              return (10, None)              return (10, None)
122    
123          # More detailed analysis needed, so figure out the numbers          # More detailed analysis needed, so figure out the numbers
# Line 119  def judge_version_increase(version_old, Line 125  def judge_version_increase(version_old,
125    
126          # Check/ensure major version number is the same          # Check/ensure major version number is the same
127          if majmin_nrs[0][0] != majmin_nrs[1][0]:          if majmin_nrs[0][0] != majmin_nrs[1][0]:
128                # 1.0.x -> 2.0.x
129              return (1, "Major version number increase")              return (1, "Major version number increase")
130    
131          # Minor indicates stable/unstable          # Minor indicates stable/unstable
# Line 127  def judge_version_increase(version_old, Line 134  def judge_version_increase(version_old,
134          # Upgrading to unstable is weird          # Upgrading to unstable is weird
135          if not devstate[1]:          if not devstate[1]:
136              if devstate[0]:              if devstate[0]:
137                    # 1.2.x -> 1.3.x
138                  return (1, "Stable to unstable increase")                  return (1, "Stable to unstable increase")
139    
140                # 1.3.x -> 1.5.x
141              return (4, "Unstable to unstable version increase")              return (4, "Unstable to unstable version increase")
142    
143          # Unstable => stable is always ok          # Unstable => stable is always ok
144          if not devstate[0]:          if not devstate[0]:
145                # 1.1.x -> 1.2.x
146              return (5, "Unstable to stable")              return (5, "Unstable to stable")
147    
148          # Can only be increase of minors from one stable to the next          # Can only be increase of minors from one stable to the next
149            # 1.0.x -> 1.2.x
150          return (6, "Stable version increase")          return (6, "Stable version increase")
151    
152  def line_input (file):  def line_input (file):
# Line 613  def cmd_package_new_version(options, par Line 624  def cmd_package_new_version(options, par
624    
625  def cmd_parse_ftp_release_list(options, parser):  def cmd_parse_ftp_release_list(options, parser):
626      # XXX - not working yet      # XXX - not working yet
627      def _send_reply_mail(contents, orig_msg, to):      def _send_reply_mail(contents, orig_msg, to, error=False):
628          """Send an reply email"""          """Send an reply email"""
629          contents.seek(0)          contents.seek(0)
630          msg = MIMEText(contents.read(), _charset='utf-8')          msg = MIMEText(contents.read(), _charset='utf-8')
631          msg['Subject'] = "Re: %s" % orig_msg['Subject']          if error:
632                # XXX - ugly
633                contents.seek(0)
634                lastline = contents.read().splitlines()[-1]
635                # Remove things like "ERROR: " and so on from the last line
636                lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline)
637                subjecterror = " (ERROR: %s)" % lastline if lastline else " (ERROR)"
638            else:
639                subjecterror = ""
640            msg['Subject'] = "Re: %s%s" % (orig_msg['Subject'], subjecterror)
641          msg['To'] = to          msg['To'] = to
642          msg["In-Reply-To"] = orig_msg["Message-ID"]          msg["In-Reply-To"] = orig_msg["Message-ID"]
643          msg["References"] = orig_msg["Message-ID"]          msg["References"] = orig_msg["Message-ID"]
# Line 635  def cmd_parse_ftp_release_list(options, Line 655  def cmd_parse_ftp_release_list(options,
655      msg = email.email.message_from_file(sys.stdin)      msg = email.email.message_from_file(sys.stdin)
656    
657      if options.mail:      if options.mail:
658          stdout = tempfile.NamedTemporaryFile()          stdout = tempfile.TemporaryFile()
659          stderr = stdout          stderr = stdout
660      else:      else:
661          stdout = sys.stdout          stdout = sys.stdout
# Line 647  def cmd_parse_ftp_release_list(options, Line 667  def cmd_parse_ftp_release_list(options,
667          hexdigest = msg['X-Module-SHA256-tar.xz']          hexdigest = msg['X-Module-SHA256-tar.xz']
668      except KeyError, e:      except KeyError, e:
669          print >>stderr, "ERROR: %s" % e          print >>stderr, "ERROR: %s" % e
670          if options.mail: _send_reply_mail(stdout, msg, options.mail)          if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)
671          sys.exit(1)          sys.exit(1)
672    
673      try:      try:
674          packages = get_downstream_from_upstream(module, version)          packages = get_downstream_from_upstream(module, version)
675      except ValueError, e:      except ValueError, e:
676          print >>stderr, "ERROR: %s" % e          print >>stderr, "ERROR: %s" % e
677          if options.mail: _send_reply_mail(stdout, msg, options.mail)          if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)
678          sys.exit(1)          sys.exit(1)
679    
680      if options.wait:      if options.wait:
681            # maildrop aborts and will try to deliver after 5min
682            # fork to avoid this
683            if os.fork() != 0: sys.exit(0)
684          time.sleep(SLEEP_INITIAL)          time.sleep(SLEEP_INITIAL)
685    
686        error = False
687      for package in packages:      for package in packages:
688          subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr)          if subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr):
689                error = True
690    
691      if options.mail: _send_reply_mail(stdout, msg, options.mail)      if options.mail: _send_reply_mail(stdout, msg, options.mail, error=error)
692    
693  def main():  def main():
694      description = """Mageia GNOME commands."""      description = """Mageia GNOME commands."""

Legend:
Removed from v.3120  
changed lines
  Added in v.3449

  ViewVC Help
Powered by ViewVC 1.1.30