chiark / gitweb /
Externalize srclibs to fdroiddata
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 20 May 2013 11:16:06 +0000 (13:16 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 20 May 2013 11:16:06 +0000 (13:16 +0200)
fdroidserver/common.py

index 74ced163163a71fda983eaf927efdf2d0cb3f354..a76e9e0104a69ff48c0b8e1c7ef2740fa8d6d28b 100644 (file)
@@ -909,970 +909,91 @@ class MetaDataException(Exception):
     def __str__(self):
         return repr(self.value)
 
+def parse_srclib(metafile, **kw):
 
-# Get the specified source library.
-# Returns the path to it. Normally this is the path to be used when referencing
-# it, which may be a subdirectory of the actual project. If you want the base
-# directory of the project, pass 'basepath=True'.
-# TODO: These are currently just hard-coded in this method. It will be a
-# metadata-driven system eventually, but not yet.
-def getsrclib(spec, extlib_dir, sdk_path, basepath=False):
-
-    name, ref = spec.split('@')
-
-    if name == 'GreenDroid':
-        sdir = os.path.join(extlib_dir, 'GreenDroid')
-        vcs = getvcs('git',
-            'https://github.com/cyrilmottier/GreenDroid.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return os.path.join(sdir, 'GreenDroid')
-
-    if name == 'Dropbear':
-        sdir = os.path.join(extlib_dir, 'Dropbear')
-        vcs = getvcs('git',
-            'https://github.com/CyanogenMod/android_external_dropbear.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'ActionBarSherlock':
-        sdir = os.path.join(extlib_dir, 'ActionBarSherlock')
-        vcs = getvcs('git',
-            'https://github.com/JakeWharton/ActionBarSherlock.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        # For latest ABS releases
-        if not os.path.exists(libdir):
-            libdir = os.path.join(sdir, 'actionbarsherlock')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating ActionBarSherlock project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'Google-Gson':
-        sdir = os.path.join(extlib_dir, 'Google-Gson')
-        vcs = getvcs('git-svn',
-        'http://google-gson.googlecode.com/svn;trunk=trunk;tags=tags', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'gson')
-        return libdir
-
-    if name == 'libsuperuser':
-        sdir = os.path.join(extlib_dir, 'libsuperuser')
-        vcs = getvcs('git',
-        'https://github.com/Chainfire/libsuperuser', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'libsuperuser')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'AndroidUtils':
-        sdir = os.path.join(extlib_dir, 'AndroidUtils')
-        vcs = getvcs('git',
-        'https://github.com/yuriykulikov/AndroidUtils', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'Amazing-ListView':
-        sdir = os.path.join(extlib_dir, 'Amazing-ListView')
-        vcs = getvcs('git-svn',
-           'http://android-amazing-listview.googlecode.com/svn/trunk', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'AmazingListView')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating Amazing-ListView project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'ViewPagerIndicator':
-        sdir = os.path.join(extlib_dir, 'ViewPagerIndicator')
-        vcs = getvcs('git',
-            'https://github.com/JakeWharton/Android-ViewPagerIndicator.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating Android-ViewPagerIndicator project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'UITableView':
-        sdir = os.path.join(extlib_dir, 'UITableView')
-        vcs = getvcs('git',
-            'https://github.com/thiagolocatelli/android-uitableview.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'android-uitableview')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating UITableView project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'ViewPagerTabs':
-        sdir = os.path.join(extlib_dir, 'ViewPagerTabs')
-        vcs = getvcs('git',
-            'https://github.com/astuetz/android-viewpagertabs.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        pp = open(os.path.join(sdir, 'project.properties'), 'w')
-        pp.write('android.library=true\n')
-        pp.write('target=android-15\n')
-        pp.close()
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating ViewPagerTabs project')
-        return sdir
-
-    if name == 'ActionBar':
-        sdir = os.path.join(extlib_dir, 'ActionBar')
-        vcs = getvcs('git',
-            'https://github.com/johannilsson/android-actionbar.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'actionbar')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating ActionBar project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'ActionBarNW':
-        sdir = os.path.join(extlib_dir, 'ActionBarNW')
-        vcs = getvcs('git',
-            'https://github.com/NightWhistler/android-actionbar.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'actionbar')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating ActionBarNW project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'FacebookSDK':
-        sdir = os.path.join(extlib_dir, 'FacebookSDK')
-        vcs = getvcs('git',
-                'git://github.com/facebook/facebook-android-sdk.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'facebook')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating FacebookSDK project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'OI':
-        sdir = os.path.join(extlib_dir, 'OI')
-        vcs = getvcs('git-svn',
-                'http://openintents.googlecode.com/svn/trunk/', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'JOpenDocument':
-        sdir = os.path.join(extlib_dir, 'JOpenDocument')
-        vcs = getvcs('git',
-                'https://github.com/andiwand/JOpenDocument.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        shutil.rmtree(os.path.join(sdir, 'bin'))
-        return sdir
-
-    if name == 'BitcoinJWallet':
-        sdir = os.path.join(extlib_dir, 'BitcoinJWallet')
-        vcs = getvcs('git',
-                'https://code.google.com/r/andreasschildbach-bitcoinj/', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'Color-Picker':
-        sdir = os.path.join(extlib_dir, 'Color-Picker')
-        vcs = getvcs('git',
-            'https://github.com/brk3/android-color-picker.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating Color-Picker project')
-        return sdir
-
-    if name == 'Processing-Multitouch':
-        sdir = os.path.join(extlib_dir, 'Processing-Multitouch')
-        vcs = getvcs('git',
-           'https://github.com/rjmarsan/AndroidProcessingMultitouch.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating Multitouch project')
-        return sdir
-
-    if name == 'NewQuickAction3D':
-        sdir = os.path.join(extlib_dir, 'NewQuickAction3D')
-        vcs = getvcs('git',
-           'https://github.com/alt236/NewQuickAction3D.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating NewQuickAction3D project')
-        return sdir
-
-    if name == 'AnySoftKeyboard-API':
-        sdir = os.path.join(extlib_dir, 'AnySoftKeyboard-API')
-        vcs = getvcs('git',
-            'https://github.com/AnySoftKeyboard/AnySoftKeyboard-API.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating AnySoftKeyboard-API project')
-        return sdir
-
-    if name == 'File-Picker':
-        sdir = os.path.join(extlib_dir, 'File-Picker')
-        vcs = getvcs('hg',
-           'https://code.google.com/p/android-file-picker/', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating File-Picker project')
-        return sdir
-
-    if name == 'EmulatorView':
-        sdir = os.path.join(extlib_dir, 'EmulatorView')
-        vcs = getvcs('git',
-            'https://github.com/jackpal/Android-Terminal-Emulator.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'libraries', 'emulatorview')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating EmulatorView project')
-        if basepath:
-            return sdir
-        return libdir
-
-    #Leave the native code as a blob; submodules required for that
-    if name == 'Libpd':
-        sdir = os.path.join(extlib_dir, 'Libpd')
-        vcs = getvcs('git',
-           'https://github.com/libpd/pd-for-android.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'PdCore')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('LibPd project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'Tree-View-List':
-        sdir = os.path.join(extlib_dir, 'Tree-View-List')
-        vcs = getvcs('hg',
-           'https://code.google.com/p/tree-view-list-android/', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating Tree-List-View project')
-        return sdir
-
-    if name == 'PrayTimes':
-        sdir = os.path.join(extlib_dir, 'PrayTimes')
-        vcs = getvcs('git',
-           'https://github.com/ebraminio/PrayTimes.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'HoloEverywhere':
-        sdir = os.path.join(extlib_dir, 'HoloEverywhere')
-        vcs = getvcs('git',
-           'https://github.com/ChristopheVersieux/HoloEverywhere.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating HoloEverywhere project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'PullToRefresh':
-        sdir = os.path.join(extlib_dir, 'PullToRefresh')
-        vcs = getvcs('git',
-           'https://github.com/chrisbanes/Android-PullToRefresh.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'TessTwo':
-        sdir = os.path.join(extlib_dir, 'TessTwo')
-        vcs = getvcs('git',
-           'https://github.com/rmtheis/tess-two.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'tess-two')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating TessTwo project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'TwidereExtension':
-        sdir = os.path.join(extlib_dir, 'TwidereExtension')
-        vcs = getvcs('git',
-           'https://github.com/mariotaku/twidere-extension-library.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'EncfsJava':
-        sdir = os.path.join(extlib_dir, 'EncfsJava')
-        vcs = getvcs('git',
-           'https://github.com/mrpdaemon/encfs-java.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'FinfAgent':
-        sdir = os.path.join(extlib_dir, 'FinfAgent')
-        vcs = getvcs('git',
-           'https://github.com/uniqdom/FinfAgent.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating FinfAgent project')
-        return sdir
-
-    if name == 'MobAdMob':
-        sdir = os.path.join(extlib_dir, 'MobAdMob')
-        vcs = getvcs('git',
-           'https://github.com/mar-v-in/MobAdMob.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'MobAdMob')
-        pp = open(os.path.join(libdir, 'project.properties'), 'w')
-        pp.write('android.library=true\n')
-        pp.write('target=android-16\n')
-        pp.close()
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating MobAdMob project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'WebSMSAPI':
-        sdir = os.path.join(extlib_dir, 'WebSMSAPI')
-        vcs = getvcs('git',
-           'https://github.com/felixb/websms-api.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating WebSMSAPI project')
-        shutil.rmtree(os.path.join(sdir, 'test'))
-        return sdir
-
-    if name == 'ub0rlib':
-        sdir = os.path.join(extlib_dir, 'ub0rlib')
-        vcs = getvcs('git',
-           'https://github.com/felixb/ub0rlib.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating ub0rlib project')
-        return sdir
-
-    if name == 'JustPlayerPluginsAdView':
-        sdir = os.path.join(extlib_dir, 'JustPlayerPluginsAdView')
-        vcs = getvcs('git',
-           'https://bitbucket.org/yokmama/just-player-plugins.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'AdView')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating JustPlayerPluginsAdview project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'NoAnalytics':
-        sdir = os.path.join(extlib_dir, 'NoAnalytics')
-        vcs = getvcs('git',
-           'https://github.com/mar-v-in/NoAnalytics.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'NoAnalytics')
-        pp = open(os.path.join(libdir, 'project.properties'), 'w')
-        pp.write('android.library=true\n')
-        pp.write('target=android-16\n')
-        pp.close()
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating NoAnalytics project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'TintAddon':
-       sdir = os.path.join(extlib_dir, 'TintAddon')
-        vcs = getvcs('git',
-           'https://github.com/Anasthase/TintBrowserAddonFrameworkLibrary.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating TintAddon project')
-        return sdir
-
-    if name == 'EyesFree':
-        sdir = os.path.join(extlib_dir, 'EyesFree')
-        vcs = getvcs('git-svn',
-           'http://eyes-free.googlecode.com/svn/trunk', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'SL4A':
-        sdir = os.path.join(extlib_dir, 'SL4A')
-        vcs = getvcs('hg',
-           'https://code.google.com/p/android-scripting', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'GNUPG':
-        sdir = os.path.join(extlib_dir, 'GNUPG')
-        vcs = getvcs('git',
-           'https://github.com/guardianproject/gnupg-for-android.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'IOCipher':
-        sdir = os.path.join(extlib_dir, 'IOCipher')
-        vcs = getvcs('git',
-           'https://github.com/guardianproject/IOCipher.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'FFMPEG-Java':
-        sdir = os.path.join(extlib_dir, 'FFMPEG-Java')
-        vcs = getvcs('git',
-           'https://github.com/guardianproject/android-ffmpeg-java.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'Slider':
-        sdir = os.path.join(extlib_dir, 'Slider')
-        vcs = getvcs('git',
-           'https://github.com/Xlythe/Slider', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating Slider project')
-        return sdir
-
-    if name == 'NumberPicker':
-        sdir = os.path.join(extlib_dir, 'NumberPicker')
-        vcs = getvcs('git',
-           'https://github.com/thibault/NumberPickerWidget.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'RootCommands':
-        sdir = os.path.join(extlib_dir, 'RootCommands')
-        vcs = getvcs('git',
-           'https://github.com/dschuermann/root-commands.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'RootCommands-Library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating RootCommands project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'LibPageKite':
-        sdir = os.path.join(extlib_dir, 'LibPageKite')
-        vcs = getvcs('git',
-           'https://github.com/pagekite/libpagekite.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'OpenSSL-GP':
-        sdir = os.path.join(extlib_dir, 'OpenSSL-GP')
-        vcs = getvcs('git',
-           'https://github.com/guardianproject/openssl-android.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'NumberPicker-SimonVT':
-        sdir = os.path.join(extlib_dir, 'NumberPicker-SimonVT')
-        vcs = getvcs('git',
-           'https://github.com/SimonVT/android-numberpicker.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating NumberPicker-SimonVT project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'ComicViewer':
-        sdir = os.path.join(extlib_dir, 'ComicViewer')
-        vcs = getvcs('git',
-           'https://github.com/tcoxon/ComicViewer.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating ComicViewer project')
-        return sdir
-
-    if name == 'GitHubAPI':
-        sdir = os.path.join(extlib_dir, 'GitHubAPI')
-        vcs = getvcs('git',
-           'git://git.eclipse.org/gitroot/egit/egit-github.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'org.eclipse.egit.github.core')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'Busybox':
-        sdir = os.path.join(extlib_dir, 'Busybox')
-        vcs = getvcs('git',
-           'git://busybox.net/busybox.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'BusyboxConfigs':
-        sdir = os.path.join(extlib_dir, 'BusyboxConfigs')
-        vcs = getvcs('git',
-           'https://github.com/tias/android-busybox-ndk.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'AppMsg':
-        sdir = os.path.join(extlib_dir, 'AppMsg')
-        vcs = getvcs('git',
-           'https://github.com/johnkil/Android-AppMsg.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating AppMsg project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'BillingLibrary':
-        sdir = os.path.join(extlib_dir, 'BillingLibrary')
-        vcs = getvcs('git',
-           'https://github.com/robotmedia/AndroidBillingLibrary.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'AndroidBillingLibrary')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating BillingLibrary project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'FilePicker':
-        sdir = os.path.join(extlib_dir, 'FilePicker')
-        vcs = getvcs('git',
-           'https://github.com/Filepicker/filepicker-android.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating AppMsg project')
-        return sdir 
-
-    if name == 'aFileChooser':
-        sdir = os.path.join(extlib_dir, 'aFileChooser')
-        vcs = getvcs('git',
-           'https://github.com/TomTasche/aFileChooser', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'aFileChooser')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating aFileChooser project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'SlidingMenu':
-        sdir = os.path.join(extlib_dir, 'SlidingMenu')
-        vcs = getvcs('git',
-           'https://github.com/jfeinstein10/SlidingMenu', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating SlidingMenu project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'K9Mail-XOAUTH':
-        sdir = os.path.join(extlib_dir, 'K9Mail-XOAUTH')
-        vcs = getvcs('git',
-           'https://github.com/jberkel/k9mail.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-t', 'android-10', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating KMail-XOAUTH project')
-        return sdir
-
-    if name == 'RootTools':
-        sdir = os.path.join(extlib_dir, 'RootTools')
-        vcs = getvcs('svn',
-           'http://roottools.googlecode.com/svn/trunk/Stable/RootTools-sdk3-generic', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        pp = open(os.path.join(sdir, 'project.properties'), 'w')
-        pp.write('android.library=true\n')
-        pp.write('target=android-16\n')
-        pp.close()
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p', 
-            sdir]) != 0:
-            raise BuildException('Error updating RootTools project')
-        os.remove(os.path.join(sdir, 'android.jar'))
-        return sdir
-
-    if name == 'OsmAnd-tools':
-        sdir = os.path.join(extlib_dir, 'OsmAnd-tools')
-        vcs = getvcs('git',
-           'https://github.com/osmandapp/OsmAnd-tools', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'OsmAnd-core':
-        sdir = os.path.join(extlib_dir, 'OsmAnd-core')
-        vcs = getvcs('git',
-           'https://github.com/osmandapp/OsmAnd-core', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
-
-    if name == 'AndrozicLib':
-        sdir = os.path.join(extlib_dir, 'AndrozicLib')
-        vcs = getvcs('git',
-           'https://github.com/andreynovikov/androzic-library', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating AndrozicLib project')
-        return sdir
-
-    if name == 'Otr4j':
-       sdir = os.path.join(extlib_dir, 'Otr4j')
-        vcs = getvcs('git',
-           'https://github.com/redsolution/otr4j.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    thisinfo = {}
+    if metafile and not isinstance(metafile, file):
+        metafile = open(metafile, "r")
 
-    if name == 'AnySoftKeyboardTools':
-        sdir = os.path.join(extlib_dir, 'AnySoftKeyboardTools')
-        vcs = getvcs('git',
-           'https://github.com/AnySoftKeyboard/AnySoftKeyboardTools', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    # Defaults for fields that come from metadata
+    thisinfo['Repo Type'] = ''
+    thisinfo['Repo'] = ''
+    thisinfo['Subdir'] = None
+    thisinfo['Prepare'] = None
+    thisinfo['Update Project'] = None
 
-    if name == 'DashClock':
-        sdir = os.path.join(extlib_dir, 'DashClock')
-        vcs = getvcs('git',
-           'https://code.google.com/p/dashclock', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    if metafile is None:
+        return thisinfo
 
-    if name == 'KoushWidgets':
-        sdir = os.path.join(extlib_dir, 'KoushWidgets')
-        vcs = getvcs('git',
-           'https://github.com/koush/Widgets', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'Widgets')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating KoushWidgets project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'HoloColorPicker':
-        sdir = os.path.join(extlib_dir, 'HoloColorPicker')
-        vcs = getvcs('git',
-           'https://github.com/frigus02/HoloColorPicker', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating HoloColorPicker project')
-        return sdir
+    mode = 0
+    buildlines = []
 
-    if name == 'ColorPickerPreference':
-        sdir = os.path.join(extlib_dir, 'ColorPickerPreference')
-        vcs = getvcs('git',
-           'https://github.com/attenzione/android-ColorPickerPreference', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating ColorPickerPreference project')
-        return sdir
+    for line in metafile:
+        line = line.rstrip('\r\n')
+        if len(line) == 0:
+            continue
+        if line.startswith("#"):
+            continue
+        index = line.find(':')
+        if index == -1:
+            raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
+        field = line[:index]
+        value = line[index+1:]
+
+        if field == "Subdir":
+            thisinfo[field] = value.split(',')
+        else:
+            thisinfo[field] = value
 
-    if name == 'ChartLib':
-        sdir = os.path.join(extlib_dir, 'ChartLib')
-        vcs = getvcs('git',
-           'https://bitbucket.org/frigus02/chartlib', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating ChartLib project')
-        return sdir
+    return thisinfo
 
-    if name == 'MeterLib':
-        sdir = os.path.join(extlib_dir, 'MeterLib')
-        vcs = getvcs('git',
-           'https://github.com/zaren678/HdhomerunSignalMeterLib', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating MeterLib project')
-        return sdir
+# Get the specified source library.
+# Returns the path to it. Normally this is the path to be used when referencing
+# it, which may be a subdirectory of the actual project. If you want the base
+# directory of the project, pass 'basepath=True'.
+def getsrclib(spec, extlib_dir, sdk_path, basepath=False):
 
-    if name == 'SunriseSunset':
-        sdir = os.path.join(extlib_dir, 'SunriseSunset')
-        vcs = getvcs('git',
-           'https://github.com/mikereedell/sunrisesunsetlib-java', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    name, ref = spec.split('@')
 
-    if name == 'LocaleAPI':
-        sdir = os.path.join(extlib_dir, 'LocaleAPI')
-        vcs = getvcs('git',
-                'https://git.gitorious.org/locale-api/mirror.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating LocaleAPI project')
-        return sdir
+    srclib_path = os.path.join('srclibs', name + ".txt")
 
-    if name == 'iptables':
-        sdir = os.path.join(extlib_dir, 'iptables')
-        vcs = getvcs('git',
-           'https://android.googlesource.com/platform/external/iptables', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    if not os.path.exists(srclib_path):
+        raise BuildException('srclib ' + name + ' not found.')
 
-    if name == 'LockPattern':
-        sdir = os.path.join(extlib_dir, 'LockPattern')
-        vcs = getvcs('hg',
-           'https://code.google.com/p/android-lockpattern', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'code')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating LockPattern project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'XChange':
-        sdir = os.path.join(extlib_dir, 'XChange')
-        vcs = getvcs('git',
-           'https://github.com/timmolter/XChange', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    srclib = parse_srclib(srclib_path)
 
-    if name == 'MusicBrainz-API':
-        sdir = os.path.join(extlib_dir, 'MusicBrainz-API')
-        vcs = getvcs('git',
-        'https://github.com/jdamcd/musicbrainz-android', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'api')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'XChart':
-        sdir = os.path.join(extlib_dir, 'XChart')
-        vcs = getvcs('git',
-           'https://github.com/timmolter/XChart', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'xchart')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'Libxmp':
-        sdir = os.path.join(extlib_dir, 'Libxmp')
-        vcs = getvcs('git',
-           'git://git.code.sf.net/p/xmp/libxmp', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    sdir = os.path.join(extlib_dir, name)
+    vcs = getvcs(srclib["Repo Type"], srclib["Repo"], sdir, sdk_path)
+    vcs.gotorevision(ref)
 
-    if name == 'MenuDrawer':
-        sdir = os.path.join(extlib_dir, 'MenuDrawer')
-        vcs = getvcs('git',
-           'https://github.com/SimonVT/android-menudrawer', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating MenuDrawer project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'ImageLoader':
-        sdir = os.path.join(extlib_dir, 'ImageLoader')
-        vcs = getvcs('git',
-           'https://github.com/nostra13/Android-Universal-Image-Loader.git', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating ImageLoader project')
-        if basepath:
-            return sdir
-        shutil.rmtree(os.path.join(sdir, 'downloads'))
-        return libdir
-
-    if name == 'DragSort':
-        sdir = os.path.join(extlib_dir, 'DragSort')
-        vcs = getvcs('git',
-           'https://github.com/bauerca/drag-sort-listview', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating DragSort project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'QuickdicUtils':
-        sdir = os.path.join(extlib_dir, 'QuickdicUtils')
-        vcs = getvcs('git',
-           'https://code.google.com/p/quickdic-dictionary.util', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating QuickdicUtils project')
-        return sdir
+    libdir = None
 
-    if name == 'PrettyTime':
-        sdir = os.path.join(extlib_dir, 'PrettyTime')
-        vcs = getvcs('git',
-           'https://github.com/ocpsoft/prettytime', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    if srclib["Subdir"] is not None:
+        for subdir in srclib["Subdir"]:
+            libdir_candidate = os.path.join(sdir, subdir)
+            if os.path.exists(libdir_candidate):
+                libdir = libdir_candidate
+                break
 
-    if name == 'ShowCase-Androzic':
-        sdir = os.path.join(extlib_dir, 'ShowCase-Androzic')
-        vcs = getvcs('git',
-           'https://github.com/andreynovikov/ShowcaseView', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-l', '../../NineOldAndroids/library', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating ShowCase project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'NineOldAndroids':
-        sdir = os.path.join(extlib_dir, 'NineOldAndroids')
-        vcs = getvcs('git',
-           'https://github.com/JakeWharton/NineOldAndroids', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p', 
-            libdir]) != 0:
-            raise BuildException('Error updating NineOldAndroids project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'Jutf7':
-        sdir = os.path.join(extlib_dir, 'Jutf7')
-        vcs = getvcs('git-svn',
-           'https://jutf7.svn.sourceforge.net/svnroot/jutf7/trunk', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        return sdir
+    if libdir is None:
+        libdir = sdir
 
-    if name == 'Common-AskSven':
-        sdir = os.path.join(extlib_dir, 'Common-AskSven')
-        vcs = getvcs('git',
-           'https://github.com/asksven/AndroidCommon', sdir, sdk_path)
-        vcs.gotorevision(ref)
+    if srclib["Prepare"] is not None:
+        p = subprocess.Popen(srclib["Prepare"], cwd=libdir, shell=True,
+                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        out, err = p.communicate()
+        if p.returncode != 0:
+            raise BuildException("Error running prepare command for srclib "
+                    + name, out, err)
+    
+    if srclib["Update Project"] == "Yes":
         if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            sdir]) != 0:
-            raise BuildException('Error updating Common-AskSven project')
-        return sdir
+            'update', 'project', '-p', libdir]) != 0:
+                raise BuildException( 'Error updating ' + name + ' project')
 
-    if name == 'PhotoView':
-        sdir = os.path.join(extlib_dir, 'PhotoView')
-        vcs = getvcs('git',
-       'https://github.com/chrisbanes/PhotoView', sdir, sdk_path)
-        vcs.gotorevision(ref)
-        libdir = os.path.join(sdir, 'library')
-        if subprocess.call([os.path.join(sdk_path, 'tools', 'android'),
-            'update', 'project', '-p',
-            libdir]) != 0:
-            raise BuildException('Error updating PhotoView project')
-        if basepath:
-            return sdir
-        return libdir
-
-    if name == 'Rescu':
-        sdir = os.path.join(extlib_dir, 'Rescu')
-        vcs = getvcs('git',
-           'https://github.com/mmazi/rescu', sdir, sdk_path)
-        vcs.gotorevision(ref)
+    if basepath:
         return sdir
-
-    raise BuildException('Unknown srclib ' + name)
+    return libdir
 
 
 # Prepare the source code for a particular build