def decompose_kernel_2x_once(kernel):
 for mapping in get_mappings_2x():
  (suffix, becomes, is_full, patch_templates) = mapping
  params = {}
  match = re.search(('^(.*)' + suffix), kernel)
  if (not match):
   continue
  params['full'] = kernel
  params['base'] = match.group(1)
  match = re.search('^((\\d+\\.\\d+)\\.(\\d+))', kernel)
  if (not match):
   raise NameError(('Unable to determine major/minor version for kernel %s' % kernel))
  params['minor'] = match.group(1)
  params['major'] = match.group(2)
  params['minor-prev'] = (match.group(2) + ('.%d' % (int(match.group(3)) - 1)))
  new_kernel = (becomes % params)
  patch_list = []
  for template in patch_templates:
   patch_list.append((template % params))
  return (is_full, new_kernel, patch_list)
 return (True, kernel, None)

def decompose_kernel_2x_once ( kernel ) : for mapping in get_mappings_2x ( ) : ( suffix , becomes , is_full , patch_templates ) = mapping params = { } match = re . search ( ( '^(.*)' + suffix ) , kernel ) if ( not match ) : continue params [ 'full' ] = kernel params [ 'base' ] = match . group ( 1 ) match = re . search ( '^((\\d+\\.\\d+)\\.(\\d+))' , kernel ) if ( not match ) : raise NameError ( ( 'Unable to determine major/minor version for kernel %s' % kernel ) ) params [ 'minor' ] = match . group ( 1 ) params [ 'major' ] = match . group ( 2 ) params [ 'minor-prev' ] = ( match . group ( 2 ) + ( '.%d' % ( int ( match . group ( 3 ) ) - 1 ) ) ) new_kernel = ( becomes % params ) patch_list = [ ] for template in patch_templates : patch_list . append ( ( template % params ) ) return ( is_full , new_kernel , patch_list ) return ( True , kernel , None )
generate the parameters for the patches : full => full kernel name base => all but the matches suffix minor => 2 .