Skip to content

Commit

Permalink
update 🌰
Browse files Browse the repository at this point in the history
  • Loading branch information
UriHerrera committed Jun 15, 2023
1 parent 722eebf commit 75cab3d
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 141 deletions.
92 changes: 39 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,91 +4,77 @@
![](https://raw.githubusercontent.com/Nitrux/luv-icon-theme/master/Luv/apps/64/nx-software-updater.svg)


## Introduction
# Introduction

The point of this utility is twofold, first, to be able to update the Nitrux Operating System. And second, to back up the root for rollbacks.

`nuts` targets Nitrux 2.8.0+.
The nuts utility is designed to update the Nitrux Operating System and provide a backup option for rollbacks.

> _⚠️ Important: `nuts` is intended to work exclusively in Nitrux OS, and using this utility in other distributions will break them or not work at all. Please do not open issues regarding this use case; they will be closed._

### What is `nuts` (and what it isn't)
## Requeriments

- Nitrux 2.8.0 or newer.


#### Support for Previous Releases

#### Overview
`nuts` can technically work with previous releases that use an immutable root, such as Nitrux 2.6.0, 2.6.1, 2.7.0, and 2.7.1, as long as the partition labels match the specific values (`NX_ROOT` for the root partition and `NX_HOME` for the home partition).

`nuts` is a simple (read. [KISS](https://people.apache.org/~fhanik/kiss.html)) system update and rollback utility.
To see the partition label run the command `blkid`.

`nuts` works in three steps. First by creating a backup of the current root directory using SquashFS; then, `nuts` downloads an ISO image using the BitTorrent protocol, and uses `rsync` to update the system.
# Overview

Afterward, when using `nuts` to restore a backup, `nuts` will do the exact process but use the locally generated SquashFS instead, so, no downloads.
`nuts` is a simple and minimalistic system update and rollback utility. It performs three steps:

#### What `nuts` is ✅
1. Creates a backup of the current root directory using SquashFS.
2. Downloads an ISO image using the BitTorrent protocol and updates the system using rsync.
3. When restoring a backup, `nuts` uses the locally generated SquashFS file instead of downloading.

- `nuts` is minimalistic.
- `nuts` was designed to only do what it needs to do and nothing else.
- `nuts` is a CLI utility.
- `nuts` is 100% Free (as in Freedom) Open Source Software; see [License](#licensing).
- `nuts` is written entirely in [POSIX-compliant scripting language](https://en.wikipedia.org/wiki/Shell_script#Typical_POSIX_scripting_languages).

#### What `nuts` is not ❎
#### What `nuts` is

- `nuts` is not a package manager.
- Minimalistic, focusing on necessary functionality.
- A CLI utility.
- 100% Free and Open Source Software written entirely in [POSIX-compliant scripting language](https://en.wikipedia.org/wiki/Shell_script#Typical_POSIX_scripting_languages).

#### What `nuts` is not

- A package manager.
- `nuts` does not interact with any sort of packaging format.
- `nuts` does not interact with any software "repository" either.
- `nuts` does not interact with any package manager to perform any operation.
- `nuts` is not an installer.
- An installer.
- `nuts` is inspired by the functional workflow of most Linux installers, that is, extracting a SquashFS file. However, `nuts` does not handle in any way locale configuration, user creation, partition mounts, or bootloader configuration, etc.
- `nuts` is not "only" a backup utility.
- Solely a backup utility.
- `nuts` is not designed exclusively as a backup utility in the way that other utilities like _restic_, _bup_ or filesystem-level tools like _xfsdump_ and _xfsrestore_, _btrfs-snapshot_ or _lvmcreate_ were.
- `nuts` is not a container or a virtual machine, or a utility to make Live USBs, a Linux distribution, a desktop environment, etc.; see [Overview](#overview).
- A container, virtual machine, Live USB creator, Linux distribution, or desktop environment.
- _**Note**: We don't know why anyone would think that, but one can never know, so let's clarify that._

## Usage

This utility is designed to be highly autonomous.

To use `nuts`, do the following.

Open a terminal and run one of the following commands.

### Update

```
sudo nuts update
```

* The command above will update the currently installed root using the media specified in `nuts-query` and backup the current root directory.

### Restore
```
sudo nuts restore
```

* The command above will restore the backup of the root directory generated during the update.
# Usage

### Configuration
`nuts` is designed to be highly autonomous.

This utility is not designed to be highly configurable.
### Commands:

However, `nuts` uses the file in `/etc/nuts/nuts.conf` to load some settings.
**Update**: `sudo nuts update`
- Updates the currently installed root using the specified media in nuts-query and backs up the current root directory.

### Options
**Restore**: `sudo nuts restore`
- Restores the backup of the root directory generated during the update.

This utility is not designed to be highly interactive.
### Configuration:

```
sudo nuts -h
```
`nuts` uses the file `/etc/nuts/nuts.conf` to load some settings.

* This command will display the help of `nuts`.
### Options:

`sudo nuts -h`: Displays the help of `nuts`.

# Licensing

The license used for this repository and its contents is: BSD-3-Clause.
The repository and its contents are licensed under BSD-3-Clause.

# Issues
If you find problems with the contents of this repository please create an issue.
If any problems are encountered, users can create an issue.

©2023 Nitrux Latinoamericana S.C.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
nuts (0.5.0) nitrux; urgency=medium

* The update process is now functional.

-- Uri Herrera <uri_herrera@nxos.org> Wed, 14 Jun 2023 18:41:00 -0500

nuts (0.1.6) nitrux; urgency=medium

* Fix missing functions.
Expand Down
14 changes: 10 additions & 4 deletions tmp/nuts-cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,18 @@ error() {

FILE_LIST="/tmp/nuts-cc-file.list"

# Read the file list and iterate over each line
while IFS= read -r ITEM; do
# Remove leading/trailing whitespace
ITEM="$(echo "$ITEM" | awk '{$1=$1};1')"

# Remove the item
if [[ -e "$ITEM" ]]; then
echo "Deleting: $ITEM"
rm -rf "$ITEM"
find /usr/share/locale/ -name 'calamares-python.mo' -exec rm -f {} \;
else
echo "Item not found: $ITEM"
fi
done < "$FILE_LIST"


puts_success "Success! Cleanup complete, continuing..."


Expand All @@ -85,6 +82,15 @@ puts_info "Preparing to boot new kernel and initram, continuing..."
ln -svf "$(echo /boot/vmlinuz* | tr ' ' '\n' | tail -n 1)" /vmlinuz
ln -svf "$(echo /boot/initrd* | tr ' ' '\n' | tail -n 1)" /initrd.img


# -- Clean /boot to remove older kernels.

cd /boot || exit

NEWEST_FILE=$(find . -maxdepth 1 -type f -printf "%T@ %p\n" | sort -n | tail -n1 | awk '{print $2}')

find . -maxdepth 1 -type f ! -name "$NEWEST_FILE" -delete

puts_success "Success! Ready to use newer kernel, continuing..."

# ====== END ======
59 changes: 0 additions & 59 deletions tmp/nuts-cc-file.list
Original file line number Diff line number Diff line change
Expand Up @@ -30,65 +30,6 @@
/usr/share/icons/hicolor/scalable/apps/calamares.svg
/usr/share/lintian/overrides/calamares
/usr/share/lintian/overrides/dpkg
/usr/share/locale/ar/LC_MESSAGES/calamares-python.mo
/usr/share/locale/as/LC_MESSAGES/calamares-python.mo
/usr/share/locale/ast/LC_MESSAGES/calamares-python.mo
/usr/share/locale/az/LC_MESSAGES/calamares-python.mo
/usr/share/locale/az_AZ/LC_MESSAGES/calamares-python.mo
/usr/share/locale/be/LC_MESSAGES/calamares-python.mo
/usr/share/locale/bg/LC_MESSAGES/calamares-python.mo
/usr/share/locale/bn/LC_MESSAGES/calamares-python.mo
/usr/share/locale/ca/LC_MESSAGES/calamares-python.mo
/usr/share/locale/ca@valencia/LC_MESSAGES/calamares-python.mo
/usr/share/locale/cs_CZ/LC_MESSAGES/calamares-python.mo
/usr/share/locale/da/LC_MESSAGES/calamares-python.mo
/usr/share/locale/de/LC_MESSAGES/calamares-python.mo
/usr/share/locale/el/LC_MESSAGES/calamares-python.mo
/usr/share/locale/en_GB/LC_MESSAGES/calamares-python.mo
/usr/share/locale/eo/LC_MESSAGES/calamares-python.mo
/usr/share/locale/es/LC_MESSAGES/calamares-python.mo
/usr/share/locale/es_MX/LC_MESSAGES/calamares-python.mo
/usr/share/locale/et/LC_MESSAGES/calamares-python.mo
/usr/share/locale/eu/LC_MESSAGES/calamares-python.mo
/usr/share/locale/fa/LC_MESSAGES/calamares-python.mo
/usr/share/locale/fi_FI/LC_MESSAGES/calamares-python.mo
/usr/share/locale/fr/LC_MESSAGES/calamares-python.mo
/usr/share/locale/fur/LC_MESSAGES/calamares-python.mo
/usr/share/locale/gl/LC_MESSAGES/calamares-python.mo
/usr/share/locale/he/LC_MESSAGES/calamares-python.mo
/usr/share/locale/hi/LC_MESSAGES/calamares-python.mo
/usr/share/locale/hr/LC_MESSAGES/calamares-python.mo
/usr/share/locale/hu/LC_MESSAGES/calamares-python.mo
/usr/share/locale/id/LC_MESSAGES/calamares-python.mo
/usr/share/locale/is/LC_MESSAGES/calamares-python.mo
/usr/share/locale/it_IT/LC_MESSAGES/calamares-python.mo
/usr/share/locale/ja/LC_MESSAGES/calamares-python.mo
/usr/share/locale/ko/LC_MESSAGES/calamares-python.mo
/usr/share/locale/lt/LC_MESSAGES/calamares-python.mo
/usr/share/locale/ml/LC_MESSAGES/calamares-python.mo
/usr/share/locale/mr/LC_MESSAGES/calamares-python.mo
/usr/share/locale/nb/LC_MESSAGES/calamares-python.mo
/usr/share/locale/nl/LC_MESSAGES/calamares-python.mo
/usr/share/locale/oc/LC_MESSAGES/calamares-python.mo
/usr/share/locale/pl/LC_MESSAGES/calamares-python.mo
/usr/share/locale/pt_BR/LC_MESSAGES/calamares-python.mo
/usr/share/locale/pt_PT/LC_MESSAGES/calamares-python.mo
/usr/share/locale/ro/LC_MESSAGES/calamares-python.mo
/usr/share/locale/ru/LC_MESSAGES/calamares-python.mo
/usr/share/locale/si/LC_MESSAGES/calamares-python.mo
/usr/share/locale/sk/LC_MESSAGES/calamares-python.mo
/usr/share/locale/sl/LC_MESSAGES/calamares-python.mo
/usr/share/locale/sq/LC_MESSAGES/calamares-python.mo
/usr/share/locale/sr/LC_MESSAGES/calamares-python.mo
/usr/share/locale/sr@latin/LC_MESSAGES/calamares-python.mo
/usr/share/locale/sv/LC_MESSAGES/calamares-python.mo
/usr/share/locale/tg/LC_MESSAGES/calamares-python.mo
/usr/share/locale/th/LC_MESSAGES/calamares-python.mo
/usr/share/locale/tr_TR/LC_MESSAGES/calamares-python.mo
/usr/share/locale/uk/LC_MESSAGES/calamares-python.mo
/usr/share/locale/vi/LC_MESSAGES/calamares-python.mo
/usr/share/locale/zh_CN/LC_MESSAGES/calamares-python.mo
/usr/share/locale/zh_TW/LC_MESSAGES/calamares-python.mo
/usr/share/man/man1/calamares.1.gz
/usr/share/man/man8/calamares.8.gz
/usr/share/polkit-1/actions/com.github.calamares.calamares.policy
Expand Down
33 changes: 11 additions & 22 deletions tmp/rsync-exclude.list
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
/etc/fstab
/etc/shadow
/etc/group
/etc/gshadow
/etc/subgid
/etc/subuid
/etc/sddm.conf
/usr/bin/bash
/usr/bin/mount
/proc/
/sys/
/dev/
/run/
/run/udev/
/sys/firmware/efi/efivars/
/etc/
/home/
/media/
/proc/
/run/
/sys/
/var/cache/
/var/lib/
/var/local/
/var/lock/
/var/log/
/var/mail/
/var/opt/
/var/run/
/var/spool/
/var/tmp/
/mnt/
/root/
/srv/
/tmp/
/var/
2 changes: 1 addition & 1 deletion usr/bin/nuts-crr
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ update-grub
unmount_directory() {
local DIRECTORY="$1"

# Check if the directory is already mounted
if mountpoint -q "$DIRECTORY"; then
echo "Unmounting: $DIRECTORY"
umount "$DIRECTORY"
Expand All @@ -215,6 +214,7 @@ unmount_directory "$NUTS_DIR_SQS"
unmount_directory "/home"
unmount_directory "/dev"


# -- Update GRUB.

update-grub
Expand Down
3 changes: 1 addition & 2 deletions usr/bin/nuts-cru
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ SOURCE_DIR="$NUTS_DIR_SQS"
DESTINATION_DIR="/"
EXCLUDES_FILE="/tmp/rsync-exclude.list"

RSYNC_COMMAND="rsync -av --progress --exclude-from=$EXCLUDES_FILE $SOURCE_DIR/ $DESTINATION_DIR"
RSYNC_COMMAND="rsync -aHAXr --progress --inplace --exclude-from=$EXCLUDES_FILE $SOURCE_DIR/ $DESTINATION_DIR"
eval "$RSYNC_COMMAND"

sync
Expand All @@ -296,7 +296,6 @@ update-grub
unmount_directory() {
local DIRECTORY="$1"

# Check if the directory is already mounted
if mountpoint -q "$DIRECTORY"; then
echo "Unmounting: $DIRECTORY"
umount "$DIRECTORY"
Expand Down

0 comments on commit 75cab3d

Please sign in to comment.