-
Notifications
You must be signed in to change notification settings - Fork 12
Linux #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Linux #92
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| multiPackage: | ||
| image: ${CONFIG_SELECT_LINUX:-kernel::linux}-image | ||
| modules: ${CONFIG_SELECT_LINUX:-kernel::linux}-modules | ||
| dtbs: ${CONFIG_SELECT_LINUX:-kernel::linux}-dtbs | ||
| kmod-dist: ${CONFIG_SELECT_LINUX:-kernel::linux}-kmod-dist | ||
| headers: ${CONFIG_SELECT_LINUX:-kernel::linux}-headers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # Convenience methods for creating a Linux kernel | ||
| # | ||
| # Here we define helper methods for building the linux kernel and everything | ||
| # around it. This means the kernel modules, any dtb's and dev targets like the | ||
| # headers or an kmod-dist for building out-of-tree kernel modules. | ||
| # | ||
| # In its simplest form the usage looks something like the following. Note, that | ||
| # the kernel is downloaded into the "linux" directory and that the | ||
| # configuration files are put into the "conf" directory. Obviously you are free | ||
| # to arrange this somehow differently. Of course you only need to implement the | ||
| # targets required by your other recipes: | ||
| # | ||
| # inherit: [linux] | ||
| # | ||
| # ... | ||
| # | ||
| # metaEnvironment: | ||
| # PKG_VERSION: 6.1.114 | ||
| # | ||
| # checkoutSCM: | ||
| # - scm: url | ||
| # url: ${KERNEL_MIRROR}/linux/kernel/v6.x/linux-${PKG_VERSION}.tar.xz | ||
| # digestSHA1: 72f98a7aa831dba4d56b6c28b1a5333b04fbae35 | ||
| # stripComponents: 1 | ||
| # dir: linux | ||
| # - scm: import | ||
| # url: src/linux | ||
| # dir: conf | ||
| # | ||
| # buildScript: | | ||
| # linuxConfig $1/linux $1/conf/linux.config | ||
| # | ||
| # multiPackage: | ||
| # "": | ||
| # buildScript: linuxBuild | ||
| # | ||
| # multiPackage: | ||
| # image: | ||
| # inherit: [linux::image] | ||
| # packageScript: linuxInstallImage $1 | ||
| # | ||
| # modules: | ||
| # inherit: [linux::modules] | ||
| # packageScript: linuxInstallModules $1 | ||
| # | ||
| # kmod-dist: | ||
| # inherit: [linux::kmod-dist] | ||
| # packageScript: linuxInstallKmodDist $1 | ||
| # | ||
| # dtbs: | ||
| # inherit: [linux::dtbs] | ||
| # buildScript: linuxBuildDtbs | ||
| # packageScript: linuxInstallDtbs $1 | ||
| # | ||
| # headers: | ||
| # inherit: [linux::headers] | ||
| # buildScript: linuxBuildHeaders | ||
| # packageScript: linuxInstallHeaders $1 | ||
| # | ||
| inherit: [cpackage, make, pkg-config] | ||
|
|
||
| depends: | ||
| - tools: | ||
| target-toolchain: host-compat-toolchain | ||
| depends: | ||
| - libs::elfutils-libelf-dev | ||
| - libs::openssl-dev | ||
| - name: kernel::kmod | ||
| use: [tools] | ||
|
|
||
| privateEnvironment: | ||
| LINUX_ARCH: "$(if-then-else,$(or,$(eq,${ARCH},i386),$(eq,${ARCH},x86_64)),x86,$(if-then-else,\ | ||
| $(or,$(eq,${ARCH},sh),$(eq,${ARCH},sh64)),sh,$(if-then-else,$(or,$(eq,${ARCH},sparc32),\ | ||
| $(eq,${ARCH},sparc64)),sparc,$ARCH)))" | ||
|
|
||
| checkoutSCM: | ||
| # Always download a script for extracting the files required to build | ||
| # external kernel modules. If the kernel itself doesn't have one, we will | ||
| # use this one. | ||
| scm: url | ||
| url: https://raw.githubusercontent.com/torvalds/linux/refs/tags/v6.11/scripts/package/install-extmod-build | ||
| digestSHA1: 47eb760cf215cb3a15752186a18715fb04d9ab95 | ||
| dir: kmod-script | ||
|
|
||
| buildVars: [LINUX_ARCH, ARCH, CROSS_COMPILE, CC] | ||
| buildTools: [m4, bison, flex, target-toolchain, host-toolchain] | ||
| buildSetup: | | ||
| # make sure we find our kmod-dist script in the package step | ||
| ln -sf $1/kmod-script . | ||
|
|
||
| # Build the initial linux config. This will be used by all other steps. | ||
| # | ||
| # $1: linux kernel source directory | ||
| # $2: defconfig (optional) | ||
| # - if this is an actual file, use it as the config | ||
| # - if this is not a file, check if a defconfig for the target arch by | ||
| # that name exists and if yes, use that one | ||
| linuxConfig() | ||
| { | ||
| DEF_CFG=${2:-$1/arch/${LINUX_ARCH}/configs/defconfig} | ||
| if [[ -f "$1/arch/${LINUX_ARCH}/configs/${DEF_CFG}" ]] ; then | ||
| DEF_CFG=$1/arch/${LINUX_ARCH}/configs/${DEF_CFG} | ||
| fi | ||
| # check if the defconfig file exists | ||
| if [[ ! -f "$DEF_CFG" ]]; then | ||
| >&2 echo "Don't know how to use '$DEF_CFG' as linux kernel config!" | ||
| false | ||
| fi | ||
| # check if the source file is newer than .config | ||
| if [[ -f .config && .config -nt $DEF_CFG ]]; then | ||
| return 0 | ||
| fi | ||
| # redo the .config file | ||
| cp -u "$DEF_CFG" .config | ||
| makeSequential -C $1 O=$PWD \ | ||
| olddefconfig | ||
| } | ||
|
|
||
| # Build the actual target linux image and all configured modules | ||
| linuxBuild() | ||
| { | ||
| makeParallel \ | ||
| CC="$CC" \ | ||
| $(basename $(make -s image_name)) modules | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| inherit: [linux] | ||
|
|
||
| buildTools: [target-toolchain] | ||
| buildVars: [CROSS_COMPILE] | ||
| buildSetup: | | ||
| # Build the device tree files. | ||
| # | ||
| # $1: device tree file(s) (optional) | ||
| # - if this isn't provided, all default dtb's in the kernel directory | ||
| # are build | ||
| linuxBuildDtbs() | ||
| { | ||
| makeParallel ${1:-dtbs} "${@:2}" | ||
| } | ||
|
|
||
| packageSetup: | | ||
| # Install the device tree files. | ||
| # | ||
| # $1: linux kernel build directory | ||
| # $2: device tree file(s) (optional) | ||
| # - if this isn't provided, all default dtb's in the kernel directory | ||
| # are installed | ||
| linuxInstallDtbs() | ||
| { | ||
| if [[ -n "${2:-}" ]]; then | ||
| if [[ -d "$1/arch/$LINUX_ARCH/boot/dts" ]] ; then | ||
| make -C "$1" INSTALL_DTBS_PATH="$PWD" dtbs_install | ||
| fi | ||
| else | ||
| for i in "${@:2}" ; do | ||
| cp "$1/arch/${LINUX_ARCH}/boot/dts/$i" "$PWD" | ||
| done | ||
| fi | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| inherit: [linux] | ||
|
|
||
| buildSetup: | | ||
| # Build the linux kernel headers. | ||
| linuxBuildHeaders() | ||
| { | ||
| make headers_install | ||
| } | ||
|
|
||
| packageSetup: | | ||
| # Install the linux kernel headers. | ||
| # | ||
| # $1: linux kernel build directory | ||
| linuxInstallHeaders() | ||
| { | ||
| cp -a $1/usr . | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| inherit: [linux] | ||
|
|
||
| packageVars: [BASEMENT_DEBUG] | ||
| packageSetup: | | ||
| # Install the linux kernel image, the system.map and the .config used to | ||
| # build the kernel. | ||
| # | ||
| # $1: linux kernel build directory | ||
| # $2: destination image name (optional) | ||
| linuxInstallImage() | ||
| { | ||
| src_img_name=$(make -s -C "$1" image_name) | ||
| dst_img_name=${2:-$(basename $src_img_name)} | ||
| cp "$1/$src_img_name" "${dst_img_name}" | ||
| cp "$1/System.map" "${dst_img_name}-System.map" | ||
| cp "$1/.config" "${dst_img_name}-config" | ||
|
|
||
| if [[ ${BASEMENT_DEBUG:-0} != "0" ]] ; then | ||
| mkdir -p .debug | ||
| cp "$1/$src_img_name" ".debug/${dst_img_name}" | ||
| fi | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| inherit: [linux] | ||
|
|
||
| packageSetup: | | ||
| _SCRIPT_DIR=$1/kmod-script | ||
|
|
||
| # Install the linux kernel modules distribution for building out-of-tree | ||
| # kernel modules. | ||
| # | ||
| # $1: linux kernel build directory | ||
| linuxInstallKmodDist() | ||
| { | ||
| OUT=$PWD | ||
| # If the kernel itself provides a script for extracting the files required to | ||
| # build external kernel modules, use that, otherwise use the downloaded fixed | ||
| # version. | ||
| # Default is kernel built-in script: | ||
| SCRIPT=$1/source/scripts/package/install-extmod-build | ||
| if [[ ! -e $SCRIPT ]]; then | ||
| SCRIPT=$_SCRIPT_DIR/install-extmod-build | ||
| fi | ||
| pushd $1 | ||
| MAKE=make HOSTCC=gcc SRCARCH=$LINUX_ARCH srctree=$1/source KCONFIG_CONFIG=$1/.config \ | ||
| sh "$SCRIPT" "$OUT" | ||
| popd | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| inherit: [linux] | ||
|
|
||
| depends: | ||
| - tools: | ||
| target-toolchain: host-compat-toolchain | ||
| depends: | ||
| - libs::ncurses-dev | ||
|
|
||
| buildSetup: | | ||
| # Calls the linux savedefconfig target | ||
| # | ||
| # Especially in the sandbox this can be tricky. Provide some convenience method. | ||
| linuxSavedefconfig() | ||
| { | ||
| makeParallel savedefconfig | ||
| } | ||
|
|
||
| # Calls the linux menuconfig target | ||
| # | ||
| # Especially in the sandbox this can be tricky. Provide some convenience method. | ||
| linuxMenuconfig() | ||
| { | ||
| NCDEP=${BOB_DEP_PATHS[libs::ncurses-dev]} | ||
| makeParallel \ | ||
| HOSTCC="gcc" \ | ||
| HOSTCFLAGS="-I${NCDEP}/usr/include -DCURSES_LOC=\"<ncurses.h>\" -DLOCALE" \ | ||
| HOSTLDLIBS="-L$(gcc --print-sysroot)/usr/lib -L${NCDEP}/usr/lib -lncurses -ltinfo" \ | ||
| menuconfig | ||
| # Always save a defconfig | ||
| linuxSavedefconfig | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| inherit: [linux] | ||
|
|
||
| packageToolsWeak: [kmod] | ||
| packageVars: [BASEMENT_DEBUG, OBJCOPY] | ||
| packageSetup: | | ||
| # Install the built-in linux kernel modules. | ||
| # | ||
| # $1: linux kernel build directory | ||
| linuxInstallModules() | ||
| { | ||
| make -C "$1" \ | ||
| INSTALL_MOD_PATH="$PWD" modules_install | ||
| rm lib/modules/*/build | ||
|
|
||
| # Strip all modules. Shamelessly ripped from builddeb... | ||
| for module in $(find lib/modules/ -name *.ko -printf '%P\n'); do | ||
| module=lib/modules/$module | ||
| mkdir -p $(dirname lib/debug/$module) | ||
| # only keep debug symbols in the debug file | ||
| if [[ ${BASEMENT_DEBUG:-0} != "0" ]] ; then | ||
| $OBJCOPY --only-keep-debug $module lib/debug/$module | ||
| fi | ||
| # strip original module from debug symbols | ||
| $OBJCOPY --strip-debug $module | ||
| # then add a link to those | ||
| if [[ ${BASEMENT_DEBUG:-0} != "0" ]] ; then | ||
| $OBJCOPY --add-gnu-debuglink=lib/debug/$module $module | ||
| fi | ||
| done | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.