aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/sbin/sysupgrade
Commit message (Collapse)AuthorAgeFilesLines
* base-files: sysupgrade: exit if the firmware download failedPetr Štetiar2020-01-051-1/+1
| | | | | | | | | | Sysupgrade process shouldn't continue if the firmware image couldn't be downloaded. Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-December/020940.html Reported-by: Petr Novák <petrn@me.com> Signed-off-by: Petr Štetiar <ynezz@true.cz> (cherry picked from commit cf3da66d2ce11a30ae2993b56276ade10c9bddb9)
* treewide: sysupgrade: use $UPGRADE_BACKUP to check for backupRafał Miłecki2019-09-161-1/+0
| | | | | | | | 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> (cherry picked from commit a858db313687ddfa6ed1ddba76bd74844a7b89dc)
* base-files: sysupgrade: pass "backup" ubus attributeRafał Miłecki2019-09-161-0/+3
| | | | | | | | | This explicitly tells procd what backup file should be used during sysupgrade (if any). It's much more generic this way compared to the magic /tmp/sysupgrade.tgz file that had to be created before a call. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit c5223b26a40ae61fc7750bf865464048af328ab1)
* base-files: pass "force" parameter to the "sysupgrade" callRafał Miłecki2019-09-041-0/+3
| | | | | | | | This makes sysupgrade work with the most recent procd that validates firmware before proceeding. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit b71962da16c2e2b93d633d7bde1436b3da2bf740)
* base-files: use JSON for storing firmware validation infoRafał Miłecki2019-09-041-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far firmware validation result was binary limited: it was either successful or not. That meant various limitations, e.g.: 1) Lack of proper feedback on validation problems 2) No way of marking firmware as totally broken (impossible to install) This change introduces JSON for storing detailed validation info. It provides a list of performed validation tests and their results. It allows marking firmware as non-forceable (broken image that can't be even forced to install). Example: { "tests": { "fwtool_signature": true, "fwtool_device_match": true }, "valid": true, "forceable": true } Implementation is based on *internal* check_image bash script that: 1) Uses existing validation functions 2) Provides helpers for setting extra validation info This allows e.g. platform_check_image() to call notify_check_broken() when needed & prevent user from bricking a device. Right now the new JSON info is used by /sbin/sysupgrade only. It still doesn't make use of "forceable" as that is planned for later development. Further plans for this feature are: 1) Expose firmware validation using some new ubus method 2) Move validation step from /sbin/sysupgrade into "sysupgrade" ubus method so: a) It's possible to safely sysupgrade using ubus only b) /sbin/sysupgrade can be more like just a CLI Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit f522047958f99ab7b506ec550f796c0460af1a85)
* treewide: sysupgrade: pass "save_partitions" option to the "sysupgrade" methodRafał Miłecki2019-09-041-7/+2
| | | | | | | | This explicitly lets stage2 know if partitions should be preserved. No more "touch /tmp/sysupgrade.always.overwrite.bootdisk.partmap" hack. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit b6f4cd57e19a8cfcd9ff52582b65164ce6213c3d)
* base-files: pass "save_config" option to the "sysupgrade" methodRafał Miłecki2019-09-041-1/+4
| | | | | | | This explicitly lets stage2 know if config should be preserved. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit b534ba96110012d2697d19d71b7dcd60bd4cd375)
* base-files: don't set ARGV and ARGCRafał Miłecki2019-09-041-3/+0
| | | | | | | Those are not used by any image check function anymore. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit 3f4c785a6bbde87296e362c315f10b55c98843e3)
* base-files: move stage2 upgrade to separated fileRafał Miłecki2019-09-041-1/+1
| | | | | | | | | | 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> (cherry picked from commit f7edd94a6588aa6a3e2e7a72410a34392a9fbe78)
* base-files: sysupgrade: support additional mtd optionsDavid Bauer2019-01-261-0/+1
| | | | | | | | | | 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: add sysupgrade -k to save list of pkgsLuiz Angelo Daros de Luca2018-12-091-1/+35
| | | | | | | | | | | | | | When '-k' is used, sysupgrade inserts into backup a new file /etc/backup/installed_packages.txt which contains pkgname and origin (rom, overlay, unknown) without touching rootfs. It's mainly used to reinstall all extra packages: # opkg update # grep "\toverlay" /etc/backup/installed_packages.txt | cut -f1 | xargs -r opkg install # rm /etc/backup/installed_packages.txt Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
* base-files: add sysupgrade -o to save all overlay filesLuiz Angelo Daros de Luca2018-12-091-4/+48
| | | | | | | | | | | Add sysupgrade '-o' option in order to include all overlay files in backup, except for those that are from packages but including files listed in conffiles, sysupgrade.conf or /lib/upgrade/keep.d. With '-u' option, it will skip files equals to /rom and conffiles that were not changed. Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
* base-files: add sysupgrade -u to skip unchanged filesLuiz Angelo Daros de Luca2018-12-091-8/+19
| | | | | | | | | | | With '-u', for a file /aaa/bbb/ccc enlisted for backup, it will only get into backup if /rom/aaa/bbb/ccc does not exist or /aaa/bbb/ccc is different from /rom/aaa/bbb/ccc. It also works with '-c', but only effective for files touched but not modified. Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
* base-files: minor cleanups on sysupgradeLuiz Angelo Daros de Luca2018-12-091-16/+17
| | | | | | | | | | | | | Renamed add_uci_conffiles to add_conffiles as it includes any conffiles listed, not only UCI ones. Make do_save_conffiles arg mandatory Allow other options after -l (like -c) Do not use stdout for error messages (fixes backup to stdout) Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
* base-files: sysupgrade: Allow downloading of firmware images using HTTPSPetr Štetiar2018-11-251-1/+2
| | | | | | Currently it's only possible to download images over HTTP. Signed-off-by: Petr Štetiar <ynezz@true.cz>
* base-files: introduce sysupgrade signature chain verificationDaniel Golle2018-08-081-1/+1
| | | | | | | | | Verify ucert signature chains in sysupgrade images in case ucert is installed and $CHECK_IMAGE_SIGNARURE = 1. Also make sure ucert host binary is present and generate a self-signed ucert in case $TOPDIR/key-build.ucert is missing. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: sysupgrade: abort if config backup failsAndreas Ziegler2018-08-061-0/+5
| | | | | | | Sysupgrade shouldn't proceed, if the backup of the configuration fails because tar (or gzip) exit with a non-zero code. Signed-off-by: Andreas Ziegler <dev@andreas-ziegler.de>
* base-files: drop fwtool_pre_upgradeJohn Crispin2018-07-301-3/+0
| | | | | | | this feature has never worked, the fw image name was not passed and the -t parameter was missing in the tool invocation. drop the feature. Signed-off-by: John Crispin <john@phrozen.org>
* basefiles: Reword sysupgrade messageKevin Darbyshire-Bryant2018-07-081-1/+1
| | | | | | sysupgrade 'upgrade' message more verbose than needs be. Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
* base-files: sysupgrade: do not rely on opkg to list changed conffilesMatthias Schiffer2018-03-071-1/+20
| | | | | | | Many packages use the opkg conffiles field to list configuration files that are to be retained on upgrades. Make this work on systems without opkg. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: sysupgrade: correct command help textKevin Darbyshire-Bryant2018-01-121-1/+0
| | | | | | | | | | Commit 30f61a34b4cfd2c676fea4a919e089d6a77254e9 claimed to drop -d & -p options. In reality only -d was dropped. Update command help text to reflect that -d is no longer a supported option. Fixes FS#1187 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
* base-files: fix sysupgrade -b/-l when -c is usedLuiz Angelo Daros de Luca2017-12-141-10/+11
| | | | | | | | | | | | | Since /overlay/upper appeared, -b ignored -c silently (cause it was still checking for /overlay/etc). Now, if /overlay/upper is absent, sysupgrade -c will fail and exit verbosely. Fix -l to consider -c (it never did). Clean up to always use /overlay/upper/xxx instead of still checking for /overlay/xxx. Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
* base-files: automatically handle paths and symlinks for RAMFS_COPY_BINMatthias Schiffer2017-07-111-2/+0
| | | | | | | | | | | | 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: add support for staged sysupgrades from failsafe modeMatthias Schiffer2017-05-291-5/+13
| | | | Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* base-files: sysupgrade cleanupMatthias Schiffer2017-05-291-2/+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-31/+46
| | | | | | | | | | | 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>
* Revert "sysupgrade: run only one instance at a time."Jo-Philipp Wich2017-05-261-14/+0
| | | | | | | | | | | | | This reverts commit e96a9a9af82c00dcce606a84a7bb87a00411385d. The change breaks sysupgrade through LuCI and two-stage sysupgrade on NAND targets. There is also a mismatch of file paths in lock and unlock operations. This commit was apparently neither properly tested, nor reviewed, so drop it for now. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* sysupgrade: run only one instance at a time.Kenneth Johansson2017-05-251-0/+14
| | | | | | | Things do not work well if running multiple instances of upgrade at the same time. Signed-off-by: Kenneth Johansson <kenneth.johansson@inteno.se>
* base-files: validate metadata of sysupgrade imagesFelix Fietkau2016-11-191-1/+2
| | | | | | | | | | | Use fwtool to extract it, only require metadata to be present if the platform sysupgrade script sets REQUIRE_IMAGE_METADATA=1 Image metadata is in JSON format and contains a list of supported devices, along with version information that could be displayed by a UI later before the actual upgrade happens. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* x86: preserve partition table on sysupgradeJo-Philipp Wich2016-02-091-0/+3
| | | | | | | | | | | | | | 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 overlay savingJo-Philipp Wich2016-01-171-0/+1
| | | | | | | | | | A previous change to sysupgrade moved the overlay files into upper/ The -c switch generates a list of files to backup, but the sed calls did not take this into consideration. Signed-off-by: Rob Mosher <nyt-openwrt@countercultured.net> SVN-Revision: 48281
* base-files: add support for platform_pre_upgrade functionJohn Crispin2015-04-091-0/+8
| | | | | | | | | | | | | | | | Current NAND sysupgrade process is a bit hard to follow due to the way of triggering stage1. Currently this is done by leaving a /mark/ in the form of /tmp/sysupgrade-nand-path during nand_do_platform_check. Existence of this mark stops standard sysupgrade process (as the result of sysupgrade_pre_upgrade exit). This may be a bit misleading. Proposed solution adds a new function that will allow platform.sh trigger NAND sysupgrade consciously. This will also allow cleaning nand_do_platform_check limiting it to just checking the image. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 45338
* fix sysupgrade on overlayfs v23+Imre Kaloz2014-11-241-1/+6
| | | | | | Signed-off-by: Imre Kaloz <kaloz@openwrt.org> SVN-Revision: 43365
* sysupgrade: preserve symlinks in backupsJohn Crispin2014-10-061-2/+2
| | | | | | Signed-off-by: Catalin Patulea <catalinp@google.com> SVN-Revision: 42783
* procd: various cleanups to /lib/upgrade/nand.shJohn Crispin2014-06-161-1/+1
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 41222
* base-files: add an ugly hack for nand to sysupgradeJohn Crispin2014-06-111-0/+2
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 41126
* /lib/functions.sh: move rarely used mtd and macaddr related functions to ↵Felix Fietkau2014-04-071-0/+1
| | | | | | | | /lib/functions/system.sh Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 40411
* sysupgrade: do not kill any processes in failsafeJohn Crispin2014-01-171-3/+5
| | | | | | | | sysugrade killed the lock causing failsafe to stop Signed-off-by: Alexander Couzens <lynxis@fe80.eu> SVN-Revision: 39318
* base-files: fix whitespacesLuka Perkov2013-12-091-1/+1
| | | | | | Signed-off-by: Luka Perkov <luka@openwrt.org> SVN-Revision: 39006
* ar71xx: Unifi AP Pro sysupgrade patchFelix Fietkau2013-11-141-0/+1
| | | | | | | | | | | | | | | | | | The current implementation of mtd will not append the backup file created by sysupgrade to the correct partition, as mtd will append the data to first jffs2 partition it finds. As the kernel is also stored on a jffs2 partition (which resides before the overlay partition), the data will be appended to this partition. To fix this problem, a new option -s <number> skip the first n bytes when appending data to the jffs2 partiton, defaults to "0" is added to mtd. Signed-off-by: Peter Wagner <tripolar@gmx.at> SVN-Revision: 38807
* base-files: implement -l (--list-backup) sysupgrade parameter to list the ↵Jo-Philipp Wich2013-07-311-0/+14
| | | | | | files that would be backed up SVN-Revision: 37627
* base-files: abort sysupgrade if file specified with --restore-config is not ↵Jo-Philipp Wich2013-07-311-1/+6
| | | | | | found SVN-Revision: 37624
* base-files: implement -T (--test) sysupgrade parameter to verify image ↵Jo-Philipp Wich2013-07-301-1/+9
| | | | | | without actually flashing it SVN-Revision: 37620
* sysupgrade: create state file so procd knows when a sysupgrade is in progressJohn Crispin2013-06-101-0/+1
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 36893
* mount_root: prepare base-filesJohn Crispin2013-04-251-0/+2
| | | | | | Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 36429
* sysupgrade: clarify online helpJo-Philipp Wich2013-01-021-12/+15
| | | | | | | | Fixes #12346. Signed-off-by: Paul Fertser <fercerpav@gmail.com> SVN-Revision: 34975
* sysupgrade: do not require an extra argument after --restore-backupJo-Philipp Wich2013-01-021-6/+7
| | | | | | | | | | | Neither --create-backup nor --restore-backup need an image name (following the backup filename). Treat them in uniform way. Mostly fixes #12346. Signed-off-by: Paul Fertser <fercerpav@gmail.com> SVN-Revision: 34974
* base-files: provide a sysupgrade -r (--restore-backup) option as convenience ↵Jo-Philipp Wich2012-08-121-0/+12
| | | | | | wrapper for tar -C / -x(v)zf SVN-Revision: 33147
* base-files: fix option parsing of -F/--force parameterJo-Philipp Wich2012-08-091-1/+1
| | | | SVN-Revision: 33075
* /etc/functions.sh => /lib/functions.shJo-Philipp Wich2012-06-051-2/+2
| | | | SVN-Revision: 32062