ubuntu系统下载android源码

来源:互联网 发布:淘宝大拿韩代是正品吗 编辑:程序博客网 时间:2024/05/17 06:49

主要是记载一下下载源码过程中的一些问题和解决方法:

1. 
首先,按照http://source.android.com/source/initializing.html官方网站上得要求,配置了一个Ubuntu的源代码下载环境。
从Ubuntu官网上:http://releases.ubuntu.com/lucid/
下载了一个ubuntu-desktop-386的镜像,之后用虚拟机建了一个ubuntu的系统。
之后按照官网上得要求执行以下命令:
下载java SDK 6和安装一些需要的库
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev \
  libx11-dev libreadline6-dev libgl1-mesa-dev tofrodos python-markdown \
  libxml2-utils xsltproc
2.
 接着,配置要环境之后,按照http://source.android.com/source/downloading.html官网上得步骤下载源码。
创建bin目录,把bin目录加入到PATH环境变量中:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
通过curl命令下载repo脚本:(通过这个脚本可以方便源码的操作)
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
创建源码文件夹:
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
初始化repo:
$ repo init -u https://android.googlesource.com/platform/manifest
下载源码:
$ repo sync


问题出就出在repo sync这个命令上,首先在根据所要下载的版本初始化repo的时候,会在WORKING_DIRECTORY/.repo的目录下初始化一些版本的信息,包括这个版本的所包含的project的信息。
这些信息是存储在WORKING_DIRECTORY/.repo/manifest.xml结构化文件中。
之后repo sync 命令通过读取.repo中的版本信息,去源码库中下载。
由于网络的问题。repo sync 老是执行不完全,要么是time out, 要么就是访问出错。


在网上找了一些解决方法。
有一个方法不错,既然repo sync 是通过读取manifest.xml来下载源码的,那么可以通过脚本解析manifest.xml文件,获得project信息。
之后用repo sync projectname的方式,一个project一个project的下载。
下面是用到的脚本:
#!/bin/bash
declare -a projnames
tmp=`sed -n -e 's/<project //' -e 's/\/>//p' $1 | sed -e  's/path="//' -e 's/name="//' -e 's/"//g'`
projs=($(echo $tmp))
echo ${#projs[*]}

for((i=0; i<${#projs[*]}; i++))
do
  # projnames[j]=${projs[++i]}
#echo ${projs[++i]}
com=${projs[++i]}
echo "repo sync $com"
done


把这个脚本存成name.sh。
之后把manifest.xml文件作为参数传入即可。
命令:name.sh manifest.xml
输出如下:
repo sync bionic
repo sync bootable/bootloader/legacy
repo sync bootable/diskinstaller
repo sync bootable/recovery
repo sync cts
repo sync dalvik
repo sync development
repo sync device/common
repo sync device/google/accessory/arduino
repo sync device/google/accessory/demokit
repo sync device/htc/common
repo sync device/htc/passion
repo sync device/htc/passion-common
repo sync device/sample
repo sync device/samsung/crespo
repo sync device/samsung/crespo4g
repo sync external/apache-http
repo sync external/astl
repo sync external/bison
repo sync external/blktrace
repo sync external/bluetooth/bluez
repo sync external/bluetooth/glib
repo sync external/bluetooth/hcidump
repo sync external/bouncycastle
repo sync external/bsdiff
repo sync external/bzip2
repo sync external/chromium
repo sync external/clearsilver
repo sync external/dbus
repo sync external/dhcpcd
repo sync external/dnsmasq
repo sync external/dropbear
repo sync external/e2fsprogs
repo sync external/easymock
repo sync external/elfcopy
repo sync external/elfutils
repo sync external/embunit
repo sync external/emma
repo sync external/esd
repo sync external/expat
repo sync external/fdlibm
repo sync external/freetype
repo sync external/fsck_msdos
repo sync external/genext2fs
repo sync external/giflib
repo sync external/grub
repo sync external/gtest
repo sync external/guava
repo sync external/icu4c
repo sync external/iproute2
repo sync external/ipsec-tools
repo sync external/iptables
repo sync external/jdiff
repo sync external/jhead
repo sync external/jpeg
repo sync external/jsr305
repo sync external/junit
repo sync external/kernel-headers
repo sync external/libffi
repo sync external/libgsm
repo sync external/libnfc-nxp
repo sync external/libpcap
repo sync external/libpng
repo sync external/libvpx
repo sync external/libxml2
repo sync external/mtpd
repo sync external/netcat
repo sync external/netperf
repo sync external/neven
repo sync external/nist-sip
repo sync external/oauth
repo sync external/openssl
repo sync external/oprofile
repo sync external/ping
repo sync external/ppp
repo sync external/proguard
repo sync external/protobuf
repo sync external/qemu
repo sync revision=tools_r7
repo sync platform/external/quake
repo sync platform/external/replicaisland
repo sync platform/external/safe-iop
repo sync platform/external/skia
repo sync platform/external/sonivox
repo sync platform/external/speex
repo sync platform/external/sqlite
repo sync platform/external/srec
repo sync platform/external/stlport
repo sync platform/external/strace
repo sync platform/external/svox
repo sync platform/external/tagsoup
repo sync platform/external/tcpdump
repo sync platform/external/tinyxml
repo sync platform/external/tremolo
repo sync platform/external/v8
repo sync platform/external/webkit
repo sync platform/external/wpa_supplicant
repo sync platform/external/wpa_supplicant_6
repo sync platform/external/xmlwriter
repo sync platform/external/yaffs2
repo sync platform/external/zlib
repo sync platform/frameworks/base
repo sync platform/frameworks/ex
repo sync platform/frameworks/opt/emoji
repo sync platform/hardware/broadcom/wlan
repo sync platform/hardware/libhardware
repo sync platform/hardware/libhardware_legacy
repo sync platform/hardware/msm7k
repo sync platform/hardware/qcom/gps
repo sync platform/hardware/qcom/media
repo sync platform/hardware/ril
repo sync platform/hardware/ti/omap3
repo sync platform/hardware/ti/wlan
repo sync platform/libcore
repo sync platform/ndk
repo sync platform/packages/apps/AccountsAndSyncSettings
repo sync platform/packages/apps/Bluetooth
repo sync platform/packages/apps/Browser
repo sync platform/packages/apps/Calculator
repo sync platform/packages/apps/Calendar
repo sync platform/packages/apps/Camera
repo sync platform/packages/apps/CellBroadcastReceiver
repo sync platform/packages/apps/CertInstaller
repo sync platform/packages/apps/Contacts
repo sync platform/packages/apps/DeskClock
repo sync platform/packages/apps/Email
repo sync platform/packages/apps/Gallery
repo sync platform/packages/apps/Gallery3D
repo sync platform/packages/apps/HTMLViewer
repo sync platform/packages/apps/Launcher2
repo sync platform/packages/apps/Mms
repo sync platform/packages/apps/Music
repo sync platform/packages/apps/Nfc
repo sync platform/packages/apps/PackageInstaller
repo sync platform/packages/apps/Phone
repo sync platform/packages/apps/Protips
repo sync platform/packages/apps/Provision
repo sync platform/packages/apps/QuickSearchBox
repo sync platform/packages/apps/Settings
repo sync platform/packages/apps/SmartCardService
repo sync platform/packages/apps/SoundRecorder
repo sync platform/packages/apps/SpeechRecorder
repo sync platform/packages/apps/Stk
repo sync platform/packages/apps/Tag
repo sync platform/packages/apps/VoiceDialer
repo sync platform/packages/experimental
repo sync platform/packages/inputmethods/LatinIME
repo sync platform/packages/inputmethods/OpenWnn
repo sync platform/packages/inputmethods/PinyinIME
repo sync platform/packages/providers/ApplicationsProvider
repo sync platform/packages/providers/CalendarProvider
repo sync platform/packages/providers/ContactsProvider
repo sync platform/packages/providers/DownloadProvider
repo sync platform/packages/providers/DrmProvider
repo sync platform/packages/providers/GoogleContactsProvider
repo sync platform/packages/providers/MediaProvider
repo sync platform/packages/providers/TelephonyProvider
repo sync platform/packages/providers/UserDictionaryProvider
repo sync platform/packages/wallpapers/Basic
repo sync platform/packages/wallpapers/LivePicker
repo sync platform/packages/wallpapers/MagicSmoke
repo sync platform/packages/wallpapers/MusicVisualization
repo sync platform/prebuilt
repo sync platform/sdk
repo sync system/bluetooth
repo sync system/core
repo sync system/extras
repo sync system/media
repo sync system/netd
repo sync system/vold
repo sync system/wlan/ti


这个输出,就可以一个个考到shell中去执行了。


原创粉丝点击