aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/upgrade/common.sh
Commit message (Collapse)AuthorAgeFilesLines
* base-files: upgrade: add case to export_bootdeviceKlaus Kudielka2019-10-091-1/+13
| | | | | | | | | | | The factory uboot of the Turris Omnia boots with "root=b301", and we instruct new users to sysupgrade from there (e.g. method 1, step 7). Currently, this will fail with "Unable to determine upgrade device". Add a new case to export_bootdevice, which parses the hex argument. Fixes commit 2e5a0b81 ("mvebu: sysupgrade: sdcard: keep user added ...") Signed-off-by: Klaus Kudielka <klaus.kudielka@gmail.com>
* treewide: sysupgrade: use $UPGRADE_BACKUP to check for backupRafał Miłecki2019-09-111-1/+1
| | | | | | | Now that $UPGRADE_BACKUP is set conditionally there is no need to check the $UPGRADE_OPT_SAVE_CONFIG anymore. All conditions can be simplified. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* treewide: use new procd sysupgrade $UPGRADE_BACKUP variableRafał Miłecki2019-09-051-1/+1
| | | | | | | | | | It's a variable set by procd that should replace hardcoded /tmp/sysupgrade.tgz. This change requires the most recent procd with the commit 0f3c136 ("sysupgrade: set UPGRADE_BACKUP env variable"). Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* treewide: don't hardcode "sysupgrade.tgz" file nameRafał Miłecki2019-09-051-0/+2
| | | | | | | | 1) Add BACKUP_FILE and use it when copying an archive to be restored after sysupgrade (on the next preinit). 2) Use CONF_TAR for copying backup prepared by the /sbin/sysupgrade Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: pass "save_config" option to the "sysupgrade" methodRafał Miłecki2019-08-221-1/+1
| | | | | | This explicitly lets stage2 know if config should be preserved. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: move stage2 upgrade to separated fileRafał Miłecki2019-07-111-22/+0
| | | | | | | | | do_upgrade_stage2() isn't really any common code. It isn't used anywhere except for /sbin/sysupgrade that passes it to the stage2. Moving its code to separated file also simplifies COMMAND variable. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: drop support for NAND upgrade in platform_pre_upgrade()Rafał Miłecki2019-07-081-3/+1
| | | | | | | With bcm53xx switched to the new procedure there is no more need for keeping that backward compatibility code. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: drop unused jffs2_copy_config()Rafał Miłecki2019-07-081-10/+0
| | | | | | | | Its last usage was dropped back in 2013 in the commit b95bdc8ab56e ("kernel/base-files: clean up old code related to refreshing mtd partitions, it is no longer used anywhere"). Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: improve lib/upgrade/common.shKlaus Kudielka2019-05-111-13/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recently, upgrade device autodetection has been added to the mvebu target. This exposes some shortcomings of the generic export_bootdevice function, e.g. on the Turris Omnia: export_bootdevice silently reports the root partition to be the boot device. This makes the sysupgrade process fail at several places. Fix this by clearly distinguishing between /proc/cmdline arguments which specify the boot disk, and those which specify the root partition. Only in the latter case, strip off the partition, and do it consistently. root=PARTUUID=<pseudo PARTUUID for MBR> (any partition) and root=/dev/* (any partition) are accepted. The root of the problem is that the *existing* export_bootdevice in /lib/upgrade/common.sh behaves differently, if the kernel is booted with root=/dev/..., or if it is booted with root=PARTUUID=... In the former case, it reports back major/minor of the root partition, in the latter case it reports back major/minor of the complete boot disk. Targets, which boot with root=/dev/... *and* use export_bootdevice / export_partdevice, have added workarounds to this behaviour, by specifying *negative* increments to the export_partdevice function. Consequently, those targets have to be adapted to use positive increments, otherwise they are broken by the change to export_bootdevice. Fixes: 4e8345ff68 ("mvebu: base-files: autodetect upgrade device") Signed-off-by: Klaus Kudielka <klaus.kudielka@gmail.com> Tested-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
* base-files: sysupgrade: support additional mtd optionsDavid Bauer2019-01-261-2/+2
| | | | | | | | | | Add support for passing additional parameters to mtd called during sysupgrade. It will be required to toggle the "recovery moe" flag supported by recent tp-link boards. Signed-off-by: David Bauer <mail@david-bauer.net> [split code from board support patch; add commit message] Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: fix several bashismsMichael Heimpold2018-12-051-1/+1
| | | | | | | For equality test a simple = is sufficient, the == is usually disregarded as bashism. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
* treewide: consolidate upgrade state setMathias Kresin2018-08-161-0/+5
| | | | | | | | | | Set the (sys)upgrade state when sourcing the stage2 script instead of setting the state for each target individual. This change fixes the, due to a missing state set, not working upgrade led on ath79 and apm821xx. Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: exit if mtd write command fails during sysupgradeRafał Miłecki2018-06-181-0/+1
| | | | | | | | | | It avoids confusing situations like: > Could not get image magic > Image check failed. > Upgrade completed > Rebooting system... Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: sysupgrade: fix handing get_image unpack commandsMatthias Schiffer2018-06-111-6/+6
| | | | | | | | On bcm53xx and brcm47xx, commands are passed to default_do_upgrade that expect the image to be passed on stdin, rather than as an argument. Fixes: 30f61a34b4cf ("base-files: always use staged sysupgrade") Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: don't evaluate block-device ueventDaniel Golle2018-02-131-4/+8
| | | | | | | | | | | | | Current code and also before commit da52dd0c83 was vulnerable to shell injection using volume lables in the GPT partition table of block devices. Given that partition names can be freely defined in GPT tables we really shouldn't evaluate a string which is potentially crafted with evil intentions. Hence rather use `export -n` to absorb the uevent's variables into the environment. Fixes commit da52dd0c83 (base-files: quote values when evaluating uevent) Signed-off-by: Daniel Golle <daniel@makrotopia.org> [mschiffer@universe-factory.net: suggested export -n usage]
* base-files: quote values when evaluating ueventDaniel Golle2018-02-111-3/+2
| | | | | | | | When sourcing /sys/class/block/*/uevent values have to be quoted as they may contain spaces (e.g. in PARTNAME). Fix this by pre-processing with sed before sourcing. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: upgrade: make get_partitions() endian agnosticChristian Lamparter2017-12-081-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | This patch fixes two issues with the current get_partitions() function. First: "Invalid partition table on $disk" will pop up on legitimate images on big endian system. This is because the little-endian representation of "55 AA" is assumed in the context of little-endian architectures. On these comparing it to the 16-bit word 0xAA55 does work as intented. Whereas on big-endian systems, this would have to be 0x55AA. This patch fixes the issue by replacing the integer conversion and value match check with just a string comparision. Second: The extraction of the type, start LBA and LBA num from the partition table has the same endianness issue. This has been fixed by using the new hex_le32_to_cpu() function. This function will translate the stored little-endian data to the correct byte-order if necessary. Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: automatically handle paths and symlinks for RAMFS_COPY_BINMatthias Schiffer2017-07-111-11/+16
| | | | | | | | | | | | Depending on busybox applet selection, paths of basic utiilties may differ, and may not work as symlinks to busybox. Simply using whatever binary is found in PATH and detecting symlinks automatically is more robust and easier to maintain. The list of binaries is also slightly cleaned up and duplicates are removed. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: upgrade: correctly handle nand_do_upgrade argument passed from ↵Matthias Schiffer2017-07-111-1/+1
| | | | | | | preupgrade Fixes: 30f61a34b4cf "base-files: always use staged sysupgrade" Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: sysupgrade cleanupMatthias Schiffer2017-05-291-100/+0
| | | | | | | | | | | | Some functions only used by stage2 are moved there from common.sh. One piece that could still use more cleanup is platform_pre_upgrade: many targets reference files from there are aren't available in the ramfs, so we need to evaluate it before the switch; conversely, flash writes happen in that function on some targets. Targets that do the latter should be fixed eventually to use platform_do_upgrade for that purpose. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: always use staged sysupgradeMatthias Schiffer2017-05-291-67/+56
| | | | | | | | | | | Support for the -d and -p options is dropped; it may be added again at some point by adding these flags to the ubus sysupgrade call. A downside of this is that we get a lot less information about the progress of the upgrade: as soon as the actual upgrade starts, all shell sessions are killed to allow unmounting the root filesystem. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: save /bin/mknod for sysupgradeFelix Fietkau2017-01-061-1/+2
| | | | | | It is used on NAND devices in case hotplug is too slow Signed-off-by: Felix Fietkau <nbd@nbd.name>
* base-files: export x86 platform upgrade functions to common.shYousong Zhou2017-01-051-0/+90
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* package/basefiles: add mkfs.ext4 and losetup binaries to ramfs listAndré Valentin2016-10-261-0/+2
| | | | | | | mkfs.ext4 und losetup are needed for sysupgrade support on mmc devices with automatic rootfs split (loopback device usage). Signed-off-by: André Valentin <avalentin@marcant.net>
* sysupgrade: unmount filesystems before rebootMathias Kresin2016-08-041-0/+1
| | | | | | | | | | | | | | | sysupgrade immediately reboots after flashing an image and doesn't allow to unmount filesystems. At least in case the image used for sysupgrade is stored on a FAT formatted usb flash drive, the following warning is printed during the next mount of the flash drive: FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. Although a data corruption during read operations is unlikely, there is no need to scare the users. Signed-off-by: Mathias Kresin <dev@kresin.me>
* base-files: sysupgrade: fix pseudobridge upgradesConn O'Griofa2016-07-241-1/+1
| | | | | | Treat 'relayd' as an essential service to avoid connection interruptions during sysupgrade on devices configured as a pseudobridge. Signed-off-by: Conn O'Griofa <connogriofa@gmail.com>
* x86: generalize partition discovery for sysupgradeJo-Philipp Wich2016-05-241-1/+1
| | | | | | | | | | | | | | | Generalize the partition discovery in sysupgrade in order to fix sysupgrade and config backup/recovery on MMC block devices which use a different naming scheme compared to mtdblock or sd* devices. The change also adds the find applet to the ramdisk utilities so that upgrade code can rely on it. The commit is based on the initial submission by Russell Senior at http://patchwork.ozlabs.org/patch/625440/ . Signed-off-by: Russell Senior <russell@personaltelco.net> Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* x86: preserve partition table on sysupgradeJo-Philipp Wich2016-02-091-0/+1
| | | | | | | | | | | | | | With this patch sysupgrade will write directly to the partitions instead of to the main disk. The UUID is copied from the image to the MBR as well. This prevents the mbr from being completely overwritten and losing the partition table. The -p option has been added to maintain the original behavior and overwite the entire disk with the new image. Tests have been added to ensure that the image partitions match up with the active partitions. Signed-off-by: Rob Mosher <nyt-openwrt@countercultured.net> SVN-Revision: 48682
* base-files: fix sysupgrade 'wget' handling for uclient-fetchFelix Fietkau2016-01-251-3/+4
| | | | | | | | | | | | | change 48451 tried to add support for uclient-fetch by moving /usr/bin/wget to /bin/wget, but this change kept the symbolic link to /bin/busybox as install_bin creates links to param 1 the desired fix is to link to uclient-fetch to wget: install_bin /bin/uclient-fetch /bin/wget Signed-off-by: John Clark <inindev@gmail.com> SVN-Revision: 48483
* base-files: fix sysupgrade 'wget' handlingFelix Fietkau2016-01-221-1/+1
| | | | | | | | | | | with r48379 and r48386 the path of wget changed. respect that and adjust the dirname. this fixes #21680 Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com> SVN-Revision: 48451
* base-files: sysupgrade: quote source image nameJohn Crispin2015-09-141-2/+2
| | | | | | | | | | | | | | | | | | | get_image() eval a filename without quoting it, resulting in errors with filenames containing characters that need to be escaped. $ sysupgrade -T -f ./cfg\(12\).tar.gz img.bin; echo $? Image check 'platform_check_image' failed. Invalid config file. Please use only .tar.gz files 1 $ mv cfg\(12\).tar.gz cfg_12.tar.gz $ mv img\(1\).bin img.bin sysupgrade -T -f ./cfg_12.tar.gz img.bin; echo $? 0 Enclose the content of $from in double quotes. Signed-off-by: Adrien Schildknecht <adrien+dev@schischi.me> SVN-Revision: 46919
* base-files: default_do_upgrade: accept & forward image extraction commandJohn Crispin2015-06-051-2/+6
| | | | | | | | | | | get_image allows passing 2nd argument that is used in a pipe for extracting firmware from a non-native format. By accepting such command in default_do_upgrade we allow platforms to use this helper for vendor specific images. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 45900
* base-files: remove ubi toolLuka Perkov2015-05-291-1/+0
| | | | | | | | ubi tool was removed from fstools in r41128. Signed-off-by: Luka Perkov <luka@openwrt.org> SVN-Revision: 45813
* base-files: supress errors from lddJonas Gorski2014-11-191-1/+1
| | | | | | | | | | | | ldd might be called for shell scrips during sysupgrade, causing it to complain that they are not a dynamic executables. This is a harmless error, so supress it to avoid confusing about them being serious ones. Signed-off-by: Jonas Gorski <jogo@openwrt.org> SVN-Revision: 43315
* base-files: properly fix copying ld*.so with eglibcJonas Gorski2014-11-181-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r36107 ("base-files: sysupgrade fail with eglibc") tried to fix sysupgrade by changing the ld-soname to what is expected, but only fixed MIPS while breaking ARM. The underlying issue is that the ld.so name varies widely across different architectures for eglibc: eglibc-2.19-r25243$ grep -r "ld-soname :=" . | awk '{ print $3 }' | sort -u ld64.so.1 ld64.so.2 ld-linux-aarch64_be.so.1 ld-linux-aarch64.so.1 ld-linux-armhf.so.3 ld-linux-mipsn8.so.1 ld-linux.so.2 ld-linux.so.3 ld-linux-x32.so.2 ld-linux-x86-64.so.2 ld.so.1 Instead of adding each different soname to check for and copy it, replace the awk script with a sed script to extract it properly and drop the hardcoded so-name. Signed-off-by: Jonas Gorski <jogo@openwrt.org> SVN-Revision: 43295
* base-files: fix ldd definition if /usr/bin/ldd existsFelix Fietkau2014-10-191-1/+1
| | | | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 42976
* sysupgrade: Enable killing of all processes under upgradedJohn Crispin2014-07-101-12/+27
| | | | | | | | | | If the sysupgrade scripts is called under upgraded, it will not kill all other processes as it should to avoid interference by locked filesystem. This patch checks the parent and if it is upgraded, it kills all. Signed-off-by: André Valentin <avalentin@marcant.net> SVN-Revision: 41563
* base-files: fix ramfs / nand upgradeJohn Crispin2014-07-011-1/+1
| | | | | | | | /lib/{imx6,lantiq,...}.sh are needed in the ramfs for sysupgrade to work. Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 41440
* base-files: regenerate the /lib64 symlink when switching to a ramdiskJohn Crispin2014-06-201-0/+2
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 41284
* base-files: add upgraded to the list of daemons not killedJohn Crispin2014-06-191-1/+1
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 41268
* base-files: properly remove stderr from zcat/bzcatJohn Crispin2014-06-111-2/+2
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 41135
* base-files: include more ubi* tools in sysupgrade ramdiskJohn Crispin2014-06-111-1/+4
| | | | | | | | | Also add some more busybox symlinks which are useful for sysupgrade on UBI-enabled devices. Signed-off-by: Daniel Golle <daniel@makrotopia.org> SVN-Revision: 41125
* base-files: Allow installation of symlinks using RAMFS_COPY_BIN env var.John Crispin2014-06-021-1/+1
| | | | | | | | http://patchwork.openwrt.org/patch/5086/ Signed-off-by: karl.vogel@gmail.com SVN-Revision: 40943
* base-files: the ubi tol should be installed when jumping to ram_fsJohn Crispin2014-04-071-0/+1
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 40420
* base-files: make use of new fstoolsJohn Crispin2014-04-071-1/+2
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 40416
* /lib/functions.sh: move rarely used mtd and macaddr related functions to ↵Felix Fietkau2014-04-071-1/+1
| | | | | | | | /lib/functions/system.sh Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 40411
* ubi-utils: mini version of mtd-utils that only includes ubi toolsJohn Crispin2014-04-031-2/+9
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 40367
* fstools: add the new fstools packageJohn Crispin2014-03-121-0/+2
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 39895
* base-files: fix mount-utils incompatibilityJohn Crispin2013-12-271-12/+12
| | | | | | Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk> SVN-Revision: 39169
* base-files: fix whitespacesLuka Perkov2013-12-091-6/+6
| | | | | | Signed-off-by: Luka Perkov <luka@openwrt.org> SVN-Revision: 39006