#!/usr/bin/env bash
-# Copyright 2009 Luis R. Rodriguez <mcgrof@gmail.com>
+# Copyright 2009-2012 Luis R. Rodriguez <mcgrof@do-not-panic.com>
#
-# You can use this to make stable compat-drivers releases
+# You can use this to make compat-drivers releases:
+#
+# * daily linux-next.git based compat-drivers releases
+# * linux-stable.git / linux.git stable releases
#
# The assumption is you have the linux-stable git tree on your $HOME
+#
# git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
+# git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
#
-# Local branches will be created based on the remote linux-2.6.X.y branches.
-# If your branch already exists we will nuke it for you to avoid rebasing.
+# You can add linux.git on to your linux-stable.git as a remote to get
+# Linus's RC's and you should add linux-stable.git as a local remote
+# to your linux-next.git so you can get then get the linux-stable tags
+# for your linux-next.git tree.
#
-# If no kernel is specified we use the latest rc-release, which will be on the
-# remove master branch. Your master branch should be clean.
+# By default we refer to the GIT_TREE variable for where we are pulling
+# code for a release and guestimate what type of release you want
+# from that. By default we assume you want a daily linux-next.git tree
+# release.
# Pretty colors
GREEN="\033[01;32m"
PURPLE="\033[35m"
CYAN="\033[36m"
UNDERLINE="\033[02m"
+
GIT_STABLE_URL="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git"
+GIT_NEXT_URL="git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git"
+
+STABLE_TREE="linux-stable"
+NEXT_TREE="linux-next"
-# Note that this tree may not have the latest RC stuff, so you should also add
-# Linus' tree as a remote and fetch those objects if you want to make an RC
-# release instead.
-ALL_STABLE_TREE="linux-stable"
STAGING=/tmp/staging/compat-drivers/
function usage()
{
- echo -e "Usage: ${GREEN}$1${NORMAL} ${BLUE}[ -n | -p | -c | -f | -i ]${NORMAL} ${CYAN}[ linux-2.6.X.y ]${NORMAL}"
+ echo -e "Usage:"
+ echo -e ""
+ echo -e "export GIT_TREE=${HOME}/linux-stable/"
+ echo -e "or"
+ echo -e "export GIT_TREE=${HOME}/linux-next/"
+ echo -e ""
+ echo -e "${GREEN}$1${NORMAL} ${BLUE}[ -s | -n | -p | -c ]${NORMAL}"
echo
echo Examples usages:
echo
- echo -e "${PURPLE}${1}${NORMAL}"
- echo -e "${PURPLE}${1} ${CYAN}linux-2.6.29.y${NORMAL}"
- echo -e "${PURPLE}${1} ${CYAN}linux-2.6.30.y${NORMAL}"
+ echo -e "export GIT_TREE=${HOME}/linux-stable/"
+ echo -e "${PURPLE}${1} -s -n -p -c${NORMAL}"
+ echo or
+ echo -e "export GIT_TREE=${HOME}/linux-next/"
+ echo -e "${PURPLE}${1} -p -c${NORMAL}"
echo
- echo -e "If no kernel is specified we try to make a release based on the latest RC kernel."
- echo -en "If a kernel release is specified ${CYAN}X${NORMAL} is the next stable release "
- echo -en "as ${CYAN}35${NORMAL} in ${CYAN}2.6.35.y${NORMAL}\n"
exit
}
POSTFIX_RELEASE_TAG="-"
if [ -z $GIT_TREE ]; then
- export GIT_TREE=$HOME/$ALL_STABLE_TREE
+ export GIT_TREE=$HOME/$NEXT_TREE
if [ ! -d $GIT_TREE ]; then
- echo "Please tell me where your linux-stable git tree is."
+ echo "Please tell me where your linux-next or linux-stable git tree is."
echo "You can do this by exporting its location as follows:"
echo
- echo " export GIT_TREE=/home/$USER/linux-stable/"
+ echo " export GIT_TREE=${HOME}/linux-next/"
+ echo "or"
+ echo " export GIT_TREE=${HOME}/linux-stable/"
echo
- echo "If you do not have one you can clone the repository:"
+ echo "If you do not have one you can clone the repositories at:"
echo " git clone $GIT_STABLE_URL"
+ echo " git clone $GIT_NEXT_URL"
exit 1
fi
else
- echo "You said to use git tree at: $GIT_TREE for linux-stable"
+ echo "You said to use git tree at: $GIT_TREE"
fi
+
COMPAT_DRIVERS_DIR=$(pwd)
COMPAT_DRIVERS_BRANCH=$(git branch | grep \* | awk '{print $2}')
# to this script.
TARGET_BRANCH="$EXISTING_BRANCH"
-# By default we will not do a git fetch and reset of the branch,
-# use -f if you want to force an update, this will delete all
-# of your local patches so be careful.
-FORCE_UPDATE="no"
-
while [ $# -ne 0 ]; do
if [[ "$1" = "-s" ]]; then
UPDATE_ARGS="${UPDATE_ARGS} $1"
POSTFIX_RELEASE_TAG="${POSTFIX_RELEASE_TAG}c"
shift; continue;
fi
- if [[ "$1" = "-f" ]]; then
- FORCE_UPDATE="yes"
- shift; continue;
- fi
-
- if [[ $(expr "$1" : '^linux-') -eq 6 ]]; then
- TARGET_BRANCH="$1"
- shift; continue;
- fi
echo -e "Unexpected argument passed: ${RED}${1}${NORMAL}"
usage $0
exit
done
-function check_for_updates()
-{
- case $TARGET_BRANCH in
- "master") # Preparing a new stable compat-drivers release based on an RC kernel
- git checkout -f
- git fetch
- git reset --hard origin
- ;;
- *) # Based on a stable {2.6.x.y, 3.x.y} release, lets just move to the target branch
- # we'll only ask for object updates if and only if you asked us to with -f,
- # otherwise we eat up whatever you already have on your existing branch.
- git checkout -f
- git fetch
- git branch -D $TARGET_BRANCH
- git checkout -b $TARGET_BRANCH origin/$TARGET_BRANCH
- ;;
- esac
-}
-
-# We will not update your linux-stable git tree by default. You can force
-# an update by two methods:
-#
-# a) Specifying a different target branch
-# b) Specifying the -f flag to this script
-if [[ "$FORCE_UPDATE" = "yes" || "$TARGET_BRANCH" != "$EXISTING_BRANCH" ]]; then
- check_for_updates
-else
- echo -e "Skipping $ALL_STABLE_TREE git tree update checks for branch: $TARGET_BRANCH"
-fi
-
-echo "On $ALL_STABLE_TREE: $TARGET_BRANCH"
+BASE_TREE=$(basename $GIT_TREE)
-# At this point your linux-stable tree should be up to date
-# with the target kernel you want to use. Lets now make sure you are
-# on matching compat-drivers branch.
+echo "On ${BASE_TREE}: $TARGET_BRANCH"
+# Lets now make sure you are on matching compat-drivers branch.
# This is a super hack, but let me know if you figure out a cleaner way
TARGET_KERNEL_RELEASE=$(make VERSION="linux-3" SUBLEVEL="" EXTRAVERSION=".y" kernelversion)
-BASE_TREE=$(basename $GIT_TREE)
-
if [[ $COMPAT_DRIVERS_BRANCH != $TARGET_KERNEL_RELEASE && $BASE_TREE != "linux-next" ]]; then
echo -e "You are on the compat-drivers ${GREEN}${COMPAT_DRIVERS_BRANCH}${NORMAL} but are "
echo -en "on the ${RED}${TARGET_KERNEL_RELEASE}${NORMAL} branch... "
fi
fi
-
cd $COMPAT_DRIVERS_DIR
if [[ $COMPAT_DRIVERS_BRANCH != "master" ]]; then