mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-12 04:47:17 +04:00
Several image recipes call tar without the options that pin the member order, the owner, the mode and the modification time. The archive then holds the build time, the umask of the build user and the readdir order of the build directory, so two builds of the same source produce different images. Pass the same options that Image/mkfs/targz and sysupgrade-tar.sh already use. The recipes define no member order, so sorting the members takes nothing away. The diffoscope of the published WAX610 archive shows the order differing between the build machines, which is what a readdir order produces. --mode=go-w clears the write bit of the group and of the others. tar keeps the mode of the file on disk, which follows the umask of the build user, so without it the archive differs between a host with umask 022 and one with umask 002. Covers the Netgear factory archives of ipq40xx, ipq60xx and ipq807x, the Creality factory archive of mt76x8, the D-Link DWL8610AP archive of bcm53xx, the Freecom archive of ixp4xx and the Linksys switch archive of realtek. Signed-off-by: John Crispin <john@phrozen.org>
100 lines
2.6 KiB
Bash
Executable File
100 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
#
|
|
# Copyright (C) 2024 OpenWrt.org
|
|
#
|
|
# This script creates a tar file for the Linksys switches of the LGS3xxC/LGS3xxMPC
|
|
# series. It contains not only the OpenWrt firmware but additional scripts that
|
|
# are needed for the upgrade.
|
|
#
|
|
# ./linksys-image.py <ImageFile> <ImageFileOut> <LinksysModel>
|
|
#
|
|
# Known values for LinksysModel are currently
|
|
#
|
|
# LGS310MPC 60402010
|
|
# LGS310C 60402060
|
|
# LGS328PC 60401070
|
|
# LGS328PC(RTL8218D) 60401080
|
|
# LGS310MPCv2 60402090
|
|
# LGS328MPC 60412020
|
|
# LGS328C 60412040
|
|
# LGS328MPCv2 60412060
|
|
# LGS352MPC 60422030
|
|
# LGS352C 60422050
|
|
# LGS352MPCv2 60422070
|
|
|
|
# The check script that verifies if the images matches the hardware model
|
|
gen_imagecheck() {
|
|
echo '#!/bin/sh'
|
|
echo 'if [ "$1" = "'${1}'" ]; then'
|
|
echo 'echo 0'
|
|
echo 'else'
|
|
echo 'echo 1'
|
|
echo 'fi'
|
|
}
|
|
|
|
# Generic attributes
|
|
gen_fwinfo() {
|
|
echo 'FW_VERSION=1.01.100\nBOOT_VERSION=01.00.01'
|
|
}
|
|
|
|
# NOR upgrade script. It allows to install OpenWrt only to first partition.
|
|
gen_nor_upgrade() {
|
|
echo '#!/bin/sh'
|
|
echo 'flash_bank=65536'
|
|
echo 'filesize=`stat --format=%s ./series_vmlinux.bix`'
|
|
echo 'num_bank=`expr \( ${filesize} + ${flash_bank} - 1 \) / ${flash_bank}`'
|
|
echo 'filesize_bank=`expr ${num_bank} \* ${flash_bank}`'
|
|
echo 'case $1 in'
|
|
echo '1)'
|
|
echo 'mtd_debug erase $2 0 ${filesize_bank} >/dev/null 2>&1'
|
|
echo 'mtd_debug write $2 0 ${filesize} ./series_vmlinux.bix >/dev/null 2>&1'
|
|
echo 'mtd_debug read $2 0 100 image1.img >/dev/null 2>&1'
|
|
echo 'CreateImage -r ./image1.img > /tmp/app/image1.txt'
|
|
echo 'echo 0'
|
|
echo ';;'
|
|
echo '*)'
|
|
echo 'echo 1'
|
|
echo 'esac'
|
|
}
|
|
|
|
# NAND upgrade script. It allows to install OpenWrt only to first partition.
|
|
gen_nand_upgrade() {
|
|
echo '#!/bin/sh'
|
|
echo 'case $1 in'
|
|
echo '1)'
|
|
echo 'flash_eraseall $2 >/dev/null 2>&1'
|
|
echo 'nandwrite -p $2 ./series_vmlinux.bix >/dev/null 2>&1'
|
|
echo 'mtd_debug read $2 0 100 image1.img >/dev/null 2>&1'
|
|
echo 'CreateImage -r ./image1.img > /tmp/app/image1.txt'
|
|
echo 'echo 0'
|
|
echo ';;'
|
|
echo '*)'
|
|
echo 'echo 1'
|
|
echo 'esac'
|
|
}
|
|
|
|
tmpdir="$( mktemp -d 2> /dev/null )"
|
|
imgdir=$tmpdir/image
|
|
mkdir $imgdir
|
|
|
|
gen_imagecheck $3 > $imgdir/iss_imagecheck.sh
|
|
gen_nor_upgrade > $imgdir/iss_imageupgrade.sh
|
|
gen_nand_upgrade > $imgdir/iss_nand_imageupgrade.sh
|
|
gen_fwinfo > $imgdir/firmware_information.txt
|
|
|
|
chmod +x $imgdir/iss_imagecheck.sh
|
|
chmod +x $imgdir/iss_imageupgrade.sh
|
|
chmod +x $imgdir/iss_nand_imageupgrade.sh
|
|
|
|
cp $1 $imgdir/series_vmlinux.bix
|
|
|
|
mtime=""
|
|
if [ -n "$SOURCE_DATE_EPOCH" ]; then
|
|
mtime="--mtime=@${SOURCE_DATE_EPOCH}"
|
|
fi
|
|
|
|
tar cf $2 -C $tmpdir --sort=name --numeric-owner --owner=0 --group=0 --mode=go-w $mtime image/
|
|
|
|
rm -rf $tmpdir
|