code: def package(env, target, source, PACKAGEROOT, NAME, VERSION, DESCRIPTION,
              SUMMARY, X_IPK_PRIORITY, X_IPK_SECTION, SOURCE_URL,
              X_IPK_MAINTAINER, X_IPK_DEPENDS, **kw):
      
      SCons.Tool.Tool('ipkg').generate(env)
  
      # setup the Ipkg builder
      bld = env['BUILDERS']['Ipkg']
      target, source = stripinstallbuilder(target, source, env)
      target, source = putintopackageroot(target, source, env, PACKAGEROOT)
  
      # This should be overrideable from the construction environment,
      # which it is by using ARCHITECTURE=.
      # Guessing based on what os.uname() returns at least allows it
      # to work for both i386 and x86_64 Linux systems.
      archmap = {
          'i686'  : 'i386',
          'i586'  : 'i386',
          'i486'  : 'i386',
      }
  
      buildarchitecture = os.uname()[4]
      buildarchitecture = archmap.get(buildarchitecture, buildarchitecture)
  
      if 'ARCHITECTURE' in kw:
          buildarchitecture = kw['ARCHITECTURE']
  
      # setup the kw to contain the mandatory arguments to this function.
      # do this before calling any builder or setup function
      loc=locals()
      del loc['kw']
      kw.update(loc)
      del kw['source'], kw['target'], kw['env']
  
      # generate the specfile
      specfile = gen_ipk_dir(PACKAGEROOT, source, env, kw)
  
      # override the default target.
      if str(target[0])=="%s-%s"%(NAME, VERSION):
          target=[ "%s_%s_%s.ipk"%(NAME, VERSION, buildarchitecture) ]
  
      # now apply the Ipkg builder
      return bld(env, target, specfile, **kw)
docs: This function prepares the packageroot directory for packaging with the
      ipkg builder.