Commit Graph

75 Commits (438dcbfe74a6da1a8949d8fb785092d934499b60)

Author SHA1 Message Date
Matthias Schiffer 438dcbfe74
base-files: automatically handle paths and symlinks for RAMFS_COPY_BIN
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>
7 years ago
Matthias Schiffer 7a29e44f90
base-files: upgrade: correctly handle nand_do_upgrade argument passed from preupgrade
Fixes: 30f61a34b4 "base-files: always use staged sysupgrade"
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
7 years ago
Matthias Schiffer b2adb9a7b5
base-files: sysupgrade cleanup
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>
7 years ago
Matthias Schiffer 30f61a34b4
base-files: always use staged sysupgrade
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>
7 years ago
Felix Fietkau 7304510392 base-files: save /bin/mknod for sysupgrade
It is used on NAND devices in case hotplug is too slow

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years ago
Yousong Zhou 6f61d8511e base-files: export x86 platform upgrade functions to common.sh
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
7 years ago
André Valentin 783875f18b package/basefiles: add mkfs.ext4 and losetup binaries to ramfs list
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>
8 years ago
Mathias Kresin 3004298e62 sysupgrade: unmount filesystems before reboot
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>
8 years ago
Conn O'Griofa e1406cd31a base-files: sysupgrade: fix pseudobridge upgrades
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>
8 years ago
Jo-Philipp Wich 1012701014 x86: generalize partition discovery for sysupgrade
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>
8 years ago
Jo-Philipp Wich 4aeeead303 x86: preserve partition table on sysupgrade
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
8 years ago
Felix Fietkau b7ab6c66cc base-files: fix sysupgrade 'wget' handling for uclient-fetch
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
8 years ago
Felix Fietkau f57419d26e base-files: fix sysupgrade 'wget' handling
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
8 years ago
John Crispin 4ef319fad2 base-files: sysupgrade: quote source image name
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
9 years ago
John Crispin f57076956e base-files: default_do_upgrade: accept & forward image extraction command
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
9 years ago
Luka Perkov 0a4bcd5be6 base-files: remove ubi tool
ubi tool was removed from fstools in r41128.

Signed-off-by: Luka Perkov <luka@openwrt.org>

SVN-Revision: 45813
9 years ago
Jonas Gorski 02c6798a0d base-files: supress errors from ldd
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
10 years ago
Jonas Gorski 2e95b1fda7 base-files: properly fix copying ld*.so with eglibc
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
10 years ago
Felix Fietkau 0ef474a118 base-files: fix ldd definition if /usr/bin/ldd exists
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42976
10 years ago
John Crispin be26421f45 sysupgrade: Enable killing of all processes under upgraded
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
10 years ago
John Crispin 66ae4803e2 base-files: fix ramfs / nand upgrade
/lib/{imx6,lantiq,...}.sh are needed in the ramfs for sysupgrade to work.

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41440
10 years ago
John Crispin 09273f5c0a base-files: regenerate the /lib64 symlink when switching to a ramdisk
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41284
10 years ago
John Crispin 4b1c48bc93 base-files: add upgraded to the list of daemons not killed
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41268
10 years ago
John Crispin bedd6f44a5 base-files: properly remove stderr from zcat/bzcat
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41135
10 years ago
John Crispin e73538ba56 base-files: include more ubi* tools in sysupgrade ramdisk
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
10 years ago
John Crispin 0de0310a9c base-files: Allow installation of symlinks using RAMFS_COPY_BIN env var.
http://patchwork.openwrt.org/patch/5086/

Signed-off-by: karl.vogel@gmail.com

SVN-Revision: 40943
10 years ago
John Crispin 665d39f698 base-files: the ubi tol should be installed when jumping to ram_fs
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 40420
10 years ago
John Crispin 1d5ac95850 base-files: make use of new fstools
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 40416
10 years ago
Felix Fietkau 4a9ea80ef0 /lib/functions.sh: move rarely used mtd and macaddr related functions to /lib/functions/system.sh
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 40411
10 years ago
John Crispin 08b4924401 ubi-utils: mini version of mtd-utils that only includes ubi tools
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 40367
10 years ago
John Crispin 0dc9d8d6ff fstools: add the new fstools package
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 39895
10 years ago
John Crispin 834204bda6 base-files: fix mount-utils incompatibility
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>

SVN-Revision: 39169
11 years ago
Luka Perkov 3ceb6b3274 base-files: fix whitespaces
Signed-off-by: Luka Perkov <luka@openwrt.org>

SVN-Revision: 39006
11 years ago
Felix Fietkau ff17114ba1 ar71xx: Unifi AP Pro sysupgrade patch
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
11 years ago
Hauke Mehrtens 0d82bbb1fb base-files: don't kill nas for sysupgrade
Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>

SVN-Revision: 38766
11 years ago
Felix Fietkau b95bdc8ab5 kernel/base-files: clean up old code related to refreshing mtd partitions, it is no longer used anywhere
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37282
11 years ago
John Crispin c7c243669c sysupgrade: fixes broken pipe error during sysupgade
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 36548
11 years ago
Florian Fainelli 3810cc0f46 base-files: sysupgrade fail with eglibc
With eglibc, "ldd busybox" give us
    libcrypt.so.1 => /lib/libcrypt.so.1 (0x774be000)
    libm.so.6 => /lib/libm.so.6 (0x773e4000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x773c0000)
    libc.so.6 => /lib/libc.so.6 (0x77276000)
    /lib/ld.so.1 (0x774fe000)

Thus /lib/ld.so.1 is not printed by the libs fonction and isn't copied to the 'new' root before pivot root
libs() { ldd $* | awk '{print $3}'; }
https://dev.openwrt.org/browser/trunk/package/base-files/files/lib/upgrade/common.sh

With uclibc the last line of "ldd busybox" is
    ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0x77ada000)

Don't know for musl!

This patch replace https://dev.openwrt.org/changeset/19167, as glibc is gone
The other way around is to rework libs()

Please apply the fix (mine or another) on trunk and AA
Might fix https://dev.openwrt.org/ticket/12273

Signed-off-by: Etienne CHAMPETIER <etienne.champetier@free.fr>
Signed-off-by: Florian Fainelli <florian@openwrt.org>

SVN-Revision: 36107
11 years ago
John Crispin ada74b8732 sysupgrade was broken as procd was getting killed
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 36031
11 years ago
John Crispin f43b7934d2 make basefiles aware of procd
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 36003
11 years ago
Mirko Vogt 4cca5cd4fd hot-fix nameclash in sysupgrade: rename pivot() to supivot() in sysupgrade
Sysupgrade defines its very own pivot() function.
Prior merging boot.sh and functions.sh sysupgrade just included boot.sh,
now it includes functions.sh which defines pivot() as well, however
slightly different which causes sysupgrade to fail.

This is a hot-fix to unbreak sysupgrade, however those two pivot()
functions should actually get merged.

SVN-Revision: 34815
12 years ago
Mirko Vogt 439a869090 Do not overload mount-call - trying to reduce confusion
The behaviour of calling 'mount' differed depending on whether it called
the busybox-mount, the mount of util-linux, the mount defined in
/lib/functions.sh and /lib/functions/boot.sh

/etc/preinit even included /lib/functions.sh and /lib/functions/boot.sh,
both re-defining 'mount'.

SVN-Revision: 34792
12 years ago
Jo-Philipp Wich ff3161a6c4 base-files: ensure that /sys is available during sysupgrade, some essential services like om-watchdog need it
SVN-Revision: 32587
12 years ago
Jo-Philipp Wich 9ae901445b /etc/functions.sh => /lib/functions.sh
SVN-Revision: 32062
12 years ago
Felix Fietkau 166db84309 base-files: kill ubusd and udhcpc on sysupgrade as well
SVN-Revision: 31852
12 years ago
Felix Fietkau 5d6628a88c base-files: allow sysupgrade to kill netifd, fixes pppd shutdown on upgrade
SVN-Revision: 31851
12 years ago
Gabor Juhos 6aec1d72c2 package/base-files: copy /lib/functions.sh to the ramfs on sysupgrade
SVN-Revision: 31842
12 years ago
Jo-Philipp Wich 6d80ce78f1 base-files: rewrite killing of nonessential services to not rely on top, use the proc filesystem only
SVN-Revision: 29187
13 years ago
Jo-Philipp Wich 7e3b6aa1f1 base-files: do not kill udhcpc on sysupgrade, it will tear down the interface if terminated
SVN-Revision: 28863
13 years ago
Jo-Philipp Wich daca6a6a97 base-files: do not assume that "top" is busybox' top, but try to call the applet explicitely
SVN-Revision: 28862
13 years ago