Skip to contentSkip to conversation

Xenomai patch packaging concerns

Xenomai-core Applied Romain Lenglet 2 participants 6 messages Feb 23, 2006 – Feb 27, 2006 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

I understand that the prepare-kernel.sh script is a kind of "smart patch" program. It is very nice, but for packaging for Debian we need a real diff file. So I am currently modifying prepare-kernel.sh to be even smarter, so that it can optionally generate a diff file instead of actually modifying the Linux tree. This is done efficiently in terms of disk space, i.e. it does not duplicate the Linux tree to generate the diff file. I will send a patch for prepare-kernel.sh once I have finished.

However, I have a problem: some files are copied (linked) several times into the Linux tree. As a consequence, in a generated diff file those files would be duplicated. And I believe that such a duplication is unecessary.

Here are the sets of links that are currently made by prepare-kernel.sh (on every line: Linux tree -> Xeno tree):

1- arch/<arch>/xenomai/* -> ksrc/arch/<arch>/*
2- kernel/xenomai/* -> ksrc/*
3- kernel/xenomai/arch/* -> ksrc/arch/<arch>/*
4- kernel/xenomai/drivers/*... -> ksrc/drivers/*... 5- kernel/xenomai/nucleus/*... -> ksrc/nucleus/*... 6- kernel/xenomai/skins/*... -> ksrc/skins/*... 7- drivers/xenomai/*... -> ksrc/drivers/*...
8- include/asm-<arch>/xenomai/* -> include/asm-<arch>/* 9- include/asm-generic/xenomai/* -> include/asm-generic/* 10- include/xenomai/* -> include/*
11- include/xenomai/asm-<arch>/* -> include/asm-<arch>/* 12- include/xenomai/asm-generic/* -> include/asm-generic/*
...

1- and 3- are redundant: I guess that 3- is not required? 4- and 7- are redundant: I guess that 4- is not required? 8- and 11- are redundant: I guess that 11- is not required? 9- and 12- are redundant: I guess that 12- is not required? I everybody agrees, I will modify prepare-kernel.sh to not generate the 3-, 4-, 11- and 12- sets of links.

Note that removing the 3- and 4- sets of links would also require to modify the ksrc/Makefile file, so that the line:
obj-$(CONFIG_XENOMAI) += arch/ nucleus/ skins/
becomes:
obj-$(CONFIG_XENOMAI) += nucleus/ skins/
and the following line should be suppressed:
subdir-$(CONFIG_XENOMAI) += arch
Is that OK?

It would even be better and easier to modify the Xenomai source tree to match better the Linux tree:
ksrc/
L arch
L drivers
L kernel
L nucleus
L skins

And I also will make prepare-kernel.sh not link (or generate diff) for the asm-<arch> and arch/<arch>/ directories for architectures that are different from the built architecture.

Signature · 1 line
Romain LENGLET
#1 lore raw
Quoted 32 lines · Romain Lenglet

Hi,

I understand that the prepare-kernel.sh script is a kind of "smart patch" program. It is very nice, but for packaging for Debian we need a real diff file. So I am currently modifying prepare-kernel.sh to be even smarter, so that it can optionally generate a diff file instead of actually modifying the Linux tree. This is done efficiently in terms of disk space, i.e. it does not duplicate the Linux tree to generate the diff file.
I will send a patch for prepare-kernel.sh once I have finished.

However, I have a problem: some files are copied (linked) several times into the Linux tree. As a consequence, in a generated diff file those files would be duplicated. And I believe that such a duplication is unecessary.

Here are the sets of links that are currently made by prepare-kernel.sh (on every line: Linux tree -> Xeno tree):

1- arch/<arch>/xenomai/* -> ksrc/arch/<arch>/*
2- kernel/xenomai/* -> ksrc/*
3- kernel/xenomai/arch/* -> ksrc/arch/<arch>/*
4- kernel/xenomai/drivers/*... -> ksrc/drivers/*... 5- kernel/xenomai/nucleus/*... -> ksrc/nucleus/*... 6- kernel/xenomai/skins/*... -> ksrc/skins/*... 7- drivers/xenomai/*... -> ksrc/drivers/*...
8- include/asm-<arch>/xenomai/* -> include/asm-<arch>/* 9- include/asm-generic/xenomai/* -> include/asm-generic/* 10- include/xenomai/* -> include/*
11- include/xenomai/asm-<arch>/* -> include/asm-<arch>/* 12- include/xenomai/asm-generic/* -> include/asm-generic/*
...

1- and 3- are redundant: I guess that 3- is not required?
4- and 7- are redundant: I guess that 4- is not required?
8- and 11- are redundant: I guess that 11- is not required?
9- and 12- are redundant: I guess that 12- is not required?
I everybody agrees, I will modify prepare-kernel.sh to not generate the 3-, 4-, 11- and 12- sets of links.

Quoted 8 lines

Note that removing the 3- and 4- sets of links would also require to modify the ksrc/Makefile file, so that the line:
obj-$(CONFIG_XENOMAI) += arch/ nucleus/ skins/
becomes:
obj-$(CONFIG_XENOMAI) += nucleus/ skins/
and the following line should be suppressed:
subdir-$(CONFIG_XENOMAI) += arch
Is that OK?

Entering arch/ from the kernel section is needed to compile the generic HAL part; this is why 3- is currently needed. How would this fit into your new layout? Filtering out the rest looks ok though.

Quoted 8 lines

It would even be better and easier to modify the Xenomai source tree to match better the Linux tree:
ksrc/
L arch
L drivers
L kernel
L nucleus
L skins

We could do that for later versions, but the generic HAL issue needs to be addressed first.

Quoted 2 lines

And I also will make prepare-kernel.sh not link (or generate diff) for the asm-<arch> and arch/<arch>/ directories for architectures that are different from the built architecture.

Signature · 1 line
Philippe.
#2 lore raw

Hi Philippe,

I figured out where to link/copy every file. There was no need to modify any file in ksrc/...

Here is my patch. The new option to prepare-kernel.sh is:
--outpatch=<patchfiletocreate> <tempdir>

For instance you can run:

Quoted 2 lines

mkdir /tmp/temptree
./scripts/prepare-kernel.sh

--outpatch=/tmp/patch.diff /tmp/temptree

I tested that at least I get the same result as before without using the new option.
I have only tested with the Linux 2.6.15 source tree, not with Linux 2.4. But as you can see, my modifications are simple and conservative, so it should work.

Regards,

Signature · 1 line
Romain LENGLET
ChangeLog +7 -0
@@ -1,3 +1,10 @@
+2006-02-24  Romain Lenglet <[email protected]>
+
+	* scripts/prepare-kernel.sh: Added option to generate a diff file
+	instead of actually modifying the Linux source tree. Cleanup to not
+	link / copy files for other architectures than the built architecture,
+	and to not link / copy some files twice.
+
 2006-02-22  Gilles Chanteperdrix  <[email protected]>
 
 	* include/nucleus/timer.h: Use binary heaps for the aperiodic
CREDITS +1 -1
@@ -80,7 +80,7 @@
 
 N: Romain Lenglet
 E: <[email protected]>
-D: Man pages.
+D: Man pages, and patch generation script changes.
 
 N: Heikki Lindholm
 E: [email protected]
scripts/prepare-kernel.sh +155 -45

324 lines not on this page · raw message

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 8 lines · Gilles Chanteperdrix

Review

Quoted 6 lines · Romain Lenglet
(quoted diff) +6 -0
+        while read f; do
+            f=`echo $f | cut -d/ -f2-`
+            d=`dirname $f`
+            if test "x$output_patch" = "x"; then
+                mkdir -p $linux_tree/$link_dir/$d && \
+                    rm -f $linux_tree/$link_dir/$f && \
Quoted 4 lines

Could you remove this rm ? It causes Xenomai to be rebuilt everytime the prepare-kernel is run. And when using configure option --enable-linux-build, prepare-kernel is run for every build.

OK, here is a corrected patch.

Signature · 1 line
Romain LENGLET
ChangeLog +9 -0
@@ -1,3 +1,12 @@
+2006-02-25  Romain Lenglet <[email protected]>
+
+	* scripts/prepare-kernel.sh: Added option to generate a diff file
+	instead of actually modifying the Linux source tree. Cleanup to not
+	link / copy files for other architectures than the built architecture,
+	and to not link / copy some files twice. Links to Xenomai files in the
+	Linux tree are no more created by default if they already exists. Added
+	--forcelink option to force the creation of links.
+
 2006-02-24  Philippe Gerum  <[email protected]>
 
 	* ksrc/nucleus/pod.c: Make sure that
CREDITS +1 -1
@@ -80,7 +80,7 @@
 
 N: Romain Lenglet
 E: <[email protected]>
-D: Man pages.
+D: Man pages, and patch generation script changes.
 
 N: Heikki Lindholm
 E: [email protected]
scripts/prepare-kernel.sh +171 -45

341 lines not on this page · raw message

#5 lore raw
Quoted 10 lines · Romain Lenglet
Quoted 8 lines · Gilles Chanteperdrix
Quoted 6 lines · Romain Lenglet
scripts/prepare-kernel.sh +6 -0
+        while read f; do
+            f=`echo $f | cut -d/ -f2-`
+            d=`dirname $f`
+            if test "x$output_patch" = "x"; then
+                mkdir -p $linux_tree/$link_dir/$d && \
+                    rm -f $linux_tree/$link_dir/$f && \
Quoted 8 lines
Quoted 4 lines

Could you remove this rm ? It causes Xenomai to be rebuilt everytime the prepare-kernel is run. And when using configure option --enable-linux-build, prepare-kernel is run for every build.

OK, here is a corrected patch.

Applied, thanks.

Quoted 396 lines

------------------------------------------------------------------------

ChangeLog +9 -0
@@ -1,3 +1,12 @@
+2006-02-25  Romain Lenglet <[email protected]>
+
+	* scripts/prepare-kernel.sh: Added option to generate a diff file
+	instead of actually modifying the Linux source tree. Cleanup to not
+	link / copy files for other architectures than the built architecture,
+	and to not link / copy some files twice. Links to Xenomai files in the
+	Linux tree are no more created by default if they already exists. Added
+	--forcelink option to force the creation of links.
+
 2006-02-24  Philippe Gerum  <[email protected]>
 
 	* ksrc/nucleus/pod.c: Make sure that
CREDITS +1 -1
@@ -80,7 +80,7 @@
 
 N: Romain Lenglet
 E: <[email protected]>
-D: Man pages.
+D: Man pages, and patch generation script changes.
 
 N: Heikki Lindholm
 E: [email protected]
scripts/prepare-kernel.sh +171 -46
@@ -1,38 +1,122 @@
 #! /bin/bash
 set -e
 
-do_links() {
-    ( if test -x $2; then
-      cd $2 &&
-      find . \( -name Makefile -o -name $config_file -o -name '*.[chS]' \) |
-      while read f; do
-        if test ! -e $1/$f; then rm -f $f; fi
-      done; else true; fi &&
-      cd $1 &&
-      find . \( -name Makefile -o -name $config_file -o -name '*.[chS]' \) |
-      while read f; do
-        f=`echo $f | cut -d/ -f2-`
-        d=`dirname $f`
-	mkdir -p $2/$d && ln -sf $1/$f $2/$f
-      done )
+patch_copytempfile() {
+    file="$1"
+    if ! test -f "$temp_tree/$file"; then
+        subdir=`dirname "$file"`
+        mkdir -p "$temp_tree/$subdir"
+        cp "$linux_tree/$file" "$temp_tree/$file"
+    fi
 }
 
-usage='usage: prepare-kernel --linux=<linux-tree> --adeos=<adeos-patch> [--arch=<arch>]'
+patch_append() {
+    file="$1"
+    if test "x$output_patch" = "x"; then
+        realfile="$linux_tree/$file"
+    else
+        patch_copytempfile "$file"
+        realfile="$temp_tree/$file"
+    fi
+    cat >> "$realfile"
+}
+
+patch_ed() {
+    file="$1"
+    if test "x$output_patch" = "x"; then
+        realfile="$linux_tree/$file"
+    else
+        patch_copytempfile "$file"
+        realfile="$temp_tree/$file"
+    fi
+    ed -s "$realfile" > /dev/null
+}
+
+patch_link() {
+    recursive="$1"              # "r" or "n"
+    link_makefiles="$2"         # "m" or "n"
+    target_dir="$3"
+    link_dir="$4"
+
+    (
+        recursive_opt=""
+        directorytype_opt=""
+        if test x$recursive = xr; then
+            directorytype_opt="\( -type d -mindepth 1 \) -o"
+        else
+            recursive_opt="-maxdepth 1"
+        fi
+        link_makefiles_opt=""
+        if test x$link_makefiles = xm; then
+            link_makefiles_opt="-name Makefile -o"
+        fi
+
+        if test "x$output_patch" = "x"; then
+            cd $linux_tree/$link_dir &&
+	    find . $recursive_opt \( $directorytype_opt \
+                $link_makefiles_opt -name $config_file -o -name '*.[chS]' \) |
+            while read f; do
+                if test ! -e $xenomai_root/$target_dir/$f; then rm -Rf $f; fi
+            done; else true; fi &&
+        fi
+
+        cd $xenomai_root/$target_dir &&
+        find . $recursive_opt \
+            \( $link_makefiles_opt -name $config_file -o -name '*.[chS]' \) |
+        while read f; do
+            f=`echo $f | cut -d/ -f2-`
+            d=`dirname $f`
+            if test "x$output_patch" = "x"; then
+                mkdir -p $linux_tree/$link_dir/$d
+                if test x$forcelink = x1 -o ! -h $linux_tree/$link_dir/$f; then
+                    ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f
+                fi
+            else
+                mkdir -p $temp_tree/$link_dir/$d
+                cp $xenomai_root/$target_dir/$f $temp_tree/$link_dir/$f
+            fi
+        done
+    )
+
+}
+
+generate_patch() {
+    (
+    cd "$temp_tree"
+    find . -type f |
+    while read f; do
+        diff -Naurd "$linux_tree/$f" "$f" |
+        sed -e "s,^--- ${linux_tree}/\.\(/.*\)$,--- linux\1," \
+            -e "s,^+++ \.\(/.*\)$,+++ linux-patched\1,"
+    done
+    )
+}
+
+
+usage='usage: prepare-kernel --linux=<linux-tree> --adeos=<adeos-patch> [--arch=<arch>] [--outpatch=<file> <tempdir>] [--forcelink]'
 me=`basename $0`
 
 while test $# -gt 0; do
     case "$1" in
     --linux=*)
-	linux_tree=`echo $1|sed -e 's,--linux=\\(.*\\)$,\\1,g'`;
+	linux_tree=`echo $1|sed -e 's,^--linux=\\(.*\\)$,\\1,g'`
 	linux_tree=`eval "echo $linux_tree"`
 	;;
     --adeos=*)
-	adeos_patch=`echo $1|sed -e 's,--adeos=\\(.*\\)$,\\1,g'`;
+	adeos_patch=`echo $1|sed -e 's,^--adeos=\\(.*\\)$,\\1,g'`
 	adeos_patch=`eval "echo $adeos_patch"`
 	;;
     --arch=*)
-	linux_arch=`echo $1|sed -e 's,--arch=\\(.*\\)$,\\1,g'`;
+	linux_arch=`echo $1|sed -e 's,^--arch=\\(.*\\)$,\\1,g'`
+	;;
+    --outpatch=*)
+	output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
+	shift
+	temp_tree=`echo $1|sed -e 's,^--tempdir=\\(.*\\)$,\\1,g'`
 	;;
+    --forcelink)
+        forcelink=1
+        ;;
     --verbose)
 	verbose=1
 	;;
@@ -41,8 +125,8 @@
 	exit 0
 	;;
     *)
-	echo "$me: unknown flag: $1"
-	echo "$usage"
+	echo "$me: unknown flag: $1" >&2
+	echo "$usage" >&2
 	exit 1
 	;;
     esac
@@ -82,6 +166,22 @@
    exit 2
 fi
 
+# Create an empty output patch file, and initialize the temporary tree.
+if test "x$output_patch" != "x"; then
+
+    if test ! -d $temp_tree; then
+        echo "$me: $temp_tree (temporary tree) is not an existing directory"
+        exit 2
+    fi
+    temp_tree=`cd $temp_tree && pwd`
+
+    patchdir=`dirname $output_patch`
+    patchdir=`cd $patchdir && pwd`
+    output_patch=$patchdir/`basename $output_patch`
+    echo > "$output_patch"
+
+fi
+
 # Infer the default architecture if unspecified.
 
 if test x$linux_arch = x; then
@@ -159,13 +259,17 @@
 
 linux_version="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL$linux_EXTRAVERSION"
 
+if test x$verbose = x1; then
 echo "Preparing kernel $linux_version in $linux_tree..."
+fi
 
 if test -r $linux_tree/include/linux/ipipe.h; then
+    if test x$verbose = x1; then
     echo "Adeos found - bypassing patch."
+    fi
 elif test -r $linux_tree/include/linux/adeos.h; then
-   echo "$me: Deprecated Adeos (oldgen) support found in $linux_tree;"
-   echo "Upgrade required to Adeos/I-pipe (newgen)."
+   echo "$me: Deprecated Adeos (oldgen) support found in $linux_tree;" >&2
+   echo "Upgrade required to Adeos/I-pipe (newgen)." >&2
    exit 2
 else
    if test x$adeos_patch = x; then
@@ -191,7 +295,7 @@
    curdir=$PWD
    cd $linux_tree && patch --dry-run -p1 -f < $adeos_patch || { 
         cd $curdir;
-        echo "$me: Unable to patch kernel $linux_version with `basename $adeos_patch`."
+        echo "$me: Unable to patch kernel $linux_version with `basename $adeos_patch`." >&2
         exit 2;
    }
    patch -p1 -f -s < $adeos_patch
@@ -201,9 +305,11 @@
 adeos_version=`grep '^#define.*IPIPE_ARCH_STRING.*"' $linux_tree/include/asm-$linux_arch/ipipe.h|sed -e 's,.*"\(.*\)"$,\1,'`
 
 if test \! x$adeos_version = x; then
+   if test x$verbose = x1; then
    echo "Adeos/$linux_arch $adeos_version installed."
+   fi
 else
-   echo "$me: $linux_tree has no Adeos support for $linux_arch"
+   echo "$me: $linux_tree has no Adeos support for $linux_arch" >&2
    exit 2
 fi
 
@@ -218,22 +324,23 @@
     config_file=Kconfig
 
     if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
-	sed -e "s,@LINUX_ARCH@,$linux_arch,g" $xenomai_root/scripts/Kconfig.frag >> $linux_tree/init/Kconfig
+	sed -e "s,@LINUX_ARCH@,$linux_arch,g" $xenomai_root/scripts/Kconfig.frag |
+            patch_append init/Kconfig
     fi
 
     if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then
 	p="drivers-\$(CONFIG_XENOMAI)		+= arch/$linux_arch/xenomai/"
-	( echo ; echo $p ) >> $linux_tree/arch/$linux_arch/Makefile
+	( echo ; echo $p ) | patch_append arch/$linux_arch/Makefile
     fi
 
     if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
 	p="obj-\$(CONFIG_XENOMAI)		+= xenomai/"
-	( echo ; echo $p ) >> $linux_tree/drivers/Makefile
+	( echo ; echo $p ) | patch_append drivers/Makefile
     fi
 
     if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
 	p="obj-\$(CONFIG_XENOMAI)		+= xenomai/"
-	( echo ; echo $p ) >> $linux_tree/kernel/Makefile
+	( echo ; echo $p ) | patch_append kernel/Makefile
     fi
     ;;
 
@@ -247,7 +354,7 @@
     config_file=Config.in
 
     if ! grep -q CONFIG_XENO $linux_tree/Makefile; then
-	ed -s $linux_tree/Makefile > /dev/null <<EOF
+	patch_ed Makefile <<EOF
 /DRIVERS := \$(DRIVERS-y)
 ^r $xenomai_root/scripts/Modules.frag
 
@@ -255,10 +362,10 @@
 wq
 EOF
     fi
-    for defconfig_file in .config $linux_tree/arch/$linux_arch/defconfig; do
-       if test -w $defconfig_file; then
-          if ! grep -q CONFIG_XENO $defconfig_file; then
-	      ed -s $defconfig_file > /dev/null <<EOF
+    for defconfig_file in .config arch/$linux_arch/defconfig; do
+       if test -w $linux_tree/$defconfig_file; then
+          if ! grep -q CONFIG_XENO $linux_tree/$defconfig_file; then
+	      patch_ed $defconfig_file <<EOF
 $
 r $xenomai_root/scripts/defconfig.frag
 .
@@ -268,7 +375,7 @@
        fi
     done
     if ! grep -q CONFIG_XENO $linux_tree/arch/$linux_arch/Makefile; then
-	ed -s $linux_tree/arch/$linux_arch/Makefile > /dev/null <<EOF
+	patch_ed arch/$linux_arch/Makefile <<EOF
 $
 a
 
@@ -281,7 +388,7 @@
 EOF
     fi
     if ! grep -q CONFIG_XENO $linux_tree/drivers/Makefile; then
-	ed -s $linux_tree/drivers/Makefile > /dev/null <<EOF
+	patch_ed drivers/Makefile <<EOF
 /include \$(TOPDIR)\/Rules.make
 i
 mod-subdirs := xenomai
@@ -292,7 +399,7 @@
 EOF
     fi
     if ! grep -q CONFIG_XENO $linux_tree/kernel/Makefile; then
-	ed -s $linux_tree/kernel/Makefile > /dev/null <<EOF
+	patch_ed kernel/Makefile <<EOF
 /include \$(TOPDIR)\/Rules.make
 i
 mod-subdirs := xenomai
@@ -304,7 +411,7 @@
 EOF
     fi
     if ! grep -iq xenomai $linux_tree/arch/$linux_arch/config.in; then
-	ed -s $linux_tree/arch/$linux_arch/config.in > /dev/null <<EOF
+	patch_ed arch/$linux_arch/config.in <<EOF
 $
 a
 
@@ -321,7 +428,7 @@
 
     *)
 
-    echo "$me: Unsupported kernel version $linux_VERSION.$linux_PATCHLEVEL.x"
+    echo "$me: Unsupported kernel version $linux_VERSION.$linux_PATCHLEVEL.x" >&2
     exit 2
     ;;
 
@@ -331,15 +438,34 @@
 # there, so that we don't pollute the Xenomai source tree with
 # compilation files.
 
-do_links $xenomai_root/ksrc/arch/$xenomai_arch $linux_tree/arch/$linux_arch/xenomai
-do_links $xenomai_root/ksrc $linux_tree/kernel/xenomai
-do_links $xenomai_root/ksrc/drivers $linux_tree/drivers/xenomai
-do_links $xenomai_root/include/asm-$xenomai_arch $linux_tree/include/asm-$linux_arch/xenomai
-do_links $xenomai_root/include/asm-generic $linux_tree/include/asm-generic/xenomai
-do_links $xenomai_root/include $linux_tree/include/xenomai
+patch_link r m ksrc/arch/$xenomai_arch arch/$linux_arch/xenomai
+patch_link n m ksrc/ kernel/xenomai
+patch_link n m ksrc/arch kernel/xenomai/arch
+patch_link r m ksrc/arch/generic kernel/xenomai/arch/generic
+patch_link r m ksrc/nucleus kernel/xenomai/nucleus
+patch_link r m ksrc/skins kernel/xenomai/skins
+patch_link r m ksrc/drivers drivers/xenomai
+patch_link r n include/asm-$xenomai_arch include/asm-$linux_arch/xenomai
+patch_link r n include/asm-generic include/asm-generic/xenomai
+patch_link n n include include/xenomai
+for d in include/* ; do
+    if test -d $d -a -z "`echo $d | grep '^include/asm-'`"; then
+        destdir=`echo $d | sed -e 's,^\(include\)\(/.*\)$,\1/xenomai\2,'`
+        patch_link r n $d $destdir
+    fi
+done
 
-echo 'Links installed.'
+if test "x$output_patch" != "x"; then
+    if test x$verbose = x1; then
+    echo 'Generating patch.'
+    fi
+    generate_patch > "$output_patch"
+fi
 
+if test x$verbose = x1; then
+echo 'Links installed.'
 echo 'Build system ready.'
+fi
 
 exit 0
+
 
 
------------------------------------------------------------------------

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
Philippe.
#6 lore raw
Quoted 19 lines · Philippe Gerum
Quoted 17 lines · Romain Lenglet
Quoted 12 lines · Gilles Chanteperdrix

scripts/prepare-kernel.sh

Quoted 6 lines · Romain Lenglet
scripts/prepare-kernel.sh +6 -0
+        while read f; do
+            f=`echo $f | cut -d/ -f2-`
+            d=`dirname $f`
+            if test "x$output_patch" = "x"; then
+                mkdir -p $linux_tree/$link_dir/$d && \
+                    rm -f $linux_tree/$link_dir/$f && \

Could you remove this rm ? It causes Xenomai to be rebuilt everytime the prepare-kernel is run. And when using configure option --enable-linux-build, prepare-kernel is run for every build.

Quoted 5 lines
Quoted 2 lines

OK, here is a corrected patch.

Applied, thanks.

This patch temporarily reverted; it currently breaks.

Quoted 430 lines
Quoted 427 lines

------------------------------------------------------------------------

ChangeLog 2006-02-25 14:08:09.657611040 +0900 renamed from ChangeLog 2006-02-25 13:43:31.193371768 +0900 +6 -0
@@ -1,3 +1,12 @@
+2006-02-25  Romain Lenglet <[email protected]>
+
+    * scripts/prepare-kernel.sh: Added option to generate a diff file
+    instead of actually modifying the Linux source tree. Cleanup to not
+    link / copy files for other architectures than the built 
 architecture,
+    and to not link / copy some files twice. Links to Xenomai files 

in the
+ Linux tree are no more created by default if they already exists.
Added

ChangeLog 2006-02-25 14:08:09.657611040 +0900 renamed from ChangeLog 2006-02-25 13:43:31.193371768 +0900 +2 -0
+    --forcelink option to force the creation of links.
+
 2006-02-24  Philippe Gerum  <[email protected]>
 
     * ksrc/nucleus/pod.c: Make sure that
CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +3 -2
@@ -80,7 +80,7 @@
 
 N: Romain Lenglet
 E: <[email protected]>
-D: Man pages.
+D: Man pages, and patch generation script changes.
 
 N: Heikki Lindholm
 E: [email protected]
--- xenomai/scripts/prepare-kernel.sh    2006-02-24 19:48:17.038186464 
+0900
+++ xenomai-new2/scripts/prepare-kernel.sh    2006-02-25 

14:07:30.838512440 +0900

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +0 -4
@@ -1,38 +1,122 @@
 #! /bin/bash
 set -e
 
-do_links() {
-    ( if test -x $2; then
-      cd $2 &&
-      find . \( -name Makefile -o -name $config_file -o -name 

'*.[chS]' \) |

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +0 -5
-      while read f; do
-        if test ! -e $1/$f; then rm -f $f; fi
-      done; else true; fi &&
-      cd $1 &&
-      find . \( -name Makefile -o -name $config_file -o -name 

'*.[chS]' \) |

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +52 -7
-      while read f; do
-        f=`echo $f | cut -d/ -f2-`
-        d=`dirname $f`
-    mkdir -p $2/$d && ln -sf $1/$f $2/$f
-      done )
+patch_copytempfile() {
+    file="$1"
+    if ! test -f "$temp_tree/$file"; then
+        subdir=`dirname "$file"`
+        mkdir -p "$temp_tree/$subdir"
+        cp "$linux_tree/$file" "$temp_tree/$file"
+    fi
 }
 
-usage='usage: prepare-kernel --linux=<linux-tree> 
--adeos=<adeos-patch> [--arch=<arch>]'
+patch_append() {
+    file="$1"
+    if test "x$output_patch" = "x"; then
+        realfile="$linux_tree/$file"
+    else
+        patch_copytempfile "$file"
+        realfile="$temp_tree/$file"
+    fi
+    cat >> "$realfile"
+}
+
+patch_ed() {
+    file="$1"
+    if test "x$output_patch" = "x"; then
+        realfile="$linux_tree/$file"
+    else
+        patch_copytempfile "$file"
+        realfile="$temp_tree/$file"
+    fi
+    ed -s "$realfile" > /dev/null
+}
+
+patch_link() {
+    recursive="$1"              # "r" or "n"
+    link_makefiles="$2"         # "m" or "n"
+    target_dir="$3"
+    link_dir="$4"
+
+    (
+        recursive_opt=""
+        directorytype_opt=""
+        if test x$recursive = xr; then
+            directorytype_opt="\( -type d -mindepth 1 \) -o"
+        else
+            recursive_opt="-maxdepth 1"
+        fi
+        link_makefiles_opt=""
+        if test x$link_makefiles = xm; then
+            link_makefiles_opt="-name Makefile -o"
+        fi
+
+        if test "x$output_patch" = "x"; then
+            cd $linux_tree/$link_dir &&
+        find . $recursive_opt \( $directorytype_opt \
+                $link_makefiles_opt -name $config_file -o -name 

'*.[chS]' \) |

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +8 -1
+            while read f; do
+                if test ! -e $xenomai_root/$target_dir/$f; then rm 
-Rf $f; fi
+            done; else true; fi &&
+        fi
+
+        cd $xenomai_root/$target_dir &&
+        find . $recursive_opt \
+            \( $link_makefiles_opt -name $config_file -o -name 

'*.[chS]' \) |

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +6 -0
+        while read f; do
+            f=`echo $f | cut -d/ -f2-`
+            d=`dirname $f`
+            if test "x$output_patch" = "x"; then
+                mkdir -p $linux_tree/$link_dir/$d
+                if test x$forcelink = x1 -o ! -h 

$linux_tree/$link_dir/$f; then
+ ln -sf $xenomai_root/$target_dir/$f
$linux_tree/$link_dir/$f

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +24 -1
+                fi
+            else
+                mkdir -p $temp_tree/$link_dir/$d
+                cp $xenomai_root/$target_dir/$f $temp_tree/$link_dir/$f
+            fi
+        done
+    )
+
+}
+
+generate_patch() {
+    (
+    cd "$temp_tree"
+    find . -type f |
+    while read f; do
+        diff -Naurd "$linux_tree/$f" "$f" |
+        sed -e "s,^--- ${linux_tree}/\.\(/.*\)$,--- linux\1," \
+            -e "s,^+++ \.\(/.*\)$,+++ linux-patched\1,"
+    done
+    )
+}
+
+
+usage='usage: prepare-kernel --linux=<linux-tree> 
--adeos=<adeos-patch> [--arch=<arch>] [--outpatch=<file> <tempdir>] 

[--forcelink]'
me=basename $0

while test $# -gt 0; do

     case "$1" in
     --linux=*)
CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +18 -5
-    linux_tree=`echo $1|sed -e 's,--linux=\\(.*\\)$,\\1,g'`;
+    linux_tree=`echo $1|sed -e 's,^--linux=\\(.*\\)$,\\1,g'`
     linux_tree=`eval "echo $linux_tree"`
     ;;
     --adeos=*)
-    adeos_patch=`echo $1|sed -e 's,--adeos=\\(.*\\)$,\\1,g'`;
+    adeos_patch=`echo $1|sed -e 's,^--adeos=\\(.*\\)$,\\1,g'`
     adeos_patch=`eval "echo $adeos_patch"`
     ;;
     --arch=*)
-    linux_arch=`echo $1|sed -e 's,--arch=\\(.*\\)$,\\1,g'`;
+    linux_arch=`echo $1|sed -e 's,^--arch=\\(.*\\)$,\\1,g'`
+    ;;
+    --outpatch=*)
+    output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
+    shift
+    temp_tree=`echo $1|sed -e 's,^--tempdir=\\(.*\\)$,\\1,g'`
     ;;
+    --forcelink)
+        forcelink=1
+        ;;
     --verbose)
     verbose=1
     ;;
@@ -41,8 +125,8 @@
     exit 0
     ;;
     *)
-    echo "$me: unknown flag: $1"
-    echo "$usage"
+    echo "$me: unknown flag: $1" >&2
+    echo "$usage" >&2
     exit 1
     ;;
     esac
@@ -82,6 +166,22 @@
    exit 2
 fi
 
+# Create an empty output patch file, and initialize the temporary tree.
+if test "x$output_patch" != "x"; then
+
+    if test ! -d $temp_tree; then
+        echo "$me: $temp_tree (temporary tree) is not an existing 

directory"

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +16 -2
+        exit 2
+    fi
+    temp_tree=`cd $temp_tree && pwd`
+
+    patchdir=`dirname $output_patch`
+    patchdir=`cd $patchdir && pwd`
+    output_patch=$patchdir/`basename $output_patch`
+    echo > "$output_patch"
+
+fi
+
 # Infer the default architecture if unspecified.
 
 if test x$linux_arch = x; then
@@ -159,13 +259,17 @@
 
 linux_version="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL$linux_EXTRAVERSION" 
 
 
+if test x$verbose = x1; then
 echo "Preparing kernel $linux_version in $linux_tree..."
+fi
 
 if test -r $linux_tree/include/linux/ipipe.h; then
+    if test x$verbose = x1; then
     echo "Adeos found - bypassing patch."
+    fi
 elif test -r $linux_tree/include/linux/adeos.h; then
-   echo "$me: Deprecated Adeos (oldgen) support found in $linux_tree;"
-   echo "Upgrade required to Adeos/I-pipe (newgen)."
+   echo "$me: Deprecated Adeos (oldgen) support found in 

$linux_tree;" >&2

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +1 -1
+   echo "Upgrade required to Adeos/I-pipe (newgen)." >&2
    exit 2
 else
    if test x$adeos_patch = x; then
@@ -191,7 +295,7 @@
    curdir=$PWD
    cd $linux_tree && patch --dry-run -p1 -f < $adeos_patch || { 
         cd $curdir;
-        echo "$me: Unable to patch kernel $linux_version with 

basename $adeos_patch."
+ echo "$me: Unable to patch kernel $linux_version with
basename $adeos_patch." >&2

         exit 2;
    }
    patch -p1 -f -s < $adeos_patch
CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +0 -0
@@ -201,9 +305,11 @@
 adeos_version=`grep '^#define.*IPIPE_ARCH_STRING.*"' 

$linux_tree/include/asm-$linux_arch/ipipe.h|sed -e 's,.*"\(.*\)"$,\1,'`

if test \! x$adeos_version = x; then

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +3 -2
+   if test x$verbose = x1; then
    echo "Adeos/$linux_arch $adeos_version installed."
+   fi
 else
-   echo "$me: $linux_tree has no Adeos support for $linux_arch"
+   echo "$me: $linux_tree has no Adeos support for $linux_arch" >&2
    exit 2
 fi
@@ -218,22 +324,23 @@
     config_file=Kconfig
 
     if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
-    sed -e "s,@LINUX_ARCH@,$linux_arch,g" 

$xenomai_root/scripts/Kconfig.frag >> $linux_tree/init/Kconfig
+ sed -e "s,@LINUX_ARCH@,$linux_arch,g"
$xenomai_root/scripts/Kconfig.frag |
+ patch_append init/Kconfig
fi

if ! grep -q CONFIG_XENOMAI
$linux_tree/arch/$linux_arch/Makefile; then

     p="drivers-\$(CONFIG_XENOMAI)        += arch/$linux_arch/xenomai/"
CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +4 -5
-    ( echo ; echo $p ) >> $linux_tree/arch/$linux_arch/Makefile
+    ( echo ; echo $p ) | patch_append arch/$linux_arch/Makefile
     fi
 
     if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
     p="obj-\$(CONFIG_XENOMAI)        += xenomai/"
-    ( echo ; echo $p ) >> $linux_tree/drivers/Makefile
+    ( echo ; echo $p ) | patch_append drivers/Makefile
     fi
 
     if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
     p="obj-\$(CONFIG_XENOMAI)        += xenomai/"
-    ( echo ; echo $p ) >> $linux_tree/kernel/Makefile
+    ( echo ; echo $p ) | patch_append kernel/Makefile
     fi
     ;;
@@ -247,7 +354,7 @@
     config_file=Config.in
 
     if ! grep -q CONFIG_XENO $linux_tree/Makefile; then
-    ed -s $linux_tree/Makefile > /dev/null <<EOF
+    patch_ed Makefile <<EOF
 /DRIVERS := \$(DRIVERS-y)
 ^r $xenomai_root/scripts/Modules.frag
 
@@ -255,10 +362,10 @@
 wq
 EOF
     fi
-    for defconfig_file in .config 

$linux_tree/arch/$linux_arch/defconfig; do

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +8 -8
-       if test -w $defconfig_file; then
-          if ! grep -q CONFIG_XENO $defconfig_file; then
-          ed -s $defconfig_file > /dev/null <<EOF
+    for defconfig_file in .config arch/$linux_arch/defconfig; do
+       if test -w $linux_tree/$defconfig_file; then
+          if ! grep -q CONFIG_XENO $linux_tree/$defconfig_file; then
+          patch_ed $defconfig_file <<EOF
 $
 r $xenomai_root/scripts/defconfig.frag
 .
@@ -268,7 +375,7 @@
        fi
     done
     if ! grep -q CONFIG_XENO $linux_tree/arch/$linux_arch/Makefile; then
-    ed -s $linux_tree/arch/$linux_arch/Makefile > /dev/null <<EOF
+    patch_ed arch/$linux_arch/Makefile <<EOF
 $
 a
 
@@ -281,7 +388,7 @@
 EOF
     fi
     if ! grep -q CONFIG_XENO $linux_tree/drivers/Makefile; then
-    ed -s $linux_tree/drivers/Makefile > /dev/null <<EOF
+    patch_ed drivers/Makefile <<EOF
 /include \$(TOPDIR)\/Rules.make
 i
 mod-subdirs := xenomai
@@ -292,7 +399,7 @@
 EOF
     fi
     if ! grep -q CONFIG_XENO $linux_tree/kernel/Makefile; then
-    ed -s $linux_tree/kernel/Makefile > /dev/null <<EOF
+    patch_ed kernel/Makefile <<EOF
 /include \$(TOPDIR)\/Rules.make
 i
 mod-subdirs := xenomai
@@ -304,7 +411,7 @@
 EOF
     fi
     if ! grep -iq xenomai $linux_tree/arch/$linux_arch/config.in; then
-    ed -s $linux_tree/arch/$linux_arch/config.in > /dev/null <<EOF
+    patch_ed arch/$linux_arch/config.in <<EOF
 $
 a
 
@@ -321,7 +428,7 @@
 
     *)
 
-    echo "$me: Unsupported kernel version 

$linux_VERSION.$linux_PATCHLEVEL.x"
+ echo "$me: Unsupported kernel version
$linux_VERSION.$linux_PATCHLEVEL.x" >&2

     exit 2
     ;;
CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +0 -1
@@ -331,15 +438,34 @@
 # there, so that we don't pollute the Xenomai source tree with
 # compilation files.
 
-do_links $xenomai_root/ksrc/arch/$xenomai_arch 

$linux_tree/arch/$linux_arch/xenomai

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +0 -3
-do_links $xenomai_root/ksrc $linux_tree/kernel/xenomai
-do_links $xenomai_root/ksrc/drivers $linux_tree/drivers/xenomai
-do_links $xenomai_root/include/asm-$xenomai_arch 

$linux_tree/include/asm-$linux_arch/xenomai
-do_links $xenomai_root/include/asm-generic
$linux_tree/include/asm-generic/xenomai

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +13 -1
-do_links $xenomai_root/include $linux_tree/include/xenomai
+patch_link r m ksrc/arch/$xenomai_arch arch/$linux_arch/xenomai
+patch_link n m ksrc/ kernel/xenomai
+patch_link n m ksrc/arch kernel/xenomai/arch
+patch_link r m ksrc/arch/generic kernel/xenomai/arch/generic
+patch_link r m ksrc/nucleus kernel/xenomai/nucleus
+patch_link r m ksrc/skins kernel/xenomai/skins
+patch_link r m ksrc/drivers drivers/xenomai
+patch_link r n include/asm-$xenomai_arch include/asm-$linux_arch/xenomai
+patch_link r n include/asm-generic include/asm-generic/xenomai
+patch_link n n include include/xenomai
+for d in include/* ; do
+    if test -d $d -a -z "`echo $d | grep '^include/asm-'`"; then
+        destdir=`echo $d | sed -e 

's,^\(include\)\(/.*\)$,\1/xenomai\2,'`

CREDITS 2006-02-25 13:34:54.115979480 +0900 renamed from CREDITS 2006-02-22 10:28:53.229253976 +0900 +13 -2
+        patch_link r n $d $destdir
+    fi
+done
 
-echo 'Links installed.'
+if test "x$output_patch" != "x"; then
+    if test x$verbose = x1; then
+    echo 'Generating patch.'
+    fi
+    generate_patch > "$output_patch"
+fi
 
+if test x$verbose = x1; then
+echo 'Links installed.'
 echo 'Build system ready.'
+fi
 
 exit 0
+
 
 
------------------------------------------------------------------------

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
Philippe.