#!/bin/bash -e # Upgrade from eos2 to eos3 # Removes all installed legacy app bundles, # points to the latest ostree branches, # and starts the ostree upgrade process. # Requires the user to re-install any desired # apps as flatpaks from the app center # after rebooting into eos3. ARGS=$(getopt -o fsh -l "force,skip,help" -n "$0" -- "$@") eval set -- "$ARGS" usage() { cat < /dev/null)" ]; then for driver_symlink in $ecp_ppd_dir/*; do if [ ! -h $driver_symlink ]; then echo "$driver_symlink is not a symbolic link" break fi target=$(readlink $driver_symlink) if [ -z $target ]; then echo "Could not read target for symbolic link $driver_symlink" break fi if [ ! -e $target ] || [[ $target != "/opt/"* ]]; then echo "Symbolic link $driver_symlink points to invalid target" unlink $driver_symlink break fi # Found the PPD directory inside the driver's directory, now search # for the driver's top directory so that we can remove everything. driver_topdir=$target current_dir=$(dirname $target) while [ $current_dir != "/opt" ]; do driver_topdir=$current_dir current_dir=$(dirname $current_dir) done # Sanity check to make sure we're recursively removing a # a directory in /opt, not /opt itself (or anything else). # For instance: /opt/epson-inkjet-printer-201207w if [ -d $driver_topdir ] && [[ $driver_topdir == "/opt/"?* ]]; then driver_name=$(basename $driver_topdir) echo "Removing driver downloaded from OpenPrinting: $driver_name" rm -rf $driver_topdir unlink $driver_symlink fi done # Restart CUPS after removing the drivers to make sure it # picks up the changes and reflects them in the PPD database. systemctl restart cups fi # Figure out the architecture / product machine=`uname -m` case "$machine" in armv7l) arch=armhf prod=ec100 ;; x86_64) arch=amd64 prod=amd64 ;; *) echo Unexpected machine architecture $machine exit 1 ;; esac # Set up the ostree and flatpak repo config cat < /ostree/repo/config [core] repo_version=1 mode=bare [remote "eos"] url=https://ostree.endlessm.com/ostree/eos-$arch branches=os/eos/$prod/eos3; xa.disable=true [remote "eos-runtimes"] gpg-verify=true gpg-verify-summary=true url=https://ostree.endlessm.com/ostree/eos-$arch xa.title=Endless OS and Runtimes [remote "eos-apps"] gpg-verify=true gpg-verify-summary=true url=https://ostree.endlessm.com/ostree/eos-apps xa.default-branch=eos3 xa.title=Endless Applications EOF if [ -e /dev/disk/by-label/extra ]; then # Split disk image # Create the flatpak directory and repo on the secondary storage mkdir -p /var/endless-extra/flatpak ostree init --mode=bare-user --repo /var/endless-extra/flatpak/repo # Overwrite the config file # This is identical to the main ostree config, except the mode # is "bare-user", and there is no specification of the "eos" remote cat < /var/endless-extra/flatpak/repo/config [core] repo_version=1 mode=bare-user [remote "eos-runtimes"] gpg-verify=true gpg-verify-summary=true url=https://ostree.endlessm.com/ostree/eos-$arch xa.title=Endless OS and Runtimes [remote "eos-apps"] gpg-verify=true gpg-verify-summary=true url=https://ostree.endlessm.com/ostree/eos-apps xa.default-branch=eos3 xa.title=Endless Applications EOF fi # Change the refspec for the currently deployed ostree deployment=`ostree admin status | grep '* eos' | awk -F ' ' '{print $3}'` cat < /ostree/deploy/eos/deploy/$deployment.origin [origin] refspec=eos:os/eos/$prod/eos3 EOF if ! $SKIP; then update_keys # Pull eos3 ostree without static deltas in case this system is # already suffering missing ostree objects. ostree pull --repo=/ostree/repo --disable-static-deltas eos \ os/eos/$prod/eos3 # Perform the ostree upgrade # Note that if there has not been an eos3 release since # the latest eos2 release, this chronologically will appear # to ostree as a "downgrade", so we should explicitly allow it ostree admin upgrade --allow-downgrade # All done echo "Upgrade complete! Please reboot the computer to start using Endless OS 3" fi