On 24.07.17 20:49, Oscar C wrote:
Hi,

Is there a guide on how to build a downstream kernel in obs like a upstream genuine kernel?

I have a CHIP allwinner R8 with debian but I would like to use opensuse instead.

I found a link in the wiki to a script which is supposed to help with this (http://users.suse.com/~dmueller/contrib_kernel.sh) but like is dead to me.

Hm, looks like users.suse.com does not want to talk to anyone outside of the SUSE network. Hooray.

Either way, here's the script. You may need to adapt it a bit, as it's been a while since I last used it. But overall it should still do what you expect.

Alex

---

#!/bin/bash
#
# Script to create an openSUSE Contrib kernel from downstream sources.
#
# Please use with care. No warranty granted if anything goes wrong. This
# file is public domain and free for everyone to use, distribute and modify.
#
# Author: Alexander Graf <[email protected]>
#
########

KERNEL_FLAVOR="$1"
KERNEL_ARCH="$2"
KERNEL_ARCHIVE="$3"
KERNEL_CONFIG="$4"
OBS_PRJ="$5"

# Sanity check command line
if [ ! "$1" -o ! "$2" -o ! "$3" -o ! "$4" -o ! "$5" ]; then
echo "Syntax: $0 <kernel flavor> <arch> <kernel tar.xz> <kernel config> <osc repo>

Example: $0 midway armv7hl linux-midway-3.16.tar.xz linux-midway.config home:algraf:ARM:Factory:Contrib:Midway

Available architectures:

  armv6hl
  armv7hl
  arm64
"

    exit 1
fi

# Sanity check kernel
KERNEL_TAR_VERSION=$( tar tf "$KERNEL_ARCHIVE" | head -n1 )
if [ "${KERNEL_TAR_VERSION:0:6}" != "linux-" ]; then
    echo "ERROR: Invalid tar archive

Please provide a tar archive that contains the Linux tree inside
of a directory named as

  linux-version

such as

  linux-3.16-rc1"

    exit 1
fi

# Derive kernel version from tarball

KERNEL_VERSION="${KERNEL_TAR_VERSION:6}"
KERNEL_VERSION="$(basename $KERNEL_VERSION)"

# Sanity check arch

case $KERNEL_ARCH in
  armv6hl|armv7hl|arm64)
    ;;
  *)
    echo "ERROR! Invalid architecture.

Available architectures:

  armv6hl
  armv7hl
  arm64
"
    exit 1
    ;;
esac

###

if [ ! "$KERNEL_SOURCE_GIT" ]; then
    KERNEL_SOURCE_GIT=git://kernel.opensuse.org/kernel-source.git
    DEFAULT_KERNEL_SOURCE_GIT=1
fi

echo "Welcome to the openSUSE Contrib kernel creator.

We will now create a kernel-source package and a kernel-$KERNEL_FLAVOR package.
We will also add these two packages to your $OBS_PRJ repository.

The first thing I will do is to fetch the openSUSE kernel-source.git from

  $KERNEL_SOURCE_GIT
"

if [ "$DEFAULT_KERNEL_SOURCE_GIT" ]; then
echo "If this takes too long for your taste, please keep a local copy of the
*most recent* kernel-source.git around and put its location into the
KERNEL_SOURCE_GIT environemnt variable.
"
fi


SRC=/dev/shm/kernel-source.$$

git clone $KERNEL_SOURCE_GIT $SRC
cp "$KERNEL_ARCHIVE" "$SRC/linux-${KERNEL_VERSION}.tar.xz"
cp "$KERNEL_CONFIG" "$SRC/config/armv6hl/$KERNEL_FLAVOR"
cp "$KERNEL_CONFIG" "$SRC/config/armv7hl/$KERNEL_FLAVOR"
cp "$KERNEL_CONFIG" "$SRC/config/arm64/$KERNEL_FLAVOR"

(
  cd $SRC
  echo patches.rpmify/firmware-path > series.conf
  echo "
+armv6hl        armv6hl/$KERNEL_FLAVOR
+armv7hl        armv7hl/$KERNEL_FLAVOR
+arm64          arm64/$KERNEL_FLAVOR
" > config.conf
  sed -i "s/^SRCVERSION=.*$/SRCVERSION=$KERNEL_VERSION/" rpm/config.sh
  ./scripts/sequence-patch.sh
  (
    cd tmp/linux-$KERNEL_VERSION-master/
    ./run_oldconfig.sh --flavor $KERNEL_FLAVOR -a $KERNEL_ARCH
  )
  ./scripts/tar-up.sh
)

echo "We finished assembling a kernel-source package. You can find it at

  $SRC/kernel-source.

The next step is to upload this to OBS.
"

osc rdelete -m x $OBS_PRJ kernel-source
osc rdelete -m x $OBS_PRJ kernel-$KERNEL_FLAVOR

osc meta pkg $OBS_PRJ kernel-source -F - << EOF
 <package project="$OBS_PRJ" name="kernel-source">
   <title>kernel-source</title>
   <description>
   </description>
 </package>
EOF

OSCDIR=/dev/shm/$$
mkdir $OSCDIR
(
  cd $OSCDIR
  osc co $OBS_PRJ kernel-source
  cd $OBS_PRJ/kernel-source
  cp $SRC/kernel-source/* .
  osc addremove
  osc ci -m "Add kernel sources"
)
osc linkpac -C copy $OBS_PRJ kernel-source $OBS_PRJ kernel-$KERNEL_FLAVOR

# Cleaning up
rm -rf $OSCDIR
rm -rf $SRC

echo "

Congratulations. You have now a working contrib kernel in $OBS_PRJ/kernel-$KERNEL_FLAVOR!

Have a lot of fun."
--
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]

Reply via email to