]> git.wh0rd.org - home.git/commitdiff
my chromeos helpers
authorMike Frysinger <vapier@gentoo.org>
Wed, 14 Dec 2011 00:07:15 +0000 (19:07 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 28 Apr 2012 19:36:42 +0000 (15:36 -0400)
.bin/cros-board [new file with mode: 0755]
.bin/cros-cbuildbot [new file with mode: 0755]
.bin/cros-repo [new file with mode: 0755]

diff --git a/.bin/cros-board b/.bin/cros-board
new file mode 100755 (executable)
index 0000000..ac1126a
--- /dev/null
@@ -0,0 +1,94 @@
+#!/bin/bash
+. /etc/init.d/functions.sh || exit 1
+die() { eerror "$*"; exit 1; }
+set -e
+
+cd ${HOME}/trunk/src/scripts/
+
+if [[ -z ${BOARD} ]] ; then
+       die "missing BOARD"
+fi
+IMAGES="${HOME}/trunk/src/build/images/${BOARD}"
+BUILD="/build/${BOARD}"
+
+ARG_CLEAN=false
+ARG_DEV="/dev/sdb"
+ARG_DEV_USER=false
+ARG_PRETEND=false
+ARG_NOPKG=false
+ARG_VERBOSE=false
+ARG_TEST=false
+while [[ $# -ne 0 ]] ; do
+       case $1 in
+       --clean) ARG_CLEAN=true;;
+       -p) ARG_PRETEND=true;;
+       -y) shift; ARG_DEV=$1; ARG_DEV_USER=true;;
+       -v) ARG_VERBOSE=true;;
+       -t) ARG_TEST=true;;
+       --nousepkg) ARG_NOPKG=true;;
+       *) echo "unknown opt: $*"; exit 1;;
+       esac
+       shift
+done
+
+piperet() { set -- ${PIPESTATUS[@]/0}; [[ $# -eq 0 ]]; }
+run() {
+       set +e
+       ebegin "$*"
+       if ! ${ARG_PRETEND} ; then
+               local log="${IMAGES}"/log.${1##*/}
+               if ${ARG_VERBOSE} ; then
+                       "$@" |& tee "${log}"
+               else
+                       "$@" >& "${log}"
+               fi
+               piperet
+       fi
+       eend $? || exit $?
+       set -e
+}
+
+tfe() { ($1 && echo $2 || :); }
+
+mkdir -p "${IMAGES}"
+rm -f "${IMAGES}"/log.*
+
+einfo "Log root: ${IMAGES}/log."
+
+if ${ARG_CLEAN} || [[ ! -d ${BUILD} ]] ; then
+       run sudo rm -rf "${BUILD}"
+       run ./setup_board --board=${BOARD}
+       if [ $? -ne 0 ] ; then
+               run sudo rm -rf "${BUILD}"
+               exit 1
+       fi
+fi
+
+run ./build_packages --board=${BOARD} --oldchromebinary --nowithdebug $(tfe ${ARG_NOPKG} --nousepkg) $(tfe ${ARG_TEST} --withtest)
+BUILD_IMG="./build_image --board=${BOARD} --withdev --noenable_rootfs_verification $(tfe ${ARG_TEST} --test)"
+run ${BUILD_IMG}
+
+IMG_TO_USB="./image_to_usb.sh --board=${BOARD} -y --to=${ARG_DEV}"
+if ${ARG_DEV_USER} ; then
+       run ${IMG_TO_USB}
+       sync &
+fi
+
+cat <<EOF
+
+### LIVE
+${IMG_TO_USB}
+
+### KVM
+./image_to_vm.sh --board=${BOARD} --from=../build/images/${BOARD}/latest
+kvm -m 1024 -vga std -net nic,model=virtio -net user,hostfwd=tcp::9222-:22 -hda ~/chromiumos/src/build/images/${BOARD}/latest/chromiumos_qemu_image.bin
+
+### RECOVERY
+./mod_image_for_recovery.sh --board=${BOARD}
+${IMG_TO_USB} --image_name=recovery_image.bin
+
+### FACTORY
+${BUILD_IMG} --factory_install
+${IMG_TO_USB} -i factory_install_shim.bin
+
+EOF
diff --git a/.bin/cros-cbuildbot b/.bin/cros-cbuildbot
new file mode 100755 (executable)
index 0000000..7784d46
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+d=/usr/local/google/home/vapier
+if [[ -d ${d} ]] ; then
+       d+="/trybot"
+       if mount | grep -qs $d ; then
+               echo "mounts found in $d"
+               exit 1
+       fi
+
+       echo "Cleaning ${d}"
+       sudo rm -rf ${d}
+else
+       exit 1
+fi
+
+# find all the buildbot branches
+repos=$(r b | cut -b4- | awk '$1 == "bb" {
+       # Single repo output:
+       #   bb                        | in src/third_party/portage-stable
+       # Multi repo output:
+       #   bb                        | in:
+       #                                   src/third_party/portage-stable
+       #                                   src/third_party/chromiumos-overlay
+       if ($3 == "in")
+               print $NF
+       while (getline) {
+               if ($2 == "|")
+                       break;
+               print $NF;
+       }
+}')
+if [[ -n ${repos} ]] ; then
+       echo "Auto pulling patches from 'bb' branch in repos:"
+       printf '\t%s\n' ${repos}
+
+       p_flag=""
+       for r in ${repos} ; do
+               r=$(r list | awk -v r="${r}" '$1 == r { print $NF }')
+               p_flag+="${r}:bb "
+       done
+
+       set -- -p "${p_flag}" "$@"
+fi
+
+vexec() { echo "$@"; exec "$@"; }
+vexec cbuildbot --buildroot=${d} "$@"
diff --git a/.bin/cros-repo b/.bin/cros-repo
new file mode 100755 (executable)
index 0000000..d6c6de1
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+cd ~/chromiumos
+
+usage() {
+       cat <<-EOF
+       Usage: repo-cros <command> [command opts]
+
+       Commands:
+          int            switch to internal tree
+          ext            switch to external tree
+          -b <branch>    switch branches
+       EOF
+       exit ${1:-1}
+}
+[[ $# -eq 0 ]] && usage
+
+vexec() { echo "$@"; exec "$@"; }
+
+while [[ $# -gt 0 ]] ; do
+       case $1 in
+       int) vexec repo init -u ssh://gerrit-int.chromium.org:29419/chromeos/manifest-internal.git --repo-url='http://git.chromium.org/external/repo.git' ;;
+       ext) vexec repo init -u http://git.chromium.org/chromiumos/manifest.git --repo-url http://git.chromium.org/external/repo.git ;;
+       -b)  vexec repo init -b $2 ;;
+       *) usage ;;
+       esac
+done
+exit 0