blob: b93b2584bb4970bcb16650b893722444986fdf88 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/bin/sh
2
3. $TOPDIR/scripts/functions.sh
4
5board=""
6kernel=""
7rootfs=""
8outfile=""
9err=""
10
11while [ "$1" ]; do
12 case "$1" in
13 "--board")
14 board="$2"
15 shift
16 shift
17 continue
18 ;;
19 "--kernel")
20 kernel="$2"
21 shift
22 shift
23 continue
24 ;;
25 "--rootfs")
26 rootfs="$2"
27 shift
28 shift
29 continue
30 ;;
31 *)
32 if [ ! "$outfile" ]; then
33 outfile=$1
34 shift
35 continue
36 fi
37 ;;
38 esac
39done
40
41if [ ! -n "$board" -o ! -r "$kernel" -a ! -r "$rootfs" -o ! "$outfile" ]; then
42 echo "syntax: $0 [--board boardname] [--kernel kernelimage] [--rootfs rootfs] out"
43 exit 1
44fi
45
46tmpdir="$( mktemp -d 2> /dev/null )"
47if [ -z "$tmpdir" ]; then
48 # try OSX signature
49 tmpdir="$( mktemp -t 'ubitmp' -d )"
50fi
51
52if [ -z "$tmpdir" ]; then
53 exit 1
54fi
55
56mkdir -p "${tmpdir}/sysupgrade-${board}"
57echo "BOARD=${board}" > "${tmpdir}/sysupgrade-${board}/CONTROL"
58if [ -n "${rootfs}" ]; then
59 case "$( get_fs_type ${rootfs} )" in
60 "squashfs")
61 dd if="${rootfs}" of="${tmpdir}/sysupgrade-${board}/root" bs=1024 conv=sync
62 ;;
63 *)
64 cp "${rootfs}" "${tmpdir}/sysupgrade-${board}/root"
65 ;;
66 esac
67fi
68[ -z "${kernel}" ] || cp "${kernel}" "${tmpdir}/sysupgrade-${board}/kernel"
69
70mtime=""
71if [ -n "$SOURCE_DATE_EPOCH" ]; then
72 mtime="--mtime=@${SOURCE_DATE_EPOCH}"
73fi
74
75(cd "$tmpdir"; tar --sort=name --owner=0 --group=0 --numeric-owner -cvf sysupgrade.tar sysupgrade-${board} ${mtime})
76err="$?"
77if [ -e "$tmpdir/sysupgrade.tar" ]; then
78 cp "$tmpdir/sysupgrade.tar" "$outfile"
79else
80 err=2
81fi
82rm -rf "$tmpdir"
83
84exit $err