diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/feed-browser/includes/config.inc | 142 | ||||
-rw-r--r-- | contrib/feed-browser/includes/functions.inc | 207 | ||||
-rw-r--r-- | contrib/feed-browser/index.php | 27 | ||||
-rw-r--r-- | contrib/feed-browser/update.php | 26 | ||||
-rw-r--r-- | contrib/python/.mtn2git_empty | 0 | ||||
-rwxr-xr-x | contrib/python/generate-manifest.py | 326 | ||||
-rwxr-xr-x | contrib/sanitize.py | 392 |
7 files changed, 978 insertions, 142 deletions
diff --git a/contrib/feed-browser/includes/config.inc b/contrib/feed-browser/includes/config.inc new file mode 100644 index 0000000000..e1999b066f --- /dev/null +++ b/contrib/feed-browser/includes/config.inc @@ -0,0 +1,142 @@ +<?php + +define('DB_FILENAME', './feeds.db'); + +$feeds = array( + array( + 'distro_name'=>'OpenZaurus', + 'distro_version'=>'3.5.4', + 'feed_base_url'=>'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4/feed/', + 'feeds'=>array( + array( + 'name'=>'base', + 'url'=>'base', + 'type'=>'normal', + ), + array( + 'name'=>'opie', + 'url'=>'opie', + 'type'=>'normal', + ), + array( + 'name'=>'x11', + 'url'=>'x11', + 'type'=>'normal', + ), + array( + 'name'=>'upgrades', + 'url'=>'upgrades', + 'type'=>'upgrades', + ), + array( + 'name'=>'perl', + 'url'=>'perl', + 'type'=>'normal', + ), + array( + 'name'=>'python', + 'url'=>'python', + 'type'=>'normal', + ), + array( + 'name'=>'Collie upgrades', + 'url'=>'upgrades/machine/collie', + 'type'=>'upgrades', + ), + array( + 'name'=>'Tosa upgrades', + 'url'=>'upgrades/machine/tosa', + 'type'=>'upgrades', + ), + array( + 'name'=>'Poodle upgrades', + 'url'=>'upgrades/machine/poodle', + 'type'=>'upgrades', + ), + array( + 'name'=>'Poodle', + 'url'=>'machine/poodle', + 'type'=>'normal', + ), + array( + 'name'=>'Collie', + 'url'=>'machine/collie', + 'type'=>'normal', + ), + array( + 'name'=>'Tosa', + 'url'=>'machine/tosa', + 'type'=>'normal', + ) + ) + ), + array( + 'distro_name'=>'OpenZaurus', + 'distro_version'=>'3.5.4.1', + 'feed_base_url'=>'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/', + 'feeds'=>array( + array( + 'name'=>'base', + 'url'=>'base', + 'type'=>'normal', + ), + array( + 'name'=>'opie', + 'url'=>'opie', + 'type'=>'normal', + ), + array( + 'name'=>'perl', + 'url'=>'perl', + 'type'=>'normal', + ), + array( + 'name'=>'python', + 'url'=>'python', + 'type'=>'normal', + ), + array( + 'name'=>'upgrades', + 'url'=>'upgrades', + 'type'=>'upgrades', + ), + array( + 'name'=>'x11', + 'url'=>'x11', + 'type'=>'normal', + ), + array( + 'name'=>'C7x0', + 'url'=>'machine/c7x0', + 'type'=>'normal', + ), + array( + 'name'=>'Spitz', + 'url'=>'machine/spitz', + 'type'=>'normal', + ), + array( + 'name'=>'Akita', + 'url'=>'machine/akita', + 'type'=>'normal', + ), + array( + 'name'=>'Akita upgrades', + 'url'=>'upgrades/machine/akita', + 'type'=>'upgrades', + ), + array( + 'name'=>'C7x0 upgrades', + 'url'=>'upgrades/machine/c7x0', + 'type'=>'upgrades', + ), + array( + 'name'=>'Spitz upgrades', + 'url'=>'upgrades/machine/spitz', + 'type'=>'upgrades', + ) + ) + ) +); + +?> diff --git a/contrib/feed-browser/includes/functions.inc b/contrib/feed-browser/includes/functions.inc index d18b129650..2532dd7c08 100644 --- a/contrib/feed-browser/includes/functions.inc +++ b/contrib/feed-browser/includes/functions.inc @@ -20,8 +20,6 @@ error_reporting(E_ALL); -define('DB_FILENAME', './feeds.db'); - function db_query($query) { $result = FALSE; @@ -36,7 +34,6 @@ function db_query($query) return $result; } - function db_query_n($query) { $result = FALSE; @@ -76,88 +73,30 @@ function db_table_exists ($db, $mytable) return FALSE; } -function test_insert_ipkgs ($db) +function insert_feeds ($db) { + global $feeds; - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-base', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/base') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-opie', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/opie') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-perl', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/perl') - "); - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-python', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/python') - "); - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-upgrades', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/upgrades') - "); - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-x11', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/x11') - "); - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-machine-c7x0', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/machine/c7x0') - "); - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-machine-spitz', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/machine/spitz') - "); - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-machine-akita', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/machine/akita') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-upgrades-machine-akita', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/upgrades/machine/akita') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-upgrades-machine-c7x0', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/upgrades/machine/c7x0') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-upgrades-machine-spitz', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/upgrades/machine/spitz') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('3541-upgrades-machine-tosa', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4.1/feed/upgrades/machine/tosa') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('354-base', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4/feed/base') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('354-opie', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4/feed/opie') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('354-x11', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4/feed/x11') - "); - - sqlite_query($db, - "INSERT INTO feeds (f_name, f_uri) - VALUES ('354-upgrades', 'http://ewi546.ewi.utwente.nl/mirror/www.openzaurus.org/official/unstable/3.5.4/feed/upgrades') - "); + if(isset($feeds)) + { + $id = 1; + foreach($feeds as $distro) + { + foreach($distro['feeds'] as $feed) + { + sqlite_query($db, "INSERT INTO feeds (f_id, f_name, f_uri, f_type) VALUES + ( + {$id}, + '{$distro['distro_name']} {$distro['distro_version']} {$feed['name']}', + '{$distro['feed_base_url']}{$feed['url']}', + '{$feed['type']}' + )"); + + $id++; + } + } + } } function searchletter($searchletter = '') @@ -233,7 +172,7 @@ function pkgdetails ($package) { $result = db_query("SELECT * FROM packages,feeds WHERE (packages.p_name='$package' OR packages.p_provides='$package') - AND feeds.f_name = packages.p_feed + AND feeds.f_id = packages.p_feed ORDER BY packages.p_version DESC, feeds.f_name ASC, packages.p_arch DESC "); // display first result @@ -394,68 +333,80 @@ function sectionslist() if($result = db_query ("SELECT DISTINCT p_section FROM packages ORDER BY p_section")) { - $ipkgoutput = "<ul id='sections'>\n"; + $section_up = ''; - $section_up = $result[0]['p_section']; - $section_level = FALSE; - $opie_top = FALSE; + $sections = array(); - foreach($result as $item) + foreach($result as $package) { - $section_name = $item['p_section']; + $section_split = explode('/', $package['p_section']); - if(0 === strpos($section_name, 'opie') AND !$opie_top) + if($section_up != $section_split[0]) { - $opie_top = TRUE; - - $section_up = 'opie'; + $section_up = $section_split[0]; } - elseif($opie_top AND 0 !== strpos($section_name, 'opie')) + + if(isset($section_split[1])) // x11/gnome/libs { - $opie_top = FALSE; + $sections[$section_up][$section_split[1]] = $section_split[1]; + + if(isset($section_split[2])) // x11/gnome/libs + { + $sections[ $section_up ][ $section_split[1] ] = array($section_split[2]=>$section_split[2]); + } } + } - if( - strpos($section_name, '/') // subsection - ) + $output = "<ul id='sections'>\n"; + + foreach($sections as $section_name1=>$item) + { + $output .= sprintf ("<li><a href='?action=section&section=%s' title='%s'>%s</a>", + urlencode($section_name1), + urlencode($section_name1), + $section_name1); + + if(is_array($item)) { - if(0 === strpos($section_name, $section_up . '/')) // console/network are not part of console/net + $output .= '<ul class="subsections">'; + + foreach($item as $section_name2=>$subitem) { - if(!$section_level) + $section_name = "{$section_name1}/{$section_name2}"; + $output .= sprintf ("<li><a href='?action=section&section=%s' title='%s'>%s</a>", + urlencode($section_name), + urlencode($section_name), + $section_name2); + + if(is_array($subitem)) { - $ipkgoutput .= '<li><ul class="subsections">'; + $output .= '<ul class="subsections">'; + + foreach($subitem as $section_name3=>$subitem2) + { + $section_name = "{$section_name1}/{$section_name2}/{$section_name3}"; + $output .= sprintf ("<li><a href='?action=section&section=%s' title='%s'>%s</a></li>", + urlencode($section_name), + urlencode($section_name), + $section_name3); + } + + $output .= '</ul>'; } - $section_name = str_replace($section_up . '/', '', $item['p_section']); - $section_level = TRUE; + $output .= '</li>'; } - } - elseif($section_level) - { - $section_up = $section_name; - $ipkgoutput .= '</ul></li>'; - $section_level = FALSE; - } - else - { - $section_up = $section_name; - } - $ipkgoutput .= sprintf ("<li><a href='?action=section&section=%s' title='%s'>%s</a></li>", - urlencode($item['p_section']), - urlencode($item['p_section']), - $section_name); - } + $output .= '</ul>'; + } - if($section_level) - { - $ipkgoutput .= '</ul></li>'; + $output .= '</li>'; } - $ipkgoutput .= "</ul>\n"; + $output .= "</ul>\n"; } - return $ipkgoutput; + return $output; } function check_database() @@ -488,11 +439,13 @@ function check_database() if (db_table_exists ($db, 'feeds') === FALSE) { sqlite_query ($db, "CREATE TABLE feeds ( - f_name varchar(20), + f_id int(8), + f_name varchar(32), f_uri varchar(100), - f_comments varchar(500))"); + f_type varchar(16) + )"); - test_insert_ipkgs ($db) ; + insert_feeds ($db) ; } sqlite_close($db); diff --git a/contrib/feed-browser/index.php b/contrib/feed-browser/index.php index b3fb41bcd8..1c902ac66e 100644 --- a/contrib/feed-browser/index.php +++ b/contrib/feed-browser/index.php @@ -30,10 +30,18 @@ * */ +require_once 'includes/config.inc'; require_once 'includes/functions.inc'; check_database(); +$name = ''; + +if(isset($_GET['name'])) +{ + $name = $_GET['name']; +} + $action = ''; if(isset($_GET['action'])) @@ -47,10 +55,8 @@ switch($action) $ipkgoutput = pkgdetails ($_GET['pnm']); break; - case "package": - $edit = $_POST['edit']; - $searchword = $edit['searchword']; - $ipkgoutput = searchpkg ("%$searchword%"); + case "search": + $ipkgoutput = searchpkg ("%{$name}%"); break; case "section": @@ -77,7 +83,18 @@ switch($action) <style type="text/css" media="all">@import "css/feed.css";</style> </head> <body > - <div id="right"><?php echo searchletter(); echo $ipkgoutput; ?></div> + <div id="right"> + <?php echo searchletter(); ?> + <form action="" method="get"> + <fieldset> + <label for="name">Package name</label> + <input type="text" name="name" value="<?php echo $name; ?>" /> + <input type="hidden" name="action" value="search" /> + <input type="submit" value="Search" /> + </fieldset> + </form> + <?php echo $ipkgoutput; ?> + </div> <div id="left"> <h1>Sections list</h1> <?php echo sectionslist(); ?> diff --git a/contrib/feed-browser/update.php b/contrib/feed-browser/update.php index ed7d6e47ef..ed67d3b78a 100644 --- a/contrib/feed-browser/update.php +++ b/contrib/feed-browser/update.php @@ -16,6 +16,7 @@ * */ +require_once 'includes/config.inc'; require_once 'includes/functions.inc'; /* @@ -38,15 +39,20 @@ require_once 'includes/functions.inc'; check_database(); +$feeds = db_query("SELECT f_id, f_name, f_uri FROM feeds"); + +if($argc > 1 AND $argv[1] == 'upgrades') +{ + $feeds = db_query("SELECT f_id, f_name, f_uri FROM feeds WHERE f_type = 'upgrades'"); +} + $start = time(); $p_count = 0; -$feeds = db_query("SELECT f_name, f_uri FROM feeds"); - foreach($feeds as $feed) { - print("Updating {$feed['f_name']}: {$feed['f_uri']}: "); - db_query_n("DELETE FROM packages WHERE p_feed = '{$feed['f_name']}'"); + print("Updating {$feed['f_name']}: "); + db_query_n("DELETE FROM packages WHERE p_feed = '{$feed['f_id']}'"); $count = 0; @@ -58,8 +64,8 @@ foreach($feeds as $feed) 'name'=>'', 'version'=>'', 'arch'=>'', 'depends'=>'', 'maintainer'=>'', 'homepage'=>'', 'section'=>'', 'replaces'=>'', 'provides'=>'', 'recommends'=>'', 'conflicts'=>'', 'size'=>'', - 'md5sum'=>'', 'source'=>'', 'feed'=>'', 'file'=>'', 'desc'=>'' - ); + 'md5sum'=>'', 'source'=>'', 'feed'=>$feed['f_id'], 'file'=>'', 'desc'=>'' + ); while (!feof($packagesgz_h)) { @@ -74,7 +80,7 @@ foreach($feeds as $feed) 'name'=>'', 'version'=>'', 'arch'=>'', 'depends'=>'', 'maintainer'=>'', 'homepage'=>'', 'section'=>'', 'replaces'=>'', 'provides'=>'', 'recommends'=>'', 'conflicts'=>'', 'size'=>'', - 'md5sum'=>'', 'source'=>'', 'feed'=>'', 'file'=>'', 'desc'=>'' + 'md5sum'=>'', 'source'=>'', 'feed'=>$feed['f_id'], 'file'=>'', 'desc'=>'' ); } @@ -103,7 +109,7 @@ foreach($feeds as $feed) $package_info['conflicts'] = $value; break; case 'Section': - $package_info['section'] = $value; + $package_info['section'] = strtolower($value); break; case 'Architecture': $package_info['arch'] = $value; @@ -160,7 +166,7 @@ function insert_ipkgs(&$package_info) { db_query_n("INSERT INTO packages VALUES ( '{$package_info['name']}', '{$package_info['version']}', - '{$package_info['arch']}', '{$package_info['depends']}', + '{$package_info['arch']}', '{$package_info['depends']}', '{$package_info['maintainer']}', '{$package_info['homepage']}', '{$package_info['section']}', '{$package_info['replaces']}', '{$package_info['provides']}', '{$package_info['recommends']}', @@ -168,7 +174,7 @@ function insert_ipkgs(&$package_info) '{$package_info['md5sum']}', '{$package_info['source']}', '{$package_info['feed']}', '{$package_info['file']}', '{$package_info['desc']}' - )"); + )"); } ?> diff --git a/contrib/python/.mtn2git_empty b/contrib/python/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/contrib/python/.mtn2git_empty diff --git a/contrib/python/generate-manifest.py b/contrib/python/generate-manifest.py new file mode 100755 index 0000000000..2fd681dc01 --- /dev/null +++ b/contrib/python/generate-manifest.py @@ -0,0 +1,326 @@ +#!/usr/bin/env python + +# generate Python Manifest for the OpenEmbedded build system +# (C) 2002-2006 Michael Lauer <mickey@Vanille.de> +# MIT license + +import os +import sys +import time + +VERSION = "2.4.3" +# increase when touching python-core +BASEREV = 0 + +__author__ = "Michael 'Mickey' Lauer <mickey@Vanille.de>" +__version__ = "$Revision: 1.20 $" + +class MakefileMaker: + + def __init__( self, outfile ): + """initialize""" + self.packages = {} + self.sourcePrefix = "/lib/python%s/" % VERSION[:3] + self.targetPrefix = "${libdir}/python%s" % VERSION[:3] + self.output = outfile + self.out( "#" * 120 ) + self.out( "### AUTO-GENERATED by '%s' [(C) 2002-2006 Michael 'Mickey' Lauer <mickey@Vanille.de>] on %s" % ( sys.argv[0], time.asctime() ) ) + self.out( "###" ) + self.out( "### Visit THE Python for Embedded Systems Site => http://www.Vanille.de/projects/python.spy" ) + self.out( "###" ) + self.out( "### Warning: Manual edits will be lost!" ) + self.out( "###" ) + self.out( "#" * 120 ) + # + # helper functions + # + + def out( self, data ): + """print a line to the output file""" + print >> self.output, data + + def setPrefix( self, sourcePrefix, targetPrefix ): + """set a file prefix for addPackage files""" + self.sourcePrefix = sourcePrefix + self.targetPrefix = targetPrefix + + def doProlog( self ): + self.out( """ """ ) + self.out( "" ) + + def addPackage( self, revision, name, description, dependencies, filenames ): + """add a package to the Makefile""" + if type( filenames ) == type( "" ): + filenames = filenames.split() + fullFilenames = [] + for filename in filenames: + if filename[0] != "/": + fullFilenames.append( ( "%s%s" % ( self.sourcePrefix, filename ), "%s%s" % ( self.targetPrefix, filename ) ) ) + else: + fullFilenames.append( ( filename, filename ) ) + self.packages[name] = revision, description, dependencies, fullFilenames + + def doBody( self ): + """generate body of Makefile""" + + global VERSION + + # + # generate provides line + # + + provideLine = 'PROVIDES+="' + for name in self.packages: + provideLine += "%s " % name + provideLine += '"' + + self.out( provideLine ) + self.out( "" ) + + # + # generate package line + # + + packageLine = 'PACKAGES="' + for name in self.packages: + packageLine += "%s " % name + packageLine += '"' + + self.out( packageLine ) + self.out( "" ) + + # + # generate package variables + # + + for name, data in self.packages.iteritems(): + rev, desc, deps, files = data + + # + # write out the description, revision and dependencies + # + self.out( 'DESCRIPTION_%s="%s"' % ( name, desc ) ) + self.out( 'PR_%s="ml%d"' % ( name, rev + BASEREV ) ) + self.out( 'RDEPENDS_%s="%s"' % ( name, deps.replace( ",", "" ) ) ) + + line = 'FILES_%s="' % name + + # + # check which directories to make in the temporary directory + # + + dirset = {} # if python had a set-datatype this would be sufficient. for now, we're using a dict instead. + for source, target in files: + dirset[os.path.dirname( target )] = True + + # + # generate which files to copy for the target (-dfR because whole directories are also allowed) + # + + for source, target in files: + line += "%s " % target + + line += '"' + self.out( line ) + +# for source, target in files: +# if ( source.find( "lib-dynload" ) != -1 ) or \ +# ( source.endswith( "python" ) ) or \ +# ( source.endswith( "pydoc" ) ): # MACHDEP +# self.out( "\t cp -dfR $(STAGING_LIBDIR)/..%s $(IPKTMP_DIR)%s/;" % ( source, os.path.dirname( target ) ) ) +# else: +# self.out( "\t cp -dfR $(STAGING_DIR)%s $(IPKTMP_DIR)%s/;" % ( source, os.path.dirname( target ) ) ) +# + self.out( "" ) + + def doEpilog( self ): + self.out( """""" ) + self.out( "" ) + + def make( self ): + self.doProlog() + self.doBody() + self.doEpilog() + +if __name__ == "__main__": + + if len( sys.argv ) > 1: + os.popen( "rm -f ./%s" % sys.argv[1] ) + outfile = file( sys.argv[1], "w" ) + else: + outfile = sys.stdout + + m = MakefileMaker( outfile ) + + # Add packages here. Only specify dlopen-style library dependencies here, no ldd-style dependencies! + # Parameters: revision, name, description, dependencies, filenames + # + + m.setPrefix( "/", "/usr/" ) + + m.addPackage( 1, "python-core", "Python Interpreter and core modules (needed!)", "", + "lib/python2.4/__future__.* lib/python2.4/copy.* lib/python2.4/copy_reg.* lib/python2.4/ConfigParser.py " + + "lib/python2.4/getopt.* lib/python2.4/linecache.* lib/python2.4/new.* " + + "lib/python2.4/os.* lib/python2.4/posixpath.* " + + "lib/python2.4/warnings.* lib/python2.4/site.* lib/python2.4/stat.* " + + "lib/python2.4/UserDict.* lib/python2.4/UserList.* lib/python2.4/UserString.* " + + "lib/python2.4/lib-dynload/binascii.so lib/python2.4/lib-dynload/struct.so lib/python2.4/lib-dynload/time.so " + + "lib/python2.4/lib-dynload/xreadlines.so lib/python2.4/types.* bin/python" ) + + m.addPackage( 0, "python-devel", "Python Development Package", "python-core", + "include lib/python2.4/config" ) # package + + m.addPackage( 0, "python-idle", "Python Integrated Development Environment", "python-core, python-tkinter", + "bin/idle lib/python2.4/idlelib" ) # package + + m.addPackage( 0, "python-pydoc", "Python Interactive Help Support", "python-core, python-lang, python-stringold, python-re", + "bin/pydoc lib/python2.4/pydoc.*" ) + + m.setPrefix( "/lib/python2.4/", "${libdir}/python2.4/" ) + + m.addPackage( 0, "python-audio", "Python Audio Handling", "python-core", + "wave.* chunk.* lib-dynload/ossaudiodev.so lib-dynload/audioop.so" ) + + m.addPackage( 0, "python-bsddb", "Python Berkeley Database Bindings", "python-core", + "bsddb" ) # package + + m.addPackage( 0, "python-codecs", "Python Codecs, Encodings & i18n Support", "python-core", + "codecs.* encodings gettext.* locale.* lib-dynload/_locale.so lib-dynload/unicodedata.so stringprep.* xdrlib.*" ) + + m.addPackage( 0, "python-compile", "Python Bytecode Compilation Support", "python-core", + "py_compile.* compileall.*" ) + + m.addPackage( 0, "python-compiler", "Python Compiler Support", "python-core", + "compiler" ) # package + + m.addPackage( 0, "python-compression", "Python High Level Compression Support", "python-core, python-zlib", + "gzip.* zipfile.*" ) + + m.addPackage( 0, "python-crypt", "Python Basic Cryptographic and Hashing Support", "python-core", + "lib-dynload/crypt.so lib-dynload/md5.so lib-dynload/rotor.so lib-dynload/sha.so" ) + + m.addPackage( 0, "python-textutils", "Python Option Parsing, Text Wrapping and Comma-Separated-Value Support", "python-core, python-io, python-re, python-stringold", + "lib-dynload/_csv.so csv.* optparse.* textwrap.*" ) + + m.addPackage( 1, "python-curses", "Python Curses Support", "python-core", + "curses lib-dynload/_curses.so lib-dynload/_curses_panel.so" ) # package + + m.addPackage( 0, "python-datetime", "Python Calendar and Time support", "python-core, python-codecs", + "_strptime.* calendar.* lib-dynload/datetime.so" ) + + m.addPackage( 0, "python-db", "Python File-Based Database Support", "python-core", + "anydbm.* dumbdbm.* whichdb.* " ) + + m.addPackage( 0, "python-distutils", "Python Distribution Utilities", "python-core", + "config distutils" ) # package + + m.addPackage( 0, "python-email", "Python Email Support", "python-core, python-io, python-re", + "email" ) # package + + m.addPackage( 0, "python-fcntl", "Python's fcntl Interface", "python-core", + "lib-dynload/fcntl.so" ) + + m.addPackage( 0, "python-hotshot", "Python Hotshot Profiler", "python-core", + "hotshot lib-dynload/_hotshot.so" ) + + m.addPackage( 0, "python-html", "Python HTML Processing", "python-core", + "formatter.* htmlentitydefs.* htmllib.* markupbase.* sgmllib.* " ) + + m.addPackage( 0, "python-gdbm", "Python GNU Database Support", "python-core, libgdbm3", + "lib-dynload/gdbm.so" ) + + m.addPackage( 0, "python-image", "Python Graphical Image Handling", "python-core", + "colorsys.* imghdr.* lib-dynload/imageop.so lib-dynload/rgbimg.so" ) + + m.addPackage( 0, "python-io", "Python Low-Level I/O", "python-core, python-math", + "lib-dynload/_socket.so lib-dynload/_ssl.so lib-dynload/select.so lib-dynload/termios.so lib-dynload/cStringIO.so " + "pipes.* socket.* tempfile.* StringIO.* " ) + + m.addPackage( 0, "python-lang", "Python Low-Level Language Support", "python-core", + "lib-dynload/array.so lib-dynload/parser.so lib-dynload/operator.so lib-dynload/_weakref.so " + + "lib-dynload/itertools.so lib-dynload/collections.so " + + "atexit.* code.* codeop.* dis.* inspect.* keyword.* opcode.* repr.* token.* tokenize.* traceback.* linecache.* weakref.*" ) + + m.addPackage( 0, "python-logging", "Python Logging Support", "python-core", + "logging" ) # package + + m.addPackage( 0, "python-lib-old-and-deprecated", "Python Deprecated Libraries", "python-core", + "lib-old" ) # package + + m.addPackage( 0, "python-tkinter", "Python Tcl/Tk Bindings", "python-core", + "lib-dynload/_tkinter.so lib-tk" ) # package + + m.addPackage( 0, "python-math", "Python Math Support", "python-core", + "lib-dynload/cmath.so lib-dynload/math.so lib-dynload/_random.so random.* sets.*" ) + + m.addPackage( 0, "python-mime", "Python MIME Handling APIs", "python-core, python-io", + "mimetools.* quopri.* rfc822.*" ) + + m.addPackage( 0, "python-mmap", "Python Memory-Mapped-File Support", "python-core, python-io", + "lib-dynload/mmap.so " ) + + m.addPackage( 0, "python-unixadmin", "Python Unix Administration Support", "python-core", + "lib-dynload/nis.so lib-dynload/grp.so lib-dynload/pwd.so getpass.*" ) + + m.addPackage( 1, "python-netclient", "Python Internet Protocol Clients", "python-core, python-datetime, python-io, python-lang, python-logging, python-mime", + "*Cookie*.* " + + "base64.* cookielib.* ftplib.* gopherlib.* hmac.* httplib.* mimetypes.* nntplib.* poplib.* smtplib.* telnetlib.* urllib.* urllib2.* urlparse.*" ) + + m.addPackage( 0, "python-netserver", "Python Internet Protocol Servers", "python-core, python-netclient", + "cgi.* BaseHTTPServer.* SimpleHTTPServer.* SocketServer.*" ) + + m.addPackage( 0, "python-pickle", "Python Persistence Support", "python-core, python-codecs, python-re", + "pickle.* shelve.* lib-dynload/cPickle.so" ) + + m.addPackage( 0, "python-pprint", "Python Pretty-Print Support", "python-core", + "pprint.*" ) + + m.addPackage( 0, "python-profile", "Python Basic Profiling Support", "python-core", + "profile.* pstats.*" ) + + m.addPackage( 0, "python-re", "Python Regular Expression APIs", "python-core", + "re.* sre.* sre_compile.* sre_constants* sre_parse.*" ) # _sre is builtin + + m.addPackage( 0, "python-readline", "Python Readline Support", "python-core, libreadline4", + "lib-dynload/readline.so rlcompleter.*" ) + + m.addPackage( 0, "python-resource", "Python Resource Control Interface", "python-core", + "lib-dynload/resource.so" ) + + m.addPackage( 0, "python-shell", "Python Shell-Like Functionality", "python-core, python-re", + "commands.* dircache.* fnmatch.* glob.* popen2.* shutil.*" ) + + m.addPackage( 0, "python-subprocess", "Python Subprocess Support", "python-core, python-io, python-re", + "subprocess.*" ) + + m.addPackage( 0, "python-stringold", "Python String APIs [deprecated]", "python-core, python-re", + "lib-dynload/strop.so string.*" ) + + m.addPackage( 0, "python-syslog", "Python's syslog Interface", "python-core", + "lib-dynload/syslog.so" ) + + m.addPackage( 0, "python-terminal", "Python Terminal Controlling Support", "python-core, python-io", + "pty.* tty.*" ) + + m.addPackage( 0, "python-tests", "Python Tests", "python-core", + "test" ) # package + + m.addPackage( 0, "python-threading", "Python Threading & Synchronization Support", "python-core, python-lang", + "_threading_local.* bisect.* dummy_thread.* dummy_threading.* mutex.* threading.* Queue.*" ) + + m.addPackage( 0, "python-unittest", "Python Unit Testing Framework", "python-core, python-stringold, python-lang", + "unittest.*" ) + + m.addPackage( 0, "python-xml", "Python basic XML support.", "python-core, python-re", + "lib-dynload/pyexpat.so xml xmllib.*" ) # package + + m.addPackage( 0, "python-xmlrpc", "Python XMLRPC Support", "python-core, python-xml, python-netserver, python-lang", + "xmlrpclib.* SimpleXMLRPCServer.*" ) + + m.addPackage( 1, "python-zlib", "Python zlib Support.", "python-core", + "lib-dynload/zlib.so" ) + + m.addPackage( 0, "python-mailbox", "Python Mailbox Format Support", "python-core, python-mime", + "mailbox.*" ) + + m.make() diff --git a/contrib/sanitize.py b/contrib/sanitize.py new file mode 100755 index 0000000000..27ca6e3d8d --- /dev/null +++ b/contrib/sanitize.py @@ -0,0 +1,392 @@ +#!/usr/bin/env python + +"""\ +Sanitize a bitbake file following the OpenEmbedded style guidelines, +see http://openembedded.org/wiki/StyleGuide + +(C) 2006 Cyril Romain <cyril.romain@gmail.com> +MIT license + +TODO: + - add the others OpenEmbedded variables commonly used: + - parse command arguments and print usage on misuse + . prevent giving more than one .bb file in arguments + - write result to a file + - backup the original .bb file + - make a diff and ask confirmation for patching ? + - do not use startswith only: + /!\ startswith('SOMETHING') is not taken into account due to the previous startswith('S'). + - count rule breaks and displays them in the order frequence +""" + +import fileinput +import string +import re + +__author__ = "Cyril Romain <cyril.romain@gmail.com>" +__version__ = "$Revision: 0.4 $" + +# The standard set of variables often found in .bb files in the preferred order +OE_vars = [ + 'DESCRIPTION', + 'AUTHOR', + 'HOMEPAGE', + 'SECTION', + 'PRIORITY', + 'MAINTAINER', + 'LICENSE', + 'DEPENDS', + 'RDEPENDS', + 'RRECOMMENDS', + 'RSUGGESTS', + 'PROVIDES', + 'RPROVIDES', + 'RCONFLICTS', + 'SRCDATE', + 'PV', + 'PR', + 'SRC_URI', + 'S', + 'GPE_TARBALL_SUFFIX', + 'inherit', + 'EXTRA_', + 'do_fetch', + 'do_unpack', + 'do_patch', + 'do_configure', + 'do_compile', + 'do_install', + 'do_package', + 'do_stage', + 'PACKAGE_ARCH', + 'PACKAGES', + 'FILES', + 'WORKDIR', + 'acpaths', + 'addhandler', + 'addtask', + 'bindir', + 'export', + 'headers', + 'include', + 'includedir', + 'python', + 'qtopiadir', + 'pkg_postins', + 'pkg_postrm', + 'require', + 'sbindir', + 'basesysconfdir', + 'sysconfdir', + 'ALLOW_EMPTY', + 'ALTERNATIVE_LINK', + 'ALTERNATIVE_NAME', + 'ALTERNATIVE_PATH', + 'ALTERNATIVE_PRIORITY', + 'ALTNAME', + 'AMD_DRIVER_LABEL', + 'AMD_DRIVER_VERSION', + 'ANGSTROM_EXTRA_INSTALL', + 'APPDESKTOP', + 'APPIMAGE', + 'APPNAME', + 'APPTYPE', + 'APPWEB_BUILD', + 'APPWEB_HOST', + 'AR', + 'ARCH', + 'ARM_INSTRUCTION_SET', + 'ARM_MUTEX', + 'ART_CONFIG', + 'B', + 'BJAM_OPTS', + 'BJAM_TOOLS', + 'BONOBO_HEADERS', + 'BOOTSCRIPTS', + 'BROKEN', + 'BUILD_ALL_DEPS', + 'BUILD_CPPFLAGS', + 'CFLAGS', + 'CCFLAGS', + 'CMDLINE', + 'COLLIE_MEMORY_SIZE', + 'COMPATIBLE_HOST', + 'COMPATIBLE_MACHINE', + 'COMPILE_HERMES', + 'CONFFILES', + 'CONFLICTS', + 'CORE_EXTRA_D', + 'CORE_PACKAGES_D', + 'CORE_PACKAGES_RD', + 'CPPFLAGS', + 'CVSDATE', + 'CXXFLAGS', + 'DEBIAN_NOAUTONAME', + 'DEBUG_APPS', + 'DEFAULT_PREFERENCE', + 'DB4_CONFIG', + 'EXCLUDE_FROM_SHLIBS', + 'EXCLUDE_FROM_WORLD', + 'FIXEDSRCDATE', + 'GLIBC_ADDONS', + 'GLIBC_EXTRA_OECONF', + 'GNOME_VFS_HEADERS', + 'HEADERS', + 'INHIBIT_DEFAULT_DEPS', + 'INITSCRIPT_NAME', + 'INITSCRIPT_PACKAGES', + 'INITSCRIPT_PARAMS', + 'IPKG_INSTALL', + 'KERNEL_IMAGETYPE', + 'KERNEL_IMAGEDEST', + 'KERNEL_OUTPUT', + 'KERNEL_RELEASE', + 'KERNEL_PRIORITY', + 'KERNEL_SOURCE', + 'KERNEL_SUFFIX', + 'KERNEL_VERSION', + 'K_MAJOR', + 'K_MICRO', + 'K_MINOR', + 'HHV', + 'KV', + 'LDFLAGS', + 'LD', + 'LD_SO', + 'LDLIBS', + 'LEAD_SONAME', + 'LIBTOOL', + 'LIBBDB_EXTRA', + 'LIBV', + 'MACHINE', + 'MACHINE_ESSENTIAL_EXTRA_RDEPENDS', + 'MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS', + 'MACHINE_EXTRA_RDEPENDS', + 'MACHINE_EXTRA_RRECOMMENDS', + 'MACHINE_FEATURES', + 'MACHINE_TASKS', + 'MACHTYPE', + 'MAKE_TARGETS', + 'MESSAGEUSER', + 'MESSAGEHOME', + 'MIRRORS', + 'MUTEX', + 'OE_QMAKE_INCDIR_QT', + 'OE_QMAKE_CXXFLAGS', + 'ORBIT_IDL_SRC', + 'PARALLEL_MAKE', + 'PAKCAGE_ARCH', + 'PCMCIA_MANAGER', + 'PKG_BASENAME', + 'QEMU', + 'QMAKE_PROFILES', + 'QPEDIR', + 'QPF_DESCRIPTION', + 'QPF_PKGPATTERN', + 'QT_CONFIG_FLAGS', + 'QT_LIBRARY', + 'ROOTFS_POSTPROCESS_COMMAND', + 'RREPLACES', + 'TARGET_CFLAGS', + 'TARGET_CPPFLAGS', + 'TARGET_LDFLAGS', + 'UBOOT_MACHINE', + 'UCLIBC_BASE', + 'UCLIBC_PATCHES', + 'UNSLUNG_PACKAGES', + 'VIRTUAL_NAME', + 'XORG_PN', + 'XSERVER', + 'others' +] + +varRegexp = r'^([A-Z_0-9]*)([ \t]*?)([+.:]?=[+.]?)([ \t]*?)("[^"]*["\\]?)' +routineRegexp = r'^([a-zA-Z0-9_ -]+?)\(' + +# Variables seen in the processed .bb +seen_vars = {} +for v in OE_vars: + seen_vars[v] = [] + +# _Format guideline #0_: +# No spaces are allowed at the beginning of lines that define a variable or +# a do_ routine +def respect_rule0(line): + return line.lstrip()==line +def conformTo_rule0(line): + return line.lstrip() + +# _Format guideline #1_: +# No spaces are allowed behind the line continuation symbol '\' +def respect_rule1(line): + if line.rstrip().endswith('\\'): + return line.endswith('\\') + else: + return True +def conformTo_rule1(line): + return line.rstrip() + +# _Format guideline #2_: +# Tabs should not be used (use spaces instead). +def respect_rule2(line): + return line.count('\t')==0 +def conformTo_rule2(line): + return line.expandtabs() + +# _Format guideline #3_: +# Comments inside bb files are allowed using the '#' character at the +# beginning of a line. +def respect_rule3(line): + if line.lstrip().startswith('#'): + return line.startswith('#') + else: + return True +def conformTo_rule3(line): + return line.lstrip() + +# _Format guideline #4_: +# Use quotes on the right hand side of assignments: FOO = "BAR" +def respect_rule4(line): + return re.match(varRegexp, line) is not None +def conformTo_rule4(line): + return conformTo_rule5_(line) + +# _Format guideline #5_: +# The correct spacing for a variable is FOO = "BAR". +def respect_rule5(line): + r = re.search(varRegexp, line) + return r is not None and r.group(2)==" " and r.group(4)==" " +def conformTo_rule5(line): + r = re.search(varRegexp, line) + return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)]) + +# _Format guideline #6_: +# Don't use spaces or tabs on empty lines +def respect_rule6(line): + return not line.isspace() or line=="\n" +def conformTo_rule6(line): + return "" + +# _Format guideline #7_: +# Indentation of multiline variables such as SRC_URI is desireable. +def respect_rule7(line): + return True +def conformTo_rule7(line): + return line + +rules = ( + (respect_rule0, conformTo_rule0, "No spaces are allowed at the beginning of lines that define a variable or a do_ routine"), + (respect_rule1, conformTo_rule1, "No spaces are allowed behind the line continuation symbol '\\'"), + (respect_rule2, conformTo_rule2, "Tabs should not be used (use spaces instead)"), + (respect_rule3, conformTo_rule3, "Comments inside bb files are allowed using the '#' character at the beginning of a line"), + (respect_rule4, conformTo_rule4, "Use quotes on the right hand side of assignments: FOO = \"BAR\""), + (respect_rule5, conformTo_rule5, "The correct spacing for a variable is FOO = \"BAR\""), + (respect_rule6, conformTo_rule6, "Don't use spaces or tabs on empty lines"), + (respect_rule7, conformTo_rule7, "Indentation of multiline variables such as SRC_URI is desireable"), +) + +# Function to check that a line respects a rule. If not, it tries to conform +# the line to the rule. Reminder or Disgression message are dump accordingly. +def follow_rule(i, line): + oldline = line + # if the line does not respect the rule + if not rules[i][0](line): + # try to conform it to the rule + line = rules[i][1](line) + # if the line still does not respect the rule + if not rules[i][0](line): + # this is a rule disgression + print "## Disgression: ", rules[i][2], " in:", line + else: + # just remind user about his/her errors + print "## Reminder: ", rules[i][2], " in :", oldline + return line + + +if __name__ == "__main__": + + # -- retrieves the lines of the .bb file -- + lines = [] + for line in fileinput.input(): + # use 'if True' to warn user about all the rule he/she breaks + # use 'if False' to conform to rules{2,1,6} without warnings + if True: + lines.append(line) + else: + # expandtabs on each line so that rule2 is always respected + # rstrip each line so that rule1 is always respected + line = line.expandtabs().rstrip() + # ignore empty lines (or line filled with spaces or tabs only) + # so that rule6 is always respected + if line is not '': + lines.append(line) + + # -- parse the file -- + var = "" + in_routine = False + commentBloc = [] + olines = [] + for line in lines: + # rstrip line to remove line breaks characters + line = line.rstrip() + line = follow_rule(2, line) + line = follow_rule(1, line) + line = follow_rule(6, line) + + # ignore empty lines + if line.isspace() or line is '': + # flush comments into the olines + for c in commentBloc: olines.append(c) + commentBloc = [] + continue + + if line.startswith('}'): in_routine=False + keep = line.endswith('\\') or in_routine + + # handles commented lines + if line.lstrip().startswith('#'): + # check and follow rule3 if not in a variables or routines + if not in_routine: + line = follow_rule(3, line) + commentBloc.append(line) + continue + + if seen_vars.has_key(var): + for c in commentBloc: + seen_vars[var].append(c) + commentBloc = [] + seen_vars[var].append(line) + else: + varexist = False + for k in OE_vars: + if line.startswith(k): + line = follow_rule(0, line) + varexist = True + if re.match(routineRegexp, line) is not None: + in_routine=True + elif re.match(varRegexp, line) is not None: + line = follow_rule(4, line) + line = follow_rule(5, line) + for c in commentBloc: + seen_vars[k].append(c) + commentBloc = [] + seen_vars[k].append(line) + var = (keep==True or in_routine==True) and k or "" + break + if not varexist: + if not in_routine: + print "## Warning: unknown variable/routine \"%s\"" % line + seen_vars['others'].append(line) + if not keep and not in_routine: var = "" + + # -- dump the sanitized .bb file -- + #for k in OE_vars: print k, OE_vars[k] + addEmptyLine = False + for k in OE_vars: + if k=='SRC_URI': addEmptyLine = True + if seen_vars[k] != []: + if addEmptyLine: olines.append("") + for l in seen_vars[k]: + olines.append(l) + for line in olines: print line + |