summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit2obs-kernel-sync169
-rw-r--r--git2obs.conf15
-rw-r--r--oscrc6
-rw-r--r--quiltrc10
4 files changed, 200 insertions, 0 deletions
diff --git a/git2obs-kernel-sync b/git2obs-kernel-sync
new file mode 100755
index 0000000..334ebb9
--- /dev/null
+++ b/git2obs-kernel-sync
@@ -0,0 +1,169 @@
+#! /bin/bash
+# vim:set et ts=2 sw=2:
+
+# Copyright © 2015 Collabora Ltd
+# Copyright © 2015 Valve Corporation
+# Author: Hector Oron Martinez <hector.oron@collabora.co.uk>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+set -e
+
+LOG_DIR=/tmp
+LOG_FILE=steamos-kernel.log
+exec >> "$LOG_DIR"/"$LOG_FILE" 2>&1
+
+f="/etc/default/git2obs.conf $(pwd)/git2obs.conf"
+for ff in $f ; do
+echo "INFO: Trying to load $ff configuration file"
+test -f $ff && \
+ . $ff && \
+ echo "INFO: Loaded $ff configuration file"
+done
+
+D=$(dirname $(readlink -f $0))
+OSC="osc -c${D}/oscrc"
+DQUILT="quilt --quiltrc=${D}/quiltrc-dpkg"
+GIT_UPSTREAM_COMMIT_HEAD=""
+declare -a NDVERSION
+declare -a GITKVER
+
+echo "INFO: Daily checkout started on " $(date +%Y%m%d-%H%M)
+trap cleanup ERR TERM HUP INT QUIT EXIT
+
+checkout_git_kernel() {
+ if [ ! -d "$WORKING_DIR/cache/$GIT_PRJ" ]
+ then
+ echo "INFO: Doing initial checkout of $GIT_PRJ into $WORKING_DIR/cache ..."
+ (
+ mkdir -p "$WORKING_DIR/cache"; cd "$WORKING_DIR/cache"
+ git clone "$GIT_URL" -b "$GIT_BRANCH" "$GIT_PRJ"
+ git config remote.upstream.url git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
+ git fetch upstream --tags
+ )
+ fi
+ echo "INFO: Updating $GIT_PRJ checkout ..."
+ (
+ cd "$WORKING_DIR/cache/$GIT_PRJ"
+ git pull
+ git clean -dxf
+ GITKVER="$(git show-ref HEAD | cut -d' ' -f1)"
+ echo "INFO: $GIT_PRJ revision $GITKVER"
+ )
+}
+
+checkout_obs_pkg() {
+ if [ ! -d "$WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG" ]
+ then
+ (
+ #rm -rf "$WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG"
+ echo "INFO: Doing initial OBS checkout of $GIT_PRJ into $WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG ..."
+ mkdir -p "$WORKING_DIR/cache"; cd "$WORKING_DIR/cache"
+ osc bco "$OBS_PRJ/$OBS_PKG"
+ )
+ fi
+}
+
+unpack_obs_kernel() {
+ if [ -d "$WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG" ]
+ then
+ echo "INFO: Unpacking $GIT_PRJ into $WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG ..."
+ (
+ cd "$WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG"
+ version_guess=$(osc ls "$OBS_PRJ" "$OBS_PKG" | grep dsc | cut -f2 -d_ | cut -f1 -d"-")
+ if ! dpkg-source -x "$OBS_PKG"*"${version_guess}"*dsc ; then
+ echo "ERROR: Failed to unpack $OBS_PKG*dsc";
+ exit 1;
+ fi
+ #osc rm -f "$OBS_PKG*changes" "$OBS_PKG*dsc" "$OBS_PKG*debian.tar.*"
+ cd "$WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG/$OBS_PKG"-"${version_guess}"
+
+ if NAME=$NAME uscan --verbose --download-version $KERNEL_UPSTREAM_VERSION ; then
+ echo "INFO: New upstream tarball version $KERNEL_UPSTREAM_VERSION";
+ new_version="yes"
+ else
+ echo "INFO: Package version $(dpkg-parsechangelog | sed -n 's/^Version: //p')"
+ fi
+ )
+ fi
+}
+
+extract_patches_git_kernel() {
+ if [ -d "$WORKING_DIR/cache/$GIT_PRJ" ]
+ then
+ echo "INFO: Extract patches from $GIT_PRJ into $WORKING_DIR/patches ..."
+ (
+ rm -rf "$WORKING_DIR/patches/$OBS_PATCH_DIR"
+ mkdir -p "$WORKING_DIR/patches/$OBS_PATCH_DIR"; cd "$WORKING_DIR/cache/$GIT_PRJ"
+ git format-patch -o "$WORKING_DIR/patches/$OBS_PATCH_DIR" v"$KERNEL_UPSTREAM_VERSION"..HEAD
+ )
+ fi
+}
+
+patch_update() {
+ echo "INFO: Copying $GIT_PRJ patches in $WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG ..."
+ (
+ cd "$WORKING_DIR/cache/$GIT_PRJ"
+ GITKVER="$(git show-ref HEAD | cut -d' ' -f1)"
+
+ cd "$WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG/$OBS_PKG"-"${KERNEL_UPSTREAM_VERSION}"
+
+ ${DQUILT} pop -a || true
+
+ # remove old patches
+ for p in debian/patches/$OBS_PATCH_DIR/*; do
+ ${DQUILT} delete -r $p
+ done
+
+ # Add new patches
+ for p in ${WORKING_DIR}/patches/"$OBS_PATCH_DIR"/*; do
+ cp $p debian/patches/"$OBS_PATCH_DIR"/
+ echo $OBS_PATCH_DIR/$(basename ${p}) >> debian/patches/series
+ done
+
+ ${DQUILT} push -a
+
+ if [ "$new_version" = yes ] ; then
+ NDVERSION="${KERNEL_UPSTREAM_VERSION}-0+$OBS_BUILD_TAG${REV}"
+ echo "New debian version: ${NDVERSION}"
+ NAME=$NAME dch -b -v "${NDVERSION}" "Git snapshot $GITKVER"
+ else
+ NAME=$NAME dch -b -i "Git snapshot $GITKVER"
+ fi
+
+ NAME=$NAME dch -r "Sync git upload" -D $SUITE --force-distribution
+
+ DEB_BUILD_OPTIONS="nocheck parallel=4" dpkg-buildpackage -I.git -i.git -us -uc -rfakeroot -S -d
+ )
+}
+
+upload_result() {
+ echo "INFO: Uploading $GIT_PRJ into $OBS_BPRJ/$OBS_PKG ..."
+ cd "$WORKING_DIR/cache/$OBS_BPRJ/$OBS_PKG"
+ osc addremove
+ echo osc ci -m "update kernel $GIT_UPSTREAM_COMMIT_HEAD"
+ echo osc sr -m "update kernel $GIT_UPSTREAM_COMMIT_HEAD" $OBS_PRJ
+}
+
+cleanup () {
+ echo "INFO: cleanup build directory ..."
+ if [ -n "$WORKING_DIR/patches" ]
+ then
+ echo rm --one-file-system -rf "$WORKING_DIR/patches"
+ WORKING_DIR=""
+ fi
+ echo "INFO: Exiting now ..."
+ exit 0
+}
+
+#checkout_git_kernel
+#checkout_obs_pkg
+#unpack_obs_kernel
+#extract_patches_git_kernel
+patch_update
+#upload_result
+echo "INFO: Please manually upload your kernel after verifying it."
+echo "INFO: If you prefer to automate this step, please comment $0 last lines from script"
diff --git a/git2obs.conf b/git2obs.conf
new file mode 100644
index 0000000..2e9d392
--- /dev/null
+++ b/git2obs.conf
@@ -0,0 +1,15 @@
+NAME="ValveBot"
+DEBEMAIL="noreply@valvesoftware.com"
+REV=1
+SUITE="brewmaster"
+GIT_URL="https://github.com/ValveSoftware/steamos_kernel"
+GIT_BRANCH="brewmaster-3.18"
+GIT_PRJ="steamos_kernel"
+KERNEL_UPSTREAM_VERSION="3.18.16"
+OBS_USERNAME="zumbi"
+OBS_PRJ="steamos:brewmaster:main"
+OBS_BPRJ="home:$OBS_USERNAME:branches:$OBS_PRJ"
+OBS_PKG="linux"
+OBS_PATCH_DIR="valve"
+OBS_BUILD_TAG="steamos"
+WORKING_DIR="/tmp"
diff --git a/oscrc b/oscrc
new file mode 100644
index 0000000..8dbf5f2
--- /dev/null
+++ b/oscrc
@@ -0,0 +1,6 @@
+[general]
+apiurl = https://***URL***:444
+
+[https://***URL***:444]
+user=***USER***
+pass=***PASS***
diff --git a/quiltrc b/quiltrc
new file mode 100644
index 0000000..7f74f4c
--- /dev/null
+++ b/quiltrc
@@ -0,0 +1,10 @@
+d=. ; while [ ! -d $d/debian -a `readlink -e $d` != / ]; do d=$d/..; done
+if [ -d $d/debian ] && [ -z $QUILT_PATCHES ]; then
+ # if in Debian packaging tree with unset $QUILT_PATCHES
+ QUILT_PATCHES="debian/patches"
+ QUILT_PATCH_OPTS="--reject-format=unified"
+ QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto"
+ QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
+ QUILT_COLORS="diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33"
+ if ! [ -d $d/debian/patches ]; then mkdir $d/debian/patches; fi
+fi