|
@@ -454,16 +454,16 @@ makeImages() {
|
|
debug "${FUNCNAME[0]}"
|
|
debug "${FUNCNAME[0]}"
|
|
|
|
|
|
# Reuse the existing output
|
|
# Reuse the existing output
|
|
- if [[ -d "$THIS_BINDIR" ]]; then
|
|
|
|
- if askOk "$THIS_BINDIR exists. Rebuild?"; then
|
|
|
|
- rm -rf "$THIS_BINDIR"
|
|
|
|
|
|
+ if [[ -d "$BINDIR" ]]; then
|
|
|
|
+ if askOk "$BINDIR exists. Rebuild?"; then
|
|
|
|
+ rm -rf "$BINDIR"
|
|
else
|
|
else
|
|
return 0
|
|
return 0
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
|
|
make image \
|
|
make image \
|
|
- BIN_DIR="$THIS_BINDIR" \
|
|
|
|
|
|
+ BIN_DIR="$BINDIR" \
|
|
PROFILE="${P_ARR[profile]}" \
|
|
PROFILE="${P_ARR[profile]}" \
|
|
PACKAGES="${P_ARR[packages]:+"${P_ARR[packages]}"}" \
|
|
PACKAGES="${P_ARR[packages]:+"${P_ARR[packages]}"}" \
|
|
FILES="${FILESDIR}" \
|
|
FILES="${FILESDIR}" \
|
|
@@ -478,7 +478,7 @@ verifyImages() {
|
|
|
|
|
|
declare outfile
|
|
declare outfile
|
|
|
|
|
|
- for outfile in "$THIS_BINDIR"/*.img.gz; do
|
|
|
|
|
|
+ for outfile in "$BINDIR"/*.img.gz; do
|
|
verify "$outfile" "$IB_OUT_SHA256_FILE" || return 1
|
|
verify "$outfile" "$IB_OUT_SHA256_FILE" || return 1
|
|
done
|
|
done
|
|
}
|
|
}
|
|
@@ -487,84 +487,33 @@ verifyImages() {
|
|
flashImage() {
|
|
flashImage() {
|
|
debug "${FUNCNAME[0]}"
|
|
debug "${FUNCNAME[0]}"
|
|
|
|
|
|
- declare img img_gz partitions
|
|
|
|
|
|
+ declare img_gz="$1"
|
|
|
|
+ declare dev="$2"
|
|
|
|
+
|
|
|
|
+ declare img="${img_gz%.gz}"
|
|
|
|
+ declare partitions
|
|
|
|
|
|
- if [[ ! -e "$FLASH_DEV" ]]; then
|
|
|
|
|
|
+ if [[ ! -e "$dev" ]]; then
|
|
echo "The device specified by --flash could not be found"
|
|
echo "The device specified by --flash could not be found"
|
|
- exit 1
|
|
|
|
|
|
+ return 1
|
|
fi
|
|
fi
|
|
|
|
|
|
- # TODO Roughly choose the correct image
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (( FROM_SOURCE )); then
|
|
|
|
- if [[ -f $SOURCEFACTORYIMGGZ &&
|
|
|
|
- -f $SOURCESYSUPGRADEIMGGZ ]]; then
|
|
|
|
- local _response
|
|
|
|
- echo "$SOURCEFACTORYIMGGZ and $SOURCESYSUPGRADEIMGGZ both exist"
|
|
|
|
- read -r -p "Flash factory or sysupgrade image? [(f)actory/(s)ysupgrade]" _response
|
|
|
|
- _response=${_response,,}
|
|
|
|
- if [[ "$_response" =~ ^(f|factory)$ ]]; then
|
|
|
|
- img_gz="$SOURCEFACTORYIMGGZ"
|
|
|
|
- img="$SOURCEFACTORYIMG"
|
|
|
|
- elif [[ "$_response" =~ ^(s|sysupgrade)$ ]]; then
|
|
|
|
- img_gz="$SOURCESYSUPGRADEIMGGZ"
|
|
|
|
- img="$SOURCESYSUPGRADEIMG"
|
|
|
|
- else
|
|
|
|
- echo "Invalid input, you must enter f or s"
|
|
|
|
- fi
|
|
|
|
- elif [[ -f $SOURCEFACTORYIMGGZ ]]; then
|
|
|
|
- img_gz="$SOURCEFACTORYIMGGZ"
|
|
|
|
- img="$SOURCEFACTORYIMG"
|
|
|
|
- elif [[ -f $SOURCESYSUPGRADEIMGGZ ]]; then
|
|
|
|
- img_gz="$SOURCESYSUPGRADEIMGGZ"
|
|
|
|
- img="$SOURCESYSUPGRADEIMG"
|
|
|
|
- else
|
|
|
|
- echo "No files found at $SOURCEFACTORYIMGGZ or $SOURCESYSUPGRADEIMGGZ"
|
|
|
|
- echo "Check your build output"
|
|
|
|
- return 1
|
|
|
|
- fi
|
|
|
|
- else
|
|
|
|
- if [[ -f $FACTORYIMGGZ &&
|
|
|
|
- -f $SYSUPGRADEIMGGZ ]]; then
|
|
|
|
- local _response
|
|
|
|
- echo "$FACTORYIMGGZ and $SYSUPGRADEIMGGZ both exist"
|
|
|
|
- read -r -p "Flash factory or sysupgrade image? [(f)actory/(s)ysupgrade]" _response
|
|
|
|
- _response=${_response,,}
|
|
|
|
- if [[ "$_response" =~ ^(f|factory)$ ]]; then
|
|
|
|
- img_gz="$FACTORYIMGGZ"
|
|
|
|
- img="$FACTORYIMG"
|
|
|
|
- elif [[ "$_response" =~ ^(s|sysupgrade)$ ]]; then
|
|
|
|
- img_gz="$SYSUPGRADEIMGGZ"
|
|
|
|
- img="$SYSUPGRADEIMG"
|
|
|
|
- else
|
|
|
|
- echo "Invalid input, you must enter f or s"
|
|
|
|
- fi
|
|
|
|
- elif [[ -f $FACTORYIMGGZ ]]; then
|
|
|
|
- img_gz="$FACTORYIMGGZ"
|
|
|
|
- img="$FACTORYIMG"
|
|
|
|
- elif [[ -f $SYSUPGRADEIMGGZ ]]; then
|
|
|
|
- img_gz="$SYSUPGRADEIMGGZ"
|
|
|
|
- img="$SYSUPGRADEIMG"
|
|
|
|
- else
|
|
|
|
- echo "No files found at $FACTORYIMGGZ or $SYSUPGRADEIMGGZ"
|
|
|
|
- echo "Check your build output"
|
|
|
|
- return 1
|
|
|
|
- fi
|
|
|
|
|
|
+ if [[ ! -f $img_gz ]]; then
|
|
|
|
+ echo "$img_gz does not exist"
|
|
|
|
+ echo "Check your build output"
|
|
|
|
+ return 1
|
|
fi
|
|
fi
|
|
|
|
|
|
- debug "$img_gz $img"
|
|
|
|
-
|
|
|
|
debug "gunzip -qfk $img_gz"
|
|
debug "gunzip -qfk $img_gz"
|
|
gunzip -qfk "$img_gz"
|
|
gunzip -qfk "$img_gz"
|
|
|
|
|
|
- echo "Unmounting target device $FLASH_DEV partitions"
|
|
|
|
- partitions=( "$FLASH_DEV"?* )
|
|
|
|
|
|
+ echo "Unmounting target device $dev partitions"
|
|
|
|
+ partitions=( "$dev"?* )
|
|
debug "umount ${partitions[*]}"
|
|
debug "umount ${partitions[*]}"
|
|
sudo umount "${partitions[@]}"
|
|
sudo umount "${partitions[@]}"
|
|
|
|
|
|
- debug "sudo dd if=$img of=$FLASH_DEV bs=2M conv=fsync"
|
|
|
|
- if sudo dd if="$img" of="$FLASH_DEV" bs=2M conv=fsync; then
|
|
|
|
|
|
+ debug "sudo dd if=$img of=$dev bs=2M conv=fsync"
|
|
|
|
+ if sudo dd if="$img" of="$dev" bs=2M conv=fsync; then
|
|
sync
|
|
sync
|
|
echo "Image flashed sucessfully!"
|
|
echo "Image flashed sucessfully!"
|
|
else
|
|
else
|
|
@@ -577,36 +526,29 @@ flashImage() {
|
|
sshUpgrade() {
|
|
sshUpgrade() {
|
|
debug "${FUNCNAME[0]}"
|
|
debug "${FUNCNAME[0]}"
|
|
|
|
|
|
- declare img_gz img_fname
|
|
|
|
|
|
+ declare img_gz="$1"
|
|
|
|
+ declare ssh_path="$2"
|
|
|
|
|
|
- if (( FROM_SOURCE )); then
|
|
|
|
- if [[ -f $SOURCESYSUPGRADEIMGGZ ]]; then
|
|
|
|
- img_gz="$SOURCESYSUPGRADEIMGGZ"
|
|
|
|
- img_fname="$SOURCESYSUPGRADEIMGGZFNAME"
|
|
|
|
- fi
|
|
|
|
- elif [[ -f $SYSUPGRADEIMGGZ ]]; then
|
|
|
|
- img_gz="$SYSUPGRADEIMGGZ"
|
|
|
|
- img_fname="$SYSUPGRADEIMGGZFNAME"
|
|
|
|
- fi
|
|
|
|
|
|
+ declare img_fname="${img_gz##*/}"
|
|
|
|
|
|
- if [[ ! -f $img_gz ]]; then
|
|
|
|
|
|
+ if ! [[ -f $img_gz ]]; then
|
|
echo "$img_gz is missing, check build output"
|
|
echo "$img_gz is missing, check build output"
|
|
return 1
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
|
|
- echo "Copying '$img_gz' to $SSH_UPGRADE_PATH/tmp/$img_fname"
|
|
|
|
- debug "scp $img_gz $SSH_UPGRADE_PATH:/tmp/$img_fname"
|
|
|
|
- if ! scp "$img_gz" "$SSH_UPGRADE_PATH":"/tmp/$img_fname"; then
|
|
|
|
- echo "Could not copy $img_gz to $SSH_UPGRADE_PATH:/tmp/$img_fname"
|
|
|
|
|
|
+ echo "Copying '$img_gz' to $ssh_path/tmp/$img_fname"
|
|
|
|
+ debug "scp $img_gz $ssh_path:/tmp/$img_fname"
|
|
|
|
+ if ! scp "$img_gz" "$ssh_path":"/tmp/$img_fname"; then
|
|
|
|
+ echo "Could not copy $img_gz to $ssh_path:/tmp/$img_fname"
|
|
return 1
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
|
|
echo "Executing remote sysupgrade"
|
|
echo "Executing remote sysupgrade"
|
|
- debug "ssh $SSH_UPGRADE_PATH sysupgrade -F /tmp/$img_fname"
|
|
|
|
|
|
+ debug "ssh $ssh_path sysupgrade -F /tmp/$img_fname"
|
|
# shellcheck disable=SC2029
|
|
# shellcheck disable=SC2029
|
|
# execute remotely
|
|
# execute remotely
|
|
# this will probably be a weird exit code from closed connection
|
|
# this will probably be a weird exit code from closed connection
|
|
- ssh "$SSH_UPGRADE_PATH" "sysupgrade -F /tmp/$img_fname"
|
|
|
|
|
|
+ ssh "$ssh_path" "sysupgrade -F /tmp/$img_fname"
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -626,12 +568,15 @@ fromSource() {
|
|
fi
|
|
fi
|
|
|
|
|
|
git -C "$GITSRCDIR" pull
|
|
git -C "$GITSRCDIR" pull
|
|
|
|
+ debug "Current commit:"
|
|
|
|
+ (( DEBUG )) && git -C "$GITSRCDIR" log -1
|
|
|
|
+ (( DEBUG )) && git -C "$GITSRCDIR" describe
|
|
|
|
|
|
commit=$(git -C "$GITSRCDIR" rev-parse HEAD)
|
|
commit=$(git -C "$GITSRCDIR" rev-parse HEAD)
|
|
- debug "commit hash: $commit"
|
|
|
|
|
|
+ debug "Current commit hash: $commit"
|
|
|
|
|
|
if [[ $RELEASE == "snapshot" ]]; then
|
|
if [[ $RELEASE == "snapshot" ]]; then
|
|
- gitworktreedir="$SRCDIR/$profile/$RELEASE"
|
|
|
|
|
|
+ gitworktreedir="$BUILDROOT/src/$profile/$RELEASE"
|
|
git -C "$GITSRCDIR" \
|
|
git -C "$GITSRCDIR" \
|
|
worktree add \
|
|
worktree add \
|
|
--force \
|
|
--force \
|
|
@@ -639,7 +584,7 @@ fromSource() {
|
|
"$gitworktreedir" \
|
|
"$gitworktreedir" \
|
|
"master"
|
|
"master"
|
|
else
|
|
else
|
|
- gitworktreedir="$SRCDIR/$profile/$RELEASE"
|
|
|
|
|
|
+ gitworktreedir="$BUILDROOT/src/$profile/$RELEASE"
|
|
git -C "$GITSRCDIR" \
|
|
git -C "$GITSRCDIR" \
|
|
worktree add \
|
|
worktree add \
|
|
--force \
|
|
--force \
|
|
@@ -649,8 +594,6 @@ fromSource() {
|
|
fi
|
|
fi
|
|
|
|
|
|
seed_file="$gitworktreedir/.config"
|
|
seed_file="$gitworktreedir/.config"
|
|
-
|
|
|
|
- debug "gitworktreedir: $gitworktreedir"
|
|
|
|
debug "seed_file: $seed_file"
|
|
debug "seed_file: $seed_file"
|
|
|
|
|
|
pushd "$gitworktreedir" &>/dev/null || return 1
|
|
pushd "$gitworktreedir" &>/dev/null || return 1
|
|
@@ -666,7 +609,7 @@ fromSource() {
|
|
fi
|
|
fi
|
|
|
|
|
|
# Set compilation output dir
|
|
# Set compilation output dir
|
|
- config_opts+=("CONFIG_BINARY_FOLDER=\"$THIS_BINDIR\"")
|
|
|
|
|
|
+ config_opts+=("CONFIG_BINARY_FOLDER=\"$BINDIR\"")
|
|
|
|
|
|
# Add custom packages
|
|
# Add custom packages
|
|
for pkg in ${P_ARR[packages]}; do
|
|
for pkg in ${P_ARR[packages]}; do
|
|
@@ -683,23 +626,23 @@ fromSource() {
|
|
done
|
|
done
|
|
|
|
|
|
# Only compile selected fs
|
|
# Only compile selected fs
|
|
- sed -i '/CONFIG_TARGET_ROOTFS_/d' "$seed_file"
|
|
|
|
- config_opts+=("CONFIG_TARGET_PER_DEVICE_ROOTFS=n")
|
|
|
|
- if [[ $FILESYSTEM == "squashfs" ]]; then
|
|
|
|
- config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=n")
|
|
|
|
- config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=y")
|
|
|
|
- elif [[ $FILESYSTEM == "ext4" ]]; then
|
|
|
|
- config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=n")
|
|
|
|
- config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=y")
|
|
|
|
- fi
|
|
|
|
-
|
|
|
|
- # Only compile selected target
|
|
|
|
|
|
+ # sed -i '/CONFIG_TARGET_ROOTFS_/d' "$seed_file"
|
|
|
|
+ # config_opts+=("CONFIG_TARGET_PER_DEVICE_ROOTFS=n")
|
|
|
|
+ # if [[ $FILESYSTEM == "squashfs" ]]; then
|
|
|
|
+ # config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=n")
|
|
|
|
+ # config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=y")
|
|
|
|
+ # elif [[ $FILESYSTEM == "ext4" ]]; then
|
|
|
|
+ # config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=n")
|
|
|
|
+ # config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=y")
|
|
|
|
+ # fi
|
|
|
|
+
|
|
|
|
+ # Only compile selected target image
|
|
sed -i '/CONFIG_TARGET_DEVICE_/d' "$seed_file"
|
|
sed -i '/CONFIG_TARGET_DEVICE_/d' "$seed_file"
|
|
config_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
|
config_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
|
config_opts+=("CONFIG_TARGET_PROFILE=DEVICE_${P_ARR[profile]}")
|
|
config_opts+=("CONFIG_TARGET_PROFILE=DEVICE_${P_ARR[profile]}")
|
|
config_opts+=("CONFIG_TARGET_${P_ARR[target]//\//_}_DEVICE_${P_ARR[profile]}=y")
|
|
config_opts+=("CONFIG_TARGET_${P_ARR[target]//\//_}_DEVICE_${P_ARR[profile]}=y")
|
|
config_opts+=("CONFIG_SDK=n")
|
|
config_opts+=("CONFIG_SDK=n")
|
|
- # config_opts+=("CONFIG_SDK_LLVM_BPF=n")
|
|
|
|
|
|
+ config_opts+=("CONFIG_SDK_LLVM_BPF=n")
|
|
config_opts+=("CONFIG_IB=n")
|
|
config_opts+=("CONFIG_IB=n")
|
|
config_opts+=("CONFIG_MAKE_TOOLCHAIN=n")
|
|
config_opts+=("CONFIG_MAKE_TOOLCHAIN=n")
|
|
|
|
|
|
@@ -709,16 +652,8 @@ fromSource() {
|
|
echo "$opt" >> "$seed_file"
|
|
echo "$opt" >> "$seed_file"
|
|
done
|
|
done
|
|
|
|
|
|
- [[ -v P_ARR[nested_kopts] ]] &&
|
|
|
|
- echo "${P_ARR[nested_kopts]}" >> "$seed_file"
|
|
|
|
-
|
|
|
|
- # TODO for now symlink clang for qosify
|
|
|
|
- # declare llvm_dir="$GITSRCDIR/staging_dir/host/llvm-bpf/bin"
|
|
|
|
- # [[ -d "$llvm_dir" ]] || mkdir -p "$llvm_dir"
|
|
|
|
- # ln -fs "$(which clang)" "$llvm_dir/clang"
|
|
|
|
-
|
|
|
|
- # Make image
|
|
|
|
- (( DEBUG )) && make_opts+=("V=s")
|
|
|
|
|
|
+ # [[ -v P_ARR[nested_kopts] ]] &&
|
|
|
|
+ # echo "${P_ARR[nested_kopts]}" >> "$seed_file"
|
|
|
|
|
|
# Cleaning modes
|
|
# Cleaning modes
|
|
# make clean # compiled output
|
|
# make clean # compiled output
|
|
@@ -726,6 +661,8 @@ fromSource() {
|
|
# make dirclean # compiled output, toolchain, build tools
|
|
# make dirclean # compiled output, toolchain, build tools
|
|
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
|
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
|
|
|
|
|
|
|
+ # Make image
|
|
|
|
+ (( DEBUG )) && make_opts+=("V=s")
|
|
debug "make ${make_opts[*]} defconfig"
|
|
debug "make ${make_opts[*]} defconfig"
|
|
make "${make_opts[@]}" defconfig
|
|
make "${make_opts[@]}" defconfig
|
|
debug "make ${make_opts[*]} targetclean"
|
|
debug "make ${make_opts[*]} targetclean"
|
|
@@ -737,22 +674,13 @@ fromSource() {
|
|
|
|
|
|
popd &>/dev/null || return 1
|
|
popd &>/dev/null || return 1
|
|
|
|
|
|
- linkSourceImage
|
|
|
|
-
|
|
|
|
- exit
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-# Make the output tree match Image Builder's (non-destructively)
|
|
|
|
-linkSourceImage() {
|
|
|
|
- debug "${FUNCNAME[0]}"
|
|
|
|
- declare out_file
|
|
|
|
- declare -a out_files=("$THIS_BINDIR/targets/${P_ARR[target]}/"*.{img,img.gz,ubi})
|
|
|
|
- for out_file in "${out_files[@]}"; do
|
|
|
|
- [[ -f $out_file ]] && ln -fs "$out_file" "$THIS_BINDIR/${out_file##*/}"
|
|
|
|
|
|
+ # Provide symlinks to images in root of BINDIR (to match Image Builder)
|
|
|
|
+ for image in "$BINDIR/targets/${P_ARR[target]}/"*.{img,img.gz,ubi}; do
|
|
|
|
+ ln -fs "$image" "$BINDIR/${image##*/}"
|
|
done
|
|
done
|
|
-}
|
|
|
|
|
|
|
|
|
|
+ return 0
|
|
|
|
+}
|
|
|
|
|
|
debug() { (( DEBUG )) && echo "Debug: $*"; }
|
|
debug() { (( DEBUG )) && echo "Debug: $*"; }
|
|
|
|
|
|
@@ -767,17 +695,17 @@ askOk() {
|
|
|
|
|
|
resetAll() {
|
|
resetAll() {
|
|
debug "${FUNCNAME[0]}"
|
|
debug "${FUNCNAME[0]}"
|
|
- askOk "Remove $SRCDIR and $BINDIR?" || exit $?
|
|
|
|
- debug "rm -rf $SRCDIR $BINDIR"
|
|
|
|
- rm -rf "$SRCDIR" "$BINDIR"
|
|
|
|
|
|
+ askOk "Remove $BUILDROOT/src and $BUILDROOT/bin?" || exit $?
|
|
|
|
+ debug "rm -rf $BUILDROOT/src $BUILDROOT/bin"
|
|
|
|
+ rm -rf "${BUILDROOT:?}/src" "${BUILDROOT:?}/bin"
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
resetProfile() {
|
|
resetProfile() {
|
|
debug "${FUNCNAME[0]}"
|
|
debug "${FUNCNAME[0]}"
|
|
- askOk "Remove $BUILDDIR and $THIS_BINDIR?" || exit $?
|
|
|
|
- debug "rm -rf $BUILDDIR $THIS_BINDIR"
|
|
|
|
- rm -rf "$BUILDDIR" "$THIS_BINDIR"
|
|
|
|
|
|
+ askOk "Remove $BUILDDIR and $BINDIR?" || exit $?
|
|
|
|
+ debug "rm -rf $BUILDDIR $BINDIR"
|
|
|
|
+ rm -rf "$BUILDDIR" "$BINDIR"
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -816,11 +744,10 @@ main() {
|
|
declare -g BUILDROOT="${BUILDROOT:=$SCRIPTDIR}"
|
|
declare -g BUILDROOT="${BUILDROOT:=$SCRIPTDIR}"
|
|
[[ $BUILDROOT == "/" ]] && echo "Invalid --buildroot" && exit 1
|
|
[[ $BUILDROOT == "/" ]] && echo "Invalid --buildroot" && exit 1
|
|
declare -g FILESDIR="${FILESDIR:=$BUILDROOT/src/files}"
|
|
declare -g FILESDIR="${FILESDIR:=$BUILDROOT/src/files}"
|
|
- declare -g SRCDIR="$BUILDROOT/src" # input/build
|
|
|
|
declare -g BINDIR="$BUILDROOT/bin" # output
|
|
declare -g BINDIR="$BUILDROOT/bin" # output
|
|
- declare -g GITSRCDIR="$SRCDIR/openwrt"
|
|
|
|
|
|
+ declare -g GITSRCDIR="$BUILDROOT/src/openwrt"
|
|
|
|
|
|
- for dir in "$SRCDIR" "$BINDIR"; do
|
|
|
|
|
|
+ for dir in "$BUILDROOT/src" "$BUILDROOT/bin"; do
|
|
[[ -d "$dir" ]] || mkdir -p "$dir"
|
|
[[ -d "$dir" ]] || mkdir -p "$dir"
|
|
done
|
|
done
|
|
|
|
|
|
@@ -849,9 +776,9 @@ main() {
|
|
|
|
|
|
# release precedence: user input>profile>env>hardcode
|
|
# release precedence: user input>profile>env>hardcode
|
|
declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
|
declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
|
- declare -g BUILDDIR="$SRCDIR/$profile/$RELEASE"
|
|
|
|
|
|
+ declare -g BUILDDIR="$BUILDROOT/src/$profile/$RELEASE"
|
|
|
|
+ declare -g BINDIR="$BUILDROOT/bin/$profile/$RELEASE"
|
|
declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}"
|
|
declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}"
|
|
- declare -g THIS_BINDIR="$BINDIR/$profile/$RELEASE"
|
|
|
|
|
|
|
|
if [[ "$RELEASE" == "snapshot" ]]; then
|
|
if [[ "$RELEASE" == "snapshot" ]]; then
|
|
declare url_prefix="https://downloads.openwrt.org/snapshots/targets/${P_ARR[target]}"
|
|
declare url_prefix="https://downloads.openwrt.org/snapshots/targets/${P_ARR[target]}"
|
|
@@ -863,23 +790,17 @@ main() {
|
|
declare img_fname="openwrt-$RELEASE-${P_ARR[target]//\//-}-${P_ARR[profile]}-$FILESYSTEM"
|
|
declare img_fname="openwrt-$RELEASE-${P_ARR[target]//\//-}-${P_ARR[profile]}-$FILESYSTEM"
|
|
fi
|
|
fi
|
|
|
|
|
|
- declare -g IB_URL="$url_prefix/$url_filename"
|
|
|
|
- declare -g IB_ARCHIVE="$BUILDDIR/$url_filename"
|
|
|
|
- declare -g IB_SHA256_URL="$url_prefix/sha256sums"
|
|
|
|
- declare -g IB_SHA256_FILE="$IB_ARCHIVE.sha256sums"
|
|
|
|
- declare -g IB_OUT_SHA256_FILE="$THIS_BINDIR/sha256sums"
|
|
|
|
- declare -g FACTORYIMG="$BUILDDIR/$img_fname-factory.img"
|
|
|
|
- declare -g FACTORYIMGGZ="$BUILDDIR/$img_fname-factory.img.gz"
|
|
|
|
- declare -g FACTORYIMGGZFNAME="${FACTORYIMGGZ##*/}"
|
|
|
|
- declare -g SYSUPGRADEIMG="$BUILDDIR/$img_fname-sysupgrade.img"
|
|
|
|
- declare -g SYSUPGRADEIMGGZ="$BUILDDIR/$img_fname-sysupgrade.img.gz"
|
|
|
|
- declare -g SYSUPGRADEIMGGZFNAME="${SYSUPGRADEIMGGZ##*/}"
|
|
|
|
- declare -g SOURCEFACTORYIMG="$THIS_BINDIR/$img_fname-factory.img"
|
|
|
|
- declare -g SOURCEFACTORYIMGGZ="$THIS_BINDIR/$img_fname-factory.img.gz"
|
|
|
|
- declare -g SOURCESYSUPGRADEIMG="$THIS_BINDIR/targets/$img_fname-sysupgrade.img"
|
|
|
|
- declare -g SOURCESYSUPGRADEIMGGZ="$THIS_BINDIR/targets/$img_fname-sysupgrade.img.gz"
|
|
|
|
- declare -g SOURCESYSUPGRADEIMGGZFNAME="${SOURCESYSUPGRADEIMGGZ##*/}"
|
|
|
|
- declare -g SEED_URL="$url_prefix/config.buildinfo"
|
|
|
|
|
|
+ if (( FROM_SOURCE )); then
|
|
|
|
+ declare -g SYSUPGRADEIMGGZ="$BINDIR/targets/$img_fname-sysupgrade.img.gz"
|
|
|
|
+ declare -g SEED_URL="$url_prefix/config.buildinfo"
|
|
|
|
+ else
|
|
|
|
+ declare -g SYSUPGRADEIMGGZ="$BUILDDIR/$img_fname-sysupgrade.img.gz"
|
|
|
|
+ declare -g IB_URL="$url_prefix/$url_filename"
|
|
|
|
+ declare -g IB_ARCHIVE="$BUILDDIR/$url_filename"
|
|
|
|
+ declare -g IB_SHA256_URL="$url_prefix/sha256sums"
|
|
|
|
+ declare -g IB_SHA256_FILE="$IB_ARCHIVE.sha256sums"
|
|
|
|
+ declare -g IB_OUT_SHA256_FILE="$BINDIR/sha256sums"
|
|
|
|
+ fi
|
|
|
|
|
|
if (( DEBUG )); then
|
|
if (( DEBUG )); then
|
|
echo "Profile settings:"
|
|
echo "Profile settings:"
|
|
@@ -889,29 +810,13 @@ main() {
|
|
ALIAS (\$profile, \$P_ARR)=$profile, $P_ARR
|
|
ALIAS (\$profile, \$P_ARR)=$profile, $P_ARR
|
|
BUILDROOT=$BUILDROOT
|
|
BUILDROOT=$BUILDROOT
|
|
BUILDDIR=$BUILDDIR
|
|
BUILDDIR=$BUILDDIR
|
|
- SRCDIR=$SRCDIR
|
|
|
|
- BINDIR=$BINDIR
|
|
|
|
GITSRCDIR=$GITSRCDIR
|
|
GITSRCDIR=$GITSRCDIR
|
|
- THIS_BINDIR=$THIS_BINDIR
|
|
|
|
|
|
+ BINDIR=$BINDIR
|
|
TARGET=${P_ARR[target]}
|
|
TARGET=${P_ARR[target]}
|
|
PROFILE=${P_ARR[profile]}
|
|
PROFILE=${P_ARR[profile]}
|
|
RELEASE=$RELEASE
|
|
RELEASE=$RELEASE
|
|
FILESYSTEM=$FILESYSTEM
|
|
FILESYSTEM=$FILESYSTEM
|
|
- IB_URL=$IB_URL
|
|
|
|
- IB_ARCHIVE=$IB_ARCHIVE
|
|
|
|
- SEED_URL=$SEED_URL
|
|
|
|
- IB_SHA256_URL=$IB_SHA256_URL
|
|
|
|
- IB_SHA256_FILE=$IB_SHA256_FILE
|
|
|
|
- IB_OUT_SHA256_FILE=$IB_OUT_SHA256_FILE
|
|
|
|
- FACTORYIMGGZ=$FACTORYIMGGZ
|
|
|
|
- FACTORYIMGGZFNAME=$FACTORYIMGGZFNAME
|
|
|
|
SYSUPGRADEIMGGZ=$SYSUPGRADEIMGGZ
|
|
SYSUPGRADEIMGGZ=$SYSUPGRADEIMGGZ
|
|
- SYSUPGRADEIMGGZFNAME=$SYSUPGRADEIMGGZFNAME
|
|
|
|
- SOURCEFACTORYIMG=$SOURCEFACTORYIMG
|
|
|
|
- SOURCEFACTORYIMGGZ=$SOURCEFACTORYIMGGZ
|
|
|
|
- SOURCESYSUPGRADEIMG=$SOURCESYSUPGRADEIMG
|
|
|
|
- SOURCESYSUPGRADEIMGGZ=$SOURCESYSUPGRADEIMGGZ
|
|
|
|
- SOURCESYSUPGRADEIMGGZFNAME=$SOURCESYSUPGRADEIMGGZFNAME
|
|
|
|
EOF
|
|
EOF
|
|
fi
|
|
fi
|
|
|
|
|
|
@@ -919,25 +824,26 @@ main() {
|
|
|
|
|
|
[[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR"
|
|
[[ -d $BUILDDIR ]] || mkdir -p "$BUILDDIR"
|
|
|
|
|
|
- (( FROM_SOURCE )) && fromSource
|
|
|
|
-
|
|
|
|
- # Acquire and verify Image Builder
|
|
|
|
- getImageBuilder &&
|
|
|
|
- getImageBuilderChecksum &&
|
|
|
|
- verify "$IB_ARCHIVE" "$IB_SHA256_FILE" || return $?
|
|
|
|
-
|
|
|
|
- extractImageBuilder || return $?
|
|
|
|
-
|
|
|
|
- addRepos
|
|
|
|
-
|
|
|
|
- #copyFiles
|
|
|
|
-
|
|
|
|
- [[ -v SSH_BACKUP_PATH ]] && sshBackup
|
|
|
|
|
|
+ if (( FROM_SOURCE )); then
|
|
|
|
+ fromSource || return $?
|
|
|
|
+ else
|
|
|
|
+ getImageBuilder &&
|
|
|
|
+ getImageBuilderChecksum &&
|
|
|
|
+ verify "$IB_ARCHIVE" "$IB_SHA256_FILE" || return $?
|
|
|
|
+ extractImageBuilder || return $?
|
|
|
|
+ addRepos
|
|
|
|
+ makeImages &&
|
|
|
|
+ verifyImages
|
|
|
|
+ #copyFiles
|
|
|
|
|
|
- if makeImages && verifyImages; then
|
|
|
|
- [[ -v SSH_UPGRADE_PATH ]] && sshUpgrade
|
|
|
|
- [[ -v FLASH_DEV ]] && flashImage
|
|
|
|
fi
|
|
fi
|
|
|
|
+
|
|
|
|
+ [[ -v SSH_BACKUP_PATH ]] &&
|
|
|
|
+ sshBackup
|
|
|
|
+ [[ -v SSH_UPGRADE_PATH ]] &&
|
|
|
|
+ sshUpgrade "$SYSUPGRADEIMGGZ" "$SSH_UPGRADE_PATH"
|
|
|
|
+ [[ -v FLASH_DEV ]] &&
|
|
|
|
+ flashImage "$SYSUPGRADEIMGGZ" "$FLASH_DEV"
|
|
done
|
|
done
|
|
}
|
|
}
|
|
|
|
|