First version of the new devserver client
Review URL: http://codereview.chromium.org/661447
diff --git a/buildutil.py b/buildutil.py
index ade5428..66d3630 100644
--- a/buildutil.py
+++ b/buildutil.py
@@ -24,104 +24,3 @@
"""
if err != 0:
raise Exception("%s failed to execute" % cmd)
-
-
-class BuildUtil(BuildObject):
-
- def GetPackageName(self, pkg_path):
- cmd = "cat %s/debian/control | grep Package: | cut -d \" \" -f 2-" % pkg_path
- return os.popen(cmd).read().strip()
-
- def GetLastBuildTime(self, pkg_name):
- # TODO(rtc): convert this to local time.
- cmd = "stat -c %s %s/%s*" % ("%Y", self.x86_pkg_dir, pkg_name)
- utc_time = os.popen(cmd).read().strip()
- return datetime.fromtimestamp(int(utc_time))
-
- def GetPackageBuildPath(self, pkg_name):
- cmd = "stat -c %s %s/%s*" % ("%n", self.x86_pkg_dir, pkg_name)
- return os.popen(cmd).read().strip()
-
- def GetPackageBuildFile(self, build_path):
- return build_path.replace(self.x86_pkg_dir + "/", "")
-
- def BuildPackage(self, pkg="all"):
- """
- Builds the given package and copies the output to the static dir so that
- it can be downloaded.
-
- If pkg=all is specified then the kernel and all platform packages
- will be built. A new system image will also be created.
-
- If pkg=packages is specified then all platform packages
- will be built and a new system image will be created.
- """
- if pkg == "all":
- err = os.system("%s/build_all.sh" % self.scripts_dir)
- self.AssertSystemCallSuccess(err)
- return None
-
- if pkg == "packages":
- err = os.system("%s/build_platform_packages.sh" % self.scripts_dir)
- self.AssertSystemCallSuccess(err)
- err = os.system("%s/build_image.sh" % self.scripts_dir)
- self.AssertSystemCallSuccess(err)
- return None
-
- pkg_properties = self.GetPackages().get(pkg, None)
- if pkg_properties == None:
- raise Exception("Unknown package name %s" % pkg)
-
- cmd = "(cd %s; ./make_pkg.sh)" % pkg_properties.get("source_path")
- err = os.system(cmd)
- self.AssertSystemCallSuccess(err, cmd)
-
- # Reset pkg_properties after building so that output_path and
- # output_file_name are set up properly.
- pkg_properties = self.GetPackages().get(pkg, None)
-
- cmd = "cp %s %s" % (pkg_properties.get("output_path"), self.static_dir)
- err = os.system(cmd)
- self.AssertSystemCallSuccess(err, cmd)
-
- return pkg_properties.get("output_file_name")
-
-
- def GetPackages(self):
- """
- Lists all of the packages that can be built with a make_pkg.sh script.
-
- Returns a dictionary with the following keys
- name: the name of the package.
- build_time: the time the package was last built (in UTC).
- source_path: the path to the package in the source tree.
- output_path: the path to the deb created by make_pkg.sh.
- output_file_name: the name of the deb created by make_pkg.sh
- """
- pkgs = {}
- cli = os.popen("find %s -name make_pkg.sh" % self.root_dir).read().split('\n')
- for pkg in cli:
- if pkg == "":
- continue
- pkg_path = pkg.replace("/make_pkg.sh", "", 1)
- pkg_name = self.GetPackageName(pkg_path)
- if pkg_name == "":
- web.debug("unable to find a package info for %s" % pkg_path)
- continue
-
- build_path = self.GetPackageBuildPath(pkg_name)
-
- build_time = None
- build_file = None
- if build_path != "":
- build_time = self.GetLastBuildTime(pkg_name)
- build_file = self.GetPackageBuildFile(build_path)
-
- pkgs[pkg_name] = {
- "name": pkg_name,
- "build_time": build_time,
- "source_path": pkg_path,
- "output_path": build_path,
- "output_file_name": build_file
- }
- return pkgs
diff --git a/devserver.py b/devserver.py
index 67db0ff..ad6ece6 100644
--- a/devserver.py
+++ b/devserver.py
@@ -3,7 +3,6 @@
# found in the LICENSE file.
import autoupdate
-import buildutil
import os
import web
import sys
@@ -27,26 +26,18 @@
def POST(self):
return updater.HandleUpdatePing(web.data())
-class webbuild:
- """
- builds the package specified by the pkg parameter. Then redirects to index
- """
- def GET(self):
- input = web.input()
- web.debug("called %s " % input.pkg)
- output = buildbot.BuildPackage(input.pkg)
- web.debug("copied %s to static" % output)
- raise web.seeother('/')
-
class build:
"""
builds the package specified by the pkg parameter and returns the name
of the output file.
"""
- def GET(self):
+ def POST(self):
input = web.input()
- web.debug("called %s " % input.pkg)
- return buildbot.BuildPackage(input.pkg)
+ web.debug("emerging %s " % input.pkg)
+ emerge_command = "emerge-%s %s" % (input.board, input.pkg)
+ err = os.system(emerge_command)
+ if err != 0:
+ raise Exception("failed to execute %s" % emerge_command)
if __name__ == "__main__":
@@ -57,7 +48,6 @@
os.system("mkdir -p %s" % static_dir)
updater = autoupdate.Autoupdate(root_dir=root_dir, static_dir=static_dir)
- buildbot = buildutil.BuildUtil(root_dir=root_dir, static_dir=static_dir)
urls = ('/', 'index',
'/update', 'update',
diff --git a/gmerge b/gmerge
new file mode 100755
index 0000000..c81af05
--- /dev/null
+++ b/gmerge
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set -e
+
+DEVKIT_URL=$(grep ^CHROMEOS_DEVSERVER /etc/lsb-release | cut -d = -f 2-)
+BOARD_NAME=$(grep ^CHROMEOS_RELEASE_BOARD $dir/etc/lsb-release | cut -d = -f 2-)
+
+if [ -z $DEVKIT_URL ]
+then
+ echo "No devkit server specified in /etc/lsb-release"
+ exit 1
+fi
+
+if [ -z $BOARD_NAME ]
+then
+ echo "No board specified in /etc/lsb-release"
+ exit 1
+fi
+
+mount -o remount,rw /
+mkdir -p /etc/make.profile
+
+echo "Building $1"
+ESCAPED_PACKAGE=$(python -c "import urllib; print urllib.quote('''$1''')")
+ESCAPED_BOARD=$(python -c \
+ "import urllib; print urllib.quote('''${BOARD_NAME}''')")
+
+wget $DEVKIT_URL/build --post-data="pkg=${ESCAPED_PACKAGE}&board=${ESCAPED_BOARD}"
+
+echo "Emerging $1"
+
+export PORTAGE_BINHOST="${DEVKIT_URL}/static/pkgroot/${BOARD_NAME}/packages"
+export PORTAGE_TMPDIR=/tmp
+export ACCEPT_KEYWORDS=x86
+
+emerge --getbinpkg --usepkgonly $1
diff --git a/static/pkgroot b/static/pkgroot
new file mode 120000
index 0000000..42afabf
--- /dev/null
+++ b/static/pkgroot
@@ -0,0 +1 @@
+/build
\ No newline at end of file