Skip to content

Commit

Permalink
sw: Create a dist directory for packaging
Browse files Browse the repository at this point in the history
* Create the dir in outdir of the kernel source tree
  and copy required contents (kernel_image/modules).

Issue: [1]

[1]: #25

Signed-off-by: Saalim Quadri <[email protected]>
  • Loading branch information
danascape committed Oct 25, 2023
1 parent a87aa26 commit ef75464
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,20 @@ kernel_build()
fi

if [[ -n "$create_dist" ]]; then
log_info "sworkflow: Creating dist directory"
mkdir -p out/dist
dist_path="out/dist"
if [[ -f $dist_path ]]; then
log_info "sworkflow: Copying the contents into dist"
if [[ -n "$kernel_image_name" ]]; then
log_info "sworkflow: Checking kernel image!"
if ! is_kernel_image_present "$device_arch" "$kernel_image_name"; then
log_error "error: Build failed"
else
log_info "sworkflow: Creating dist directory"
mkdir -p out/dist
dist_path="out/dist"
log_info "sworkflow: Copying the contents into dist"
kernel_image_path="out/arch/$device_arch/boot/$kernel_image_name"
cp "$kernel_image_path" $dist_path
fi
else
log_error "error: Define $kernel_image_name to create dist"
fi
fi

Expand Down
15 changes: 15 additions & 0 deletions src/sw_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ is_kernel_root()
return 1
}

# Checks if out directory contains the kernel image
#
# Returns:
# True if given kernel image is present and false otherwise
is_kernel_image_present()
{
local -r DEVICE_ARCH="$1"
local -r OBJ="$2"

if [[ -f "out/arch/${DEVICE_ARCH}/boot/${OBJ}" ]]; then
return 0
fi
return 1
}

log_error()
{
echo "${COLOR_RED}${*}"
Expand Down

0 comments on commit ef75464

Please sign in to comment.