Compare commits
9 Commits
d22e0ead04
...
dc3ccef3fd
| Author | SHA1 | Date | |
|---|---|---|---|
| dc3ccef3fd | |||
| 5ae94d72b4 | |||
| b245bffbc8 | |||
| 98c17f4ad7 | |||
| a75505f467 | |||
| cabd3aca8b | |||
| 75303a619e | |||
| 60c73cac78 | |||
| 3c8b230cc3 |
@@ -2,7 +2,7 @@
|
||||
# Builds and deploys OpenWRT images
|
||||
# Copyright 2022-24 Bryan C. Roessler
|
||||
# Apache 2.0 License
|
||||
# See README.md and ./profiles
|
||||
# See README.md and ./profiles for device configuration
|
||||
|
||||
# Set default release
|
||||
: "${RELEASE:="23.05.5"}"
|
||||
@@ -81,15 +81,15 @@ init() {
|
||||
raspbian) ID="debian" ;;
|
||||
*)
|
||||
echo "Autodetecting distro, this may be unreliable"
|
||||
if hash dnf &>/dev/null; then
|
||||
if command -v dnf &>/dev/null; then
|
||||
ID="fedora"
|
||||
RPM_MGR="dnf"
|
||||
elif hash yum &>/dev/null; then
|
||||
elif command -v yum &>/dev/null; then
|
||||
ID="centos"
|
||||
RPM_MGR="yum"
|
||||
elif hash apt &>/dev/null; then
|
||||
elif command -v apt &>/dev/null; then
|
||||
ID="ubuntu"
|
||||
elif hash pacman &>/dev/null; then
|
||||
elif command -v pacman &>/dev/null; then
|
||||
ID="arch"
|
||||
else
|
||||
return 1
|
||||
@@ -101,8 +101,8 @@ init() {
|
||||
|
||||
# Set distro-specific functions
|
||||
case "$ID" in
|
||||
fedora|centos) pkg_install(){ sudo "$RPM_MGR" install -y "$@"; } ;;
|
||||
debian|ubuntu) pkg_install(){ sudo apt-get install -y -q0 "$@"; } ;;
|
||||
fedora|centos) pkg_install(){ sudo "$RPM_MGR" install --skip-unavailable -y "$@"; } ;;
|
||||
debian|ubuntu) pkg_install(){ sudo apt-get install --ignore-missing -y -q0 "$@"; } ;;
|
||||
suse) pkg_install(){ sudo zypper --non-interactive -q install --force --no-confirm "$@"; } ;;
|
||||
arch) pkg_install(){ sudo pacman -S --noconfirm --needed "$@"; } ;;
|
||||
esac
|
||||
@@ -182,8 +182,8 @@ install_dependencies() {
|
||||
"wget"
|
||||
"which"
|
||||
"diffutils"
|
||||
"python2"
|
||||
"python3"
|
||||
"python3-devel"
|
||||
"python3-setuptools"
|
||||
"python3-pyelftools"
|
||||
"perl-base"
|
||||
@@ -316,7 +316,6 @@ install_dependencies() {
|
||||
|
||||
get_imagebuilder() {
|
||||
debug "${FUNCNAME[0]}" "$*"
|
||||
|
||||
local -a url_file_pairs=("$@")
|
||||
|
||||
for ((i=0; i<${#url_file_pairs[@]}; i+=2)); do
|
||||
@@ -381,13 +380,13 @@ make_images() {
|
||||
debug "${FUNCNAME[0]}"
|
||||
|
||||
# Reuse the existing output
|
||||
if [[ -d "$BINDIR" ]]; then
|
||||
if ask_ok "$BINDIR exists. Rebuild?"; then
|
||||
execute rm -rf "$BINDIR"
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
# if [[ -d "$BINDIR" ]]; then
|
||||
# if ask_ok "$BINDIR exists. Rebuild?"; then
|
||||
# execute rm -rf "$BINDIR"
|
||||
# else
|
||||
# return 0
|
||||
# fi
|
||||
# fi
|
||||
|
||||
debug make image BIN_DIR="$BINDIR" \
|
||||
PROFILE="$DEVICE" PACKAGES="$PACKAGES" \
|
||||
@@ -426,7 +425,7 @@ flash_images() {
|
||||
|
||||
if execute sudo dd if="$img" of="$dev" bs=2M conv=fsync; then
|
||||
sync
|
||||
echo "Image flashed sucessfully!"
|
||||
echo "Image flashed successfully!"
|
||||
else
|
||||
echo "dd failed!"
|
||||
return 1
|
||||
@@ -474,9 +473,7 @@ from_source() {
|
||||
|
||||
# Generate commitish for git worktree
|
||||
case "$RELEASE" in
|
||||
snapshot)
|
||||
wt_commit="origin/main"
|
||||
;;
|
||||
snapshot) wt_commit="origin/main" ;;
|
||||
[0-9][0-9].[0-9][0-9].*)
|
||||
local branch="openwrt-${RELEASE%.*}"
|
||||
local tag="v$RELEASE"
|
||||
@@ -493,16 +490,16 @@ from_source() {
|
||||
esac
|
||||
|
||||
# TODO There's a bug in the make clean functions that seem to invoke a full make
|
||||
# if [[ -d "$GITWORKTREEDIR" ]]; then
|
||||
# execute git -C "$GITWORKTREEDIR" checkout "$wt_commit"
|
||||
# execute git -C "$GITWORKTREEDIR" pull
|
||||
# else
|
||||
# execute git -C "$GITSRCDIR" worktree add --force --detach "$GITWORKTREEDIR" "$wt_commit"
|
||||
# fi
|
||||
if [[ -d "$GITWORKTREEDIR" ]]; then
|
||||
execute git -C "$GITWORKTREEDIR" checkout "$wt_commit"
|
||||
execute git -C "$GITWORKTREEDIR" pull
|
||||
else
|
||||
execute git -C "$GITSRCDIR" worktree add --force --detach "$GITWORKTREEDIR" "$wt_commit"
|
||||
fi
|
||||
|
||||
# To workaround bug, don't use make *clean, blow it away and start fresh
|
||||
[[ -d "$GITWORKTREEDIR" ]] && execute rm -rf "$GITWORKTREEDIR"
|
||||
execute git -C "$GITSRCDIR" worktree add --force --detach "$GITWORKTREEDIR" "$wt_commit"
|
||||
# [[ -d "$GITWORKTREEDIR" ]] && execute rm -rf "$GITWORKTREEDIR"
|
||||
# execute git -C "$GITSRCDIR" worktree add --force --detach "$GITWORKTREEDIR" "$wt_commit"
|
||||
|
||||
# Print commit information
|
||||
commit=$(git -C "$GITWORKTREEDIR" rev-parse HEAD)
|
||||
@@ -510,13 +507,7 @@ from_source() {
|
||||
echo "Current commit hash: $commit"
|
||||
echo "Git worktree description: $description"
|
||||
|
||||
if ((DEBUG)); then
|
||||
if ((YES)); then
|
||||
git --no-pager -C "$GITWORKTREEDIR" log -1
|
||||
else
|
||||
git -C "$GITWORKTREEDIR" log -1
|
||||
fi
|
||||
fi
|
||||
((DEBUG)) && git --no-pager -C "$GITWORKTREEDIR" log -1
|
||||
|
||||
# Enter worktree
|
||||
execute pushd "$GITWORKTREEDIR" || return 1
|
||||
@@ -584,12 +575,13 @@ from_source() {
|
||||
|
||||
# Make prep
|
||||
((DEBUG)) && make_opts+=("V=s")
|
||||
#execute make "${make_opts[@]}" "-j1" dirclean # TODO 'dirclean' has a bug that triggers menuconfig
|
||||
execute make "${make_opts[@]}" "-j1" distclean # TODO 'dirclean' has a bug that triggers menuconfig
|
||||
execute make "${make_opts[@]}" "-j1" defconfig
|
||||
execute make "${make_opts[@]}" "-j1" download
|
||||
((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)+1))")
|
||||
|
||||
# Make image
|
||||
if ! execute ionice -c 3 chrt --idle 0 nice -n19 make "${make_opts[@]}" "-j$(($(nproc)+1))" world; then
|
||||
if ! execute ionice -c 3 chrt --idle 0 nice -n19 make "${make_opts[@]}" world; then
|
||||
echo "Error: make failed"
|
||||
return 1
|
||||
fi
|
||||
@@ -630,7 +622,7 @@ verify() {
|
||||
local sumfile="$2"
|
||||
local checksum
|
||||
|
||||
hash sha256sum &>/dev/null || return 1
|
||||
command -v sha256sum &>/dev/null || return 1
|
||||
[[ -f $sumfile && -f $file_to_check ]] || return 1
|
||||
checksum=$(grep "${file_to_check##*/}" "$sumfile" | cut -f1 -d' ')
|
||||
echo -n "$checksum $file_to_check" | sha256sum --check --status
|
||||
@@ -782,4 +774,4 @@ main() {
|
||||
}
|
||||
|
||||
main "$@"
|
||||
exit $?
|
||||
exit
|
||||
|
||||
5
profiles
5
profiles
@@ -46,12 +46,13 @@ r4s['packages']="\
|
||||
curl \
|
||||
ethtool \
|
||||
ca-bundle"
|
||||
# The following are source mode only
|
||||
# The following only work in --source mode
|
||||
r4s['config']="\
|
||||
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y \
|
||||
CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||
CONFIG_TARGET_ROOTFS_PARTSIZE=512 \
|
||||
CONFIG_TARGET_KERNEL_PARTSIZE=32"
|
||||
CONFIG_TARGET_KERNEL_PARTSIZE=32 \
|
||||
CONFIG_BUILDBOT=n"
|
||||
r4s['files']="\
|
||||
/mnt/backup"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user