<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; display: inline !important; float: none;" class="">Inline</span><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">On Apr 4, 2018, at 5:28 PM, Luiz Angelo Daros de Luca <<a href="mailto:luizluca@gmail.com" class="">luizluca@gmail.com</a>> wrote:<br class=""><br class="">When '-k' is used, sysupgrade inserts into backup a new file<br class="">/etc/sysupgrade.installed which contains pkgname and<br class="">origin (rom, overlay, unknown).<br class=""><br class="">It's maily used to reinstall all extra packages:<br class=""><br class=""># opkg update<br class=""># grep "\toverlay" etc/sysupgrade.installed | cut -f1 | xargs opkg install<br class=""># rm etc/sysupgrade.installed<br class=""><br class="">Signed-off-by: Luiz Angelo Daros de Luca <<a href="mailto:luizluca@gmail.com" class="">luizluca@gmail.com</a>><br class="">---<br class="">package/base-files/files/sbin/sysupgrade | 30 ++++++++++++++++++++++++++++++<br class="">1 file changed, 30 insertions(+)<br class=""><br class="">diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade<br class="">index 01a942bac6..c5067a757b 100755<br class="">--- a/package/base-files/files/sbin/sysupgrade<br class="">+++ b/package/base-files/files/sbin/sysupgrade<br class="">@@ -11,6 +11,7 @@ export SAVE_CONFIG=1<br class="">export SAVE_OVERLAY=0<br class="">export SAVE_OVERLAY_PATH=<br class="">export SAVE_PARTITIONS=1<br class="">+export SAVE_INSTALLED_PKGS=0<br class="">export SKIP_UNCHANGED=0<br class="">export CONF_IMAGE=<br class="">export CONF_BACKUP_LIST=0<br class="">@@ -31,6 +32,7 @@ while [ -n "$1" ]; do<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>-c) export SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/etc;;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>-o) export SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/;;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>-p) export SAVE_PARTITIONS=0;;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>-k) export SAVE_INSTALLED_PKGS=1;;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>-u) export SKIP_UNCHANGED=1;;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>-b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>-r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;;<br class="">@@ -50,6 +52,7 @@ done<br class=""><br class="">export CONFFILES=/tmp/sysupgrade.conffiles<br class="">export CONF_TAR=/tmp/sysupgrade.tgz<br class="">+export INSTALLED_PACKAGES=/etc/sysupgrade.installed<br class=""><br class="">IMAGE="$1"<br class=""><br class="">@@ -67,6 +70,8 @@ upgrade-option:<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>-u skip from backup files that are equals to those in /rom<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>-n do not save configuration over reflash<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>-p do not attempt to restore the partition table after flash.<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>-k include in backup a list of current installed packages at<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> $INSTALLED_PACKAGES<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>-T | --test<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> Verify image and config .tar.gz but do not actually flash.<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>-F | --force<br class="">@@ -203,6 +208,15 @@ fi<br class=""><br class="">include /lib/upgrade<br class=""><br class="">+targz_append() {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>local tar="$1"<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>local append_tar="$2"<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>(<span class="Apple-tab-span" style="white-space: pre;"> </span>gunzip -c "$tar" | head -c -1024;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>gunzip -c $append_tar<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>) | gzip > $tar.new<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; display: inline !important; float: none;" class="">This seems a bit fragile… Isn’t there a better way to do this?</span><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>mv -f $tar.new $tar<br class="">+}<br class="">+<br class="">do_save_conffiles() {<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>local conf_tar="$1"<br class=""><br class="">@@ -219,6 +233,22 @@ do_save_conffiles() {<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" 2>/dev/null<br class=""><br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>mkdir -p /tmp/etc<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>cd /tmp/<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span># Format: pkg-name<TAB>{rom,overlay,unkown}<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span># rom is used for pkgs in /rom, even if updated later<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>find /usr/lib/opkg/info -name "*.control" \( \<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>\( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>\( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>\( -exec echo {} unknown \; \) \<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>\) | sed -e 's,.*/,,;s/\.control /\t/' > ${INSTALLED_PACKAGES:1}<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>tar c${TAR_V}zf sysupgrade.installed.packages.tgz ${INSTALLED_PACKAGES:1}<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>targz_append "$conf_tar" sysupgrade.installed.packages.tgz<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>rm -f sysupgrade.installed.packages.tgz ${INSTALLED_PACKAGES:1}<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>fi<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>rm -f "$CONFFILES"<br class="">}<br class=""><br class="">--<br class="">2.16.3</blockquote></body></html>