From 4e48b0dff613d7cd2150340dfd6495ff2cc3a99e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 21 Sep 2012 12:40:27 -0700 Subject: [PATCH] compat-drivers: add kup support with git-paranoia support kup [0] is the kernel.org uploader. This integrates support for usage of kup with the gen-release.sh script. When kup is used we also use git-paranoia which will bail out if either we have content on a git tree that lets us produce content that is not GPG signed, that has not yet been commited, or integrated into a git tree. To use kup just pass on the -u argument to gen-release.sh. For generic releases, that do not use kup (without -u) we still run git-paranoia but in interactive mode, allowing releases to be made that are not targeted for kernel.org with random junk or not GPG signed junk. [0] https://korg.wiki.kernel.org/index.php/Userdoc:using_kup Signed-off-by: Luis R. Rodriguez --- Makefile | 1 + scripts/gen-release.sh | 67 +++++++++++++++++++++++-- scripts/git-paranoia | 109 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+), 4 deletions(-) create mode 100755 scripts/git-paranoia diff --git a/Makefile b/Makefile index 5fee583f6534..6eccff63e41d 100644 --- a/Makefile +++ b/Makefile @@ -154,6 +154,7 @@ install-scripts: @# All the scripts we can use @mkdir -p $(DESTDIR)/usr/lib/compat-drivers/ @install scripts/modlib.sh $(DESTDIR)/usr/lib/compat-drivers/ + @install scripts/git-paranoia $(DESTDIR)/usr/sbin/ @install scripts/madwifi-unload $(DESTDIR)/usr/sbin/ @# This is to allow switching between drivers without blacklisting @install scripts/athenable $(DESTDIR)/usr/sbin/ diff --git a/scripts/gen-release.sh b/scripts/gen-release.sh index 556db70b9d5b..3e2733ca4fac 100755 --- a/scripts/gen-release.sh +++ b/scripts/gen-release.sh @@ -39,6 +39,13 @@ NEXT_TREE="linux-next" STAGING=/tmp/staging/compat-drivers/ +GIT_DIRS="$GIT_DIRS $HOME/compat/" +GIT_DIRS="$GIT_DIRS $HOME/devel/compat-drivers/" +GIT_DIRS="$GIT_DIRS $HOME/linux-next/" +GIT_DIRS="$GIT_DIRS $HOME/linux-stable/" + +export GIT_DIRS="$GIT_DIRS" + function usage() { echo -e "Usage:" @@ -47,7 +54,7 @@ function usage() 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 -e "${GREEN}$1${NORMAL} ${BLUE}[ -s | -n | -p | -c | -u ]${NORMAL}" echo echo Examples usages: echo @@ -62,6 +69,7 @@ function usage() UPDATE_ARGS="" POSTFIX_RELEASE_TAG="-" +USE_KUP="" if [ -z $GIT_TREE ]; then export GIT_TREE=$HOME/$NEXT_TREE @@ -80,6 +88,7 @@ if [ -z $GIT_TREE ]; then fi else echo "You said to use git tree at: $GIT_TREE" + GIT_DIRS="$GIT_DIRS $GIT_TREE" fi COMPAT_DRIVERS_DIR=$(pwd) @@ -94,6 +103,7 @@ EXISTING_BRANCH=$(git branch | grep \* | awk '{print $2}') # You can override the target branch by specifying an argument # to this script. TARGET_BRANCH="$EXISTING_BRANCH" +TARGET_TAG="$(git describe)" while [ $# -ne 0 ]; do if [[ "$1" = "-s" ]]; then @@ -117,6 +127,11 @@ while [ $# -ne 0 ]; do shift; continue; fi + if [[ "$1" = "-u" ]]; then + USE_KUP="1" + shift; continue; + fi + echo -e "Unexpected argument passed: ${RED}${1}${NORMAL}" usage $0 exit @@ -160,6 +175,26 @@ mkdir -p $STAGING cp -a $COMPAT_DRIVERS_DIR $STAGING/$RELEASE cd $STAGING/$RELEASE +# Only use interactive paranoia for non-signed / uploaded to kernel.org releases +PARANOIA="" +if [[ "$USE_KUP" != "1" ]]; then + PARANOIA="-i" +fi +./scripts/git-paranoia $PARANOIA +if [[ $? -ne 0 ]]; then + if [[ "$PARANOIA" != "-i" ]]; then + echo -e "Given that this is a targeted ${CYAN}kernel.org${NORMAL} release we are bailing." + exit 1 + fi + echo + echo -e "Detected some tree content is not yet ${RED}GPG signed${NORMAL}..." + read -p "Do you still want to continue (y/N)? " + if [[ "${REPLY}" != "y" ]]; then + echo -e "Bailing out !" + exit 1 + fi +fi + ./scripts/admin-update.sh $UPDATE_ARGS rm -rf $STAGING/$RELEASE/.git @@ -182,9 +217,6 @@ bzip2 -k -9 ${RELEASE}.tar # the tarball. gpg --armor --detach-sign ${RELEASE}.tar -# XXX: Add this for daily / stable release: -# kup put ${RELEASE}.tar.bz2 ${RELEASE}.tar.asc /pub/linux/kernel/projects/backports/2012/09/18/ - echo echo "compat-drivers release: $RELEASE" echo "Size: $(du -h ${RELEASE_TAR})" @@ -192,3 +224,30 @@ echo "sha1sum: $(sha1sum ${RELEASE_TAR})" echo echo "Release: ${STAGING}${RELEASE_TAR}" echo "Release signature: ${STAGING}${RELEASE}.tar.asc" + +if [[ "$USE_KUP" != "1" ]]; then + exit 0 +fi + +# Where we dump backport releases onto kernel.org +KORG_BACKPORT="/pub/linux/kernel/projects/backports/" + +if [[ "$BASE_TREE" = "linux-next" ]]; then + YEAR=$(echo $TARGET_TAG | awk -F "-" '{print $2}' | cut -c 1-4) + MONTH=$(echo $TARGET_TAG | awk -F "-" '{print $2}' | cut -c 5-6) + DAY=$(echo $TARGET_TAG | awk -F "-" '{print $2}' | cut -c 7-8) + + + kup mkdir ${KORG_BACKPORT}/${YEAR} > /dev/null 2>&1 + kup mkdir ${KORG_BACKPORT}/${YEAR}/${MONTH}/ > /dev/null 2>&1 + kup mkdir ${KORG_BACKPORT}/${YEAR}/${MONTH}/${DAY}/ > /dev/null 2>&1 + + kup ls ${KORG_BACKPORT}/${YEAR}/${MONTH}/${DAY}/ | grep ${RELEASE}.tar.bz2 > /dev/null 2>&1 + if [[ $? -eq 0 ]]; then + echo -e "File ${KORG_BACKPORT}/${YEAR}/${MONTH}/${DAY}/${BLUE}${RELEASE}.tar.bz2${NORMAL} already exists" + fi + + kup put ${RELEASE}.tar.bz2 ${RELEASE}.tar.asc ${KORG_BACKPORT}/${YEAR}/${MONTH}/${DAY}/ +else + echo XXX +fi diff --git a/scripts/git-paranoia b/scripts/git-paranoia new file mode 100755 index 000000000000..fcb2df0c258a --- /dev/null +++ b/scripts/git-paranoia @@ -0,0 +1,109 @@ +#!/bin/bash +# +# git-paranoia: for those parnaoid about what goes into releases based on git. +# +# Copyright 2012 Luis R. Rodriguez +# +# 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. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Pretty colors +GREEN="\033[01;32m" +YELLOW="\033[01;33m" +NORMAL="\033[00m" +BLUE="\033[34m" +RED="\033[31m" +PURPLE="\033[35m" +CYAN="\033[36m" +UNDERLINE="\033[02m" + +INTERACTIVE="0" + +function usage() +{ + echo -e "Usage: ${GREEN}$1${NORMAL} ${BLUE}[ -i ]${NORMAL}" + echo -e "-i\tInteractive, allows user to override paranoia" + echo + echo -e "Example usage:" + echo + echo -e "export GIT_DIRS=\"${HOME}/linux-stable/ ${HOME}/linux-next\"" + echo -e "$1" + echo + exit +} + +function __git_paranoia() +{ + for i in $GIT_DIRS; do + if [[ ! -d $i ]]; then + echo -e "${BLUE}$i${NORMAL} does not exist" + return 1 + fi + + cd $i; + + printf "Verifying ${BLUE}%15s\t${CYAN}%40s\t" $(basename $i) $(git describe) + git tag -v $(git describe --dirty) > /dev/null 2>&1 + if [[ $? -ne 0 || $(git status -s | wc -l) -ne 0 ]]; then + echo -e "[${RED}FAILED${NORMAL}]" + # We're paranoid, not only do we want the git tag to be GPG signed + # but we also want *no* unepxected content on the releases! If you have + # any files that do not belong into the git tree, nuke them, we won't do it + # for you! + if [[ $(git status -s | wc -l) -ne 0 ]]; then + echo -e "Not commited content:" + git status -s + fi + return 1 + else + echo -e "[${GREEN}OK!${NORMAL}]" + fi + done +} + +if [[ -z $GIT_DIRS ]]; then + echo -e "${RED}Error${NORMAL}:" + echo -e "Set the ${CYAN}GIT_DIRS${NORMAL} environment variable with your list of git trees" + echo + usage $0 + exit 1 +fi + +while [ $# -ne 0 ]; do + if [[ "$1" = "-i" ]]; then + INTERACTIVE="1" + shift; continue; + fi + echo -e "Unexpected argument passed: ${RED}${1}${NORMAL}" + usage $0 + exit +done + +__git_paranoia + +if [[ $? -ne 0 ]]; then + echo + echo -e "Detected some tree content is not yet ${RED}GPG signed${NORMAL}..." + if [[ "$INTERACTIVE" = "0" ]]; then + exit 1 + fi + + read -p "Do you still want to continue (y/N)? " + if [[ "${REPLY}" != "y" ]]; then + echo -e "Bailing out !" + exit 1 + fi +fi + +exit 0 -- 2.30.2