İşlemeleri karşılaştır

..

6 İşleme

Yazar SHA1 Mesaj Tarih
395263ee66 Update feeds after distclean 2024-12-07 10:02:34 -05:00
bdc4ff67e7 Mke backup filenames human readable 2024-12-06 12:51:31 -05:00
1d078a30e0 Include target subdirs in sysupgrade filepath 2024-12-06 12:32:01 -05:00
0d8502bfac Add debugging to fix backup 2024-12-06 11:49:19 -05:00
a44254bcc9 FReformat case statements 2024-12-06 09:43:04 -05:00
dcf9aaee84 Add back partition size desc 2024-12-06 09:12:04 -05:00
2 değiştirilmiş dosya ile 62 ekleme ve 46 silme

Dosyayı Görüntüle

@@ -7,6 +7,7 @@
# Set default release
: "${RELEASE:="23.05.5"}"
# @internal
print_help() {
debug "${FUNCNAME[0]}"
@@ -46,6 +47,7 @@ print_help() {
EOF
}
# @internal
init() {
debug "${FUNCNAME[0]}"
declare -g ID RPM_MGR SCRIPT_DIR DL_TOOL
@@ -83,19 +85,18 @@ init() {
raspbian) ID="debian" ;;
*)
echo "Autodetecting distro, this may be unreliable"
if command -v dnf &>/dev/null; then
ID="fedora"
RPM_MGR="dnf"
elif command -v yum &>/dev/null; then
ID="centos"
RPM_MGR="yum"
elif command -v apt &>/dev/null; then
ID="ubuntu"
elif command -v pacman &>/dev/null; then
ID="arch"
else
return 1
fi
for cmd in dnf yum apt pacman; do
if command -v "$cmd" &>/dev/null; then
case "$cmd" in
dnf) ID="fedora"; RPM_MGR="dnf" ;;
yum) ID="centos"; RPM_MGR="yum" ;;
apt) ID="ubuntu" ;;
pacman) ID="arch" ;;
esac
break
fi
done
[[ -z $ID ]] && return 1
;;
esac
@@ -119,6 +120,7 @@ init() {
fi
}
# @description Arguments
parse_input() {
debug "${FUNCNAME[0]}" "$*"
declare -ga PROFILES
@@ -143,10 +145,7 @@ parse_input() {
--verbose) VERBOSE=1 ;;
--debug|-d) echo "Debugging on"; DEBUG=1 ;;
--help|-h) print_help; exit 0 ;;
--)
shift
break
;;
--) shift; break ;;
esac
shift
done
@@ -156,6 +155,7 @@ parse_input() {
fi
}
# @description Install build dependencies on major distros
install_dependencies() {
debug "${FUNCNAME[0]}"
local -a pkg_list
@@ -319,6 +319,7 @@ install_dependencies() {
fi
}
# @description Acquires the OpenWRT Image Builder
get_imagebuilder() {
debug "${FUNCNAME[0]}" "$*"
local -a url_file_pairs=("$@")
@@ -461,6 +462,9 @@ ssh_upgrade() {
return 0
}
# @description Builds OpenWRT from source code using the the default buildbot as base
# This enables the use of kernel config options in profiles
# @arg $1 string .config seed URL
from_source() {
debug "${FUNCNAME[0]}" "$*"
local seed_url="$1"
@@ -519,16 +523,16 @@ from_source() {
# Enter worktree
execute pushd "$WORKTREE_DIR" || return 1
# Cleanup build environment
((VERBOSE)) && make_opts+=("V=s")
execute make "${make_opts[@]}" "-j1" distclean # TODO 'dirclean' has a bug that triggers menuconfig
# Update package feed
./scripts/feeds update -i -f &&
./scripts/feeds update -a -f &&
./scripts/feeds install -a -f
# Cleanup build environment
((VERBOSE)) && make_opts+=("V=s")
execute make "${make_opts[@]}" "-j1" distclean # TODO 'dirclean' has a bug that triggers menuconfig
# Grab the release seed config
if ! execute "$DL_TOOL" "-o" "$seed_file" "$seed_url"; then
echo "Could not obtain $seed_file from $seed_url"
@@ -597,7 +601,7 @@ from_source() {
return 1
fi
popd || return 1
execute popd || return 1
# Symlink output images to root of BIN_DIR (match Image Builder)
shopt -s nullglob
@@ -609,7 +613,34 @@ from_source() {
return 0
}
# Generic helpers
# @description Backs up a file to a chosen directory using its timestamp
# @arg $1 string File to backup
# @arg $2 string Directory to backup to
backup() {
debug "${FUNCNAME[0]}" "$*"
local file="$1" dir="$2"
local creation_date base_name backup_file
[[ -f $file ]] || { debug "File not found: $file"; return 1; }
[[ -d $dir ]] || execute mkdir -p "$dir" || { debug "Failed to create directory: $dir"; return 1; }
if creation_date=$(stat -c %w "$file" 2>/dev/null || stat -c %y "$file" 2>/dev/null) && \
[[ $creation_date != "-" && -n $creation_date ]] && \
creation_date=$(date -d "$creation_date" +%y%m%d%H%M 2>/dev/null); then
debug "Creation date: $creation_date"
else
creation_date="unknown"
debug "Unable to determine creation date, using 'unknown'"
fi
base_name="${file##*/}"
backup_file="$dir/$creation_date-$base_name"
[[ -f $backup_file ]] || execute cp --archive "$file" "$backup_file"
}
# @section Helper functions
# @internal
debug() { ((DEBUG)) && echo "Debug: $*"; }
ask_ok() {
((YES)) && return
@@ -619,7 +650,6 @@ ask_ok() {
[[ "$r" =~ ^(yes|y)$ ]]
}
extract() {
debug "${FUNCNAME[0]}" "$*"
local archive="$1"
local out_dir="$2"
if ! execute tar -axf "$archive" -C "$out_dir" --strip-components 1; then
@@ -627,32 +657,15 @@ extract() {
return 1
fi
}
backup_image() {
debug "${FUNCNAME[0]} $*"
local file="$1" dir="$2" count=1
[[ -f $file ]] || return 1
local creation_date
creation_date=$(stat -c %w "$file" 2>/dev/null || stat -c %y "$file" | cut -d' ' -f1)
creation_date=${creation_date:-unknown} # Default to "unknown" if no creation date
[[ "$creation_date" == "-" ]] && creation_date="unknown"
local base_name; base_name=$(basename "$file")
execute mkdir -p "$dir"
while [[ -e "$dir/$creation_date-$base_name.bk.$count" ]]; do ((count++)); done
execute mv "$file" "$dir/$creation_date-$base_name.bk.$count"
}
verify() {
debug "${FUNCNAME[0]}" "$*"
local file_to_check="$1"
local sumfile="$2"
local file_to_check="$1" sum_file="$2"
local checksum
command -v sha256sum &>/dev/null || return 1
[[ -f $sumfile && -f $file_to_check ]] || return 1
checksum=$(grep "${file_to_check##*/}" "$sumfile" | cut -f1 -d' ')
[[ -f $sum_file && -f $file_to_check ]] || return 1
checksum=$(grep "${file_to_check##*/}" "$sum_file" | cut -f1 -d' ')
echo -n "$checksum $file_to_check" | sha256sum --check --status
}
load() {
debug "${FUNCNAME[0]}" "$*"
local source_file="$1"
# shellcheck disable=SC1090
[[ -f $source_file ]] && source "$source_file"
@@ -665,6 +678,8 @@ execute() {
fi
}
# @description The openwrtbuilder main function
# @internal
main() {
debug "${FUNCNAME[0]}"
@@ -749,12 +764,12 @@ main() {
local seed_url="$url_prefix/config.buildinfo"
if ((FROM_SOURCE)); then
declare -g SYSUPGRADEIMGGZ="$BIN_DIR/targets/$img_fname-sysupgrade.img.gz"
declare -g SYSUPGRADEIMGGZ="$BIN_DIR/targets/$TARGET/$img_fname-sysupgrade.img.gz"
else
declare -g SYSUPGRADEIMGGZ="$BUILD_DIR/$img_fname-sysupgrade.img.gz"
fi
backup_image "$SYSUPGRADEIMGGZ" "$BACKUP_DIR/$profile/$RELEASE"
backup "$SYSUPGRADEIMGGZ" "$BACKUP_DIR/$profile/$RELEASE"
if ((RESET)); then
if ((FROM_SOURCE)); then

Dosyayı Görüntüle

@@ -18,6 +18,7 @@ declare -Ag r4s=(
kmod-fs-btrfs btrfs-progs block-mount smcroute avahi-daemon \
curl ethtool ca-bundle"
[config]="CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y CONFIG_BTRFS_PROGS_ZSTD=y \
CONFIG_TARGET_ROOTFS_PARTSIZE=512 CONFIG_TARGET_KERNEL_PARTSIZE=32 \
CONFIG_BUILDBOT=n"
[files]="/mnt/backup"
)