parameters: (distro, build_os, arch, spec, srcdir)
return_statement: return repo_dir
docstring: Make the Debian script.
docstring_summary: Make the Debian script.
docstring_tokens: Make the Debian script .
function: def make_deb(distro, build_os, arch, spec, srcdir):
      """Make the Debian script."""
      # I can't remember the details anymore, but the initscript/upstart
      # job files' names must match the package name in some way; and
      # see also the --name flag to dh_installinit in the generated
      # debian/rules file.
      suffix = spec.suffix()
      sdir = setupdir(distro, build_os, arch, spec)
      if re.search("debian", distro.name()):
          os.unlink(sdir + "debian/mongod.upstart")
          os.link(sdir + "debian/mongod.service",
                  sdir + "debian/%s%s-server.mongod.service" % (distro.pkgbase(), suffix))
          os.unlink(sdir + "debian/init.d")
      elif re.search("ubuntu", distro.name()):
          os.unlink(sdir + "debian/init.d")
          if build_os in ("ubuntu1204", "ubuntu1404", "ubuntu1410"):
              os.link(sdir + "debian/mongod.upstart",
                      sdir + "debian/%s%s-server.mongod.upstart" % (distro.pkgbase(), suffix))
              os.unlink(sdir + "debian/mongod.service")
          else:
              os.link(sdir + "debian/mongod.service",
                      sdir + "debian/%s%s-server.mongod.service" % (distro.pkgbase(), suffix))
              os.unlink(sdir + "debian/mongod.upstart")
      else:
          raise Exception("unknown debianoid flavor: not debian or ubuntu?")
      # Rewrite the control and rules files
      write_debian_changelog(sdir + "debian/changelog", spec, srcdir)
      distro_arch = distro.archname(arch)
      sysassert([
          "cp", "-v", srcdir + "debian/%s%s.control" % (distro.pkgbase(), suffix),
          sdir + "debian/control"
      ])
      sysassert([
          "cp", "-v", srcdir + "debian/%s%s.rules" % (distro.pkgbase(), suffix), sdir + "debian/rules"
      ])
  
      # old non-server-package postinst will be hanging around for old versions
      #
      if os.path.exists(sdir + "debian/postinst"):
          os.unlink(sdir + "debian/postinst")
  
      # copy our postinst files
      #
      sysassert(["sh", "-c", "cp -v \"%sdebian/\"*.postinst \"%sdebian/\"" % (srcdir, sdir)])
  
      with open(sdir + "debian/substvars", "w") as fh:
          # Empty for now. This makes it easier to add substvars to packages
          # later on if we need it.
          fh.write("\n")
  
      ensure_dir(sdir + "debian/source/format")
      with open(sdir + "debian/source/format", "w") as fh:
          fh.write("1.0\n")
  
      # Do the packaging.
      oldcwd = os.getcwd()
      try:
          os.chdir(sdir)
          sysassert(["dpkg-buildpackage", "-uc", "-us", "-a" + distro_arch])
      finally:
          os.chdir(oldcwd)
      repo_dir = distro.repodir(arch, build_os, spec)
      ensure_dir(repo_dir)
      # FIXME: see if shutil.copyfile or something can do this without
      # much pain.
      sysassert(["sh", "-c", "cp -v \"%s/../\"*.deb \"%s\"" % (sdir, repo_dir)])
      return repo_dir
function_tokens: def make_deb ( distro , build_os , arch , spec , srcdir ) : # I can't remember the details anymore, but the initscript/upstart # job files' names must match the package name in some way; and # see also the --name flag to dh_installinit in the generated # debian/rules file. suffix = spec . suffix ( ) sdir = setupdir ( distro , build_os , arch , spec ) if re . search ( "debian" , distro . name ( ) ) : os . unlink ( sdir + "debian/mongod.upstart" ) os . link ( sdir + "debian/mongod.service" , sdir + "debian/%s%s-server.mongod.service" % ( distro . pkgbase ( ) , suffix ) ) os . unlink ( sdir + "debian/init.d" ) elif re . search ( "ubuntu" , distro . name ( ) ) : os . unlink ( sdir + "debian/init.d" ) if build_os in ( "ubuntu1204" , "ubuntu1404" , "ubuntu1410" ) : os . link ( sdir + "debian/mongod.upstart" , sdir + "debian/%s%s-server.mongod.upstart" % ( distro . pkgbase ( ) , suffix ) ) os . unlink ( sdir + "debian/mongod.service" ) else : os . link ( sdir + "debian/mongod.service" , sdir + "debian/%s%s-server.mongod.service" % ( distro . pkgbase ( ) , suffix ) ) os . unlink ( sdir + "debian/mongod.upstart" ) else : raise Exception ( "unknown debianoid flavor: not debian or ubuntu?" ) # Rewrite the control and rules files write_debian_changelog ( sdir + "debian/changelog" , spec , srcdir ) distro_arch = distro . archname ( arch ) sysassert ( [ "cp" , "-v" , srcdir + "debian/%s%s.control" % ( distro . pkgbase ( ) , suffix ) , sdir + "debian/control" ] ) sysassert ( [ "cp" , "-v" , srcdir + "debian/%s%s.rules" % ( distro . pkgbase ( ) , suffix ) , sdir + "debian/rules" ] ) # old non-server-package postinst will be hanging around for old versions # if os . path . exists ( sdir + "debian/postinst" ) : os . unlink ( sdir + "debian/postinst" ) # copy our postinst files # sysassert ( [ "sh" , "-c" , "cp -v \"%sdebian/\"*.postinst \"%sdebian/\"" % ( srcdir , sdir ) ] ) with open ( sdir + "debian/substvars" , "w" ) as fh : # Empty for now. This makes it easier to add substvars to packages # later on if we need it. fh . write ( "\n" ) ensure_dir ( sdir + "debian/source/format" ) with open ( sdir + "debian/source/format" , "w" ) as fh : fh . write ( "1.0\n" ) # Do the packaging. oldcwd = os . getcwd ( ) try : os . chdir ( sdir ) sysassert ( [ "dpkg-buildpackage" , "-uc" , "-us" , "-a" + distro_arch ] ) finally : os . chdir ( oldcwd ) repo_dir = distro . repodir ( arch , build_os , spec ) ensure_dir ( repo_dir ) # FIXME: see if shutil.copyfile or something can do this without # much pain. sysassert ( [ "sh" , "-c" , "cp -v \"%s/../\"*.deb \"%s\"" % ( sdir , repo_dir ) ] ) return repo_dir