Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Keep GitHub's language statistics to the project's own code. These folders
# hold upstream Rufus's unchanged sources and a one-off test-fixture generator.
crates/rufust-helper/assets/** linguist-vendored
scripts/fixtures/** linguist-vendored
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@ env:
jobs:
quality:
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@bc540ba06a4ccee415bb241490e0b25ee8e7d315
with:
components: rustfmt, clippy
- name: System dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libfontconfig1-dev libfreetype-dev \
scripts/ci/apt-install.sh pkg-config libfontconfig1-dev libfreetype-dev \
libxkbcommon-dev libwayland-dev libx11-dev libxcb1-dev \
desktop-file-utils appstream libxml2-utils parted dosfstools qemu-utils libnbd-bin bzip2 \
xvfb xauth xdotool x11-utils imagemagick libgl1-mesa-dri \
libxkbcommon-x11-0 libxcursor1 libx11-xcb1 libxi6 \
libwayland-client0 libwayland-egl1 libgl1 libegl1 btrfs-progs strace
- name: Version consistency
run: scripts/version.sh check
- name: Format
run: cargo fmt --all -- --check
- name: Test
Expand Down Expand Up @@ -73,6 +75,7 @@ jobs:
windows:
name: Windows
runs-on: windows-2022
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@bc540ba06a4ccee415bb241490e0b25ee8e7d315
Expand All @@ -99,6 +102,7 @@ jobs:

distro-builds:
runs-on: ubuntu-24.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
debian:
name: Debian package
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@bc540ba06a4ccee415bb241490e0b25ee8e7d315
- name: Install packaging dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
scripts/ci/apt-install.sh \
debhelper devscripts fakeroot pkg-config \
libfontconfig1-dev libfreetype-dev libxkbcommon-dev \
libwayland-dev libx11-dev libxcb1-dev
Expand Down Expand Up @@ -72,6 +72,7 @@ jobs:
fedora:
name: Fedora package
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Build and validate Fedora installer
Expand Down Expand Up @@ -129,6 +130,7 @@ jobs:
arch:
name: Arch package
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Prepare source archive
Expand Down Expand Up @@ -197,12 +199,12 @@ jobs:
appimage:
name: Portable AppImage
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Install AppImage validation tools
run: |
sudo apt-get update
sudo apt-get install -y \
scripts/ci/apt-install.sh \
appstream binutils desktop-file-utils file libxkbcommon-x11-0 \
libxml2-utils xvfb zsync
- name: Build against glibc 2.28
Expand Down Expand Up @@ -298,6 +300,7 @@ jobs:
windows:
name: Windows installer and portable executable
runs-on: windows-2022
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@bc540ba06a4ccee415bb241490e0b25ee8e7d315
Expand Down Expand Up @@ -379,6 +382,7 @@ jobs:
startsWith(github.ref, 'refs/heads/release/v')
needs: [debian, fedora, arch, appimage, windows]
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
contents: write
id-token: write
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ For Windows 10/11 (x64), pick one download and check it against `SHA256SUMS`:
- **Installer:** `rufust-*-windows-x86_64-setup.exe` installs Rufust in
Program Files with a Start menu entry and an uninstaller (Settings → Apps).
- **Portable:** run `rufust-*-windows-x86_64.exe` directly from anywhere, such
as a USB stick. Nothing is installed.
as a USB stick. Nothing is installed. To keep your settings with it, put an
empty file named `settings.conf` beside the exe; otherwise they are saved
in your Windows profile.

```powershell
Get-FileHash .\rufust-*-windows-x86_64* -Algorithm SHA256
Expand Down
47 changes: 43 additions & 4 deletions apps/rufust/src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! Preferences kept across launches as `key=value` lines in
//! `$XDG_CONFIG_HOME/rufust/settings.conf` on Linux and
//! `%APPDATA%Rufustsettings.conf` on Windows.
//! `%APPDATA%\Rufust\settings.conf` on Windows, or a `settings.conf` that already
//! sits beside `rufust.exe` (portable use).

#[cfg(windows)]
use std::path::Path;
use std::path::PathBuf;

use crate::units::{SizeUnit, SpeedUnit};
Expand Down Expand Up @@ -100,9 +103,24 @@ fn path_in(dir: &str) -> Option<PathBuf> {
if dir == LEGACY_CONFIG_DIR {
return None;
}
let base = std::env::var_os("APPDATA")
.map(PathBuf::from)
.filter(|path| path.is_absolute())?;
windows_path(
std::env::current_exe().ok().as_deref(),
std::env::var_os("APPDATA").map(PathBuf::from),
)
}

/// A `settings.conf` beside the executable makes that copy portable: it is
/// read and written there, so preferences travel with a USB stick. Without
/// one, settings live under `%APPDATA%`.
#[cfg(windows)]
fn windows_path(exe: Option<&Path>, appdata: Option<PathBuf>) -> Option<PathBuf> {
let beside = exe
.and_then(Path::parent)
.map(|folder| folder.join("settings.conf"));
if let Some(beside) = beside.filter(|path| path.is_file()) {
return Some(beside);
}
let base = appdata.filter(|path| path.is_absolute())?;
Some(base.join("Rufust").join("settings.conf"))
}

Expand Down Expand Up @@ -141,4 +159,25 @@ mod tests {
[WueOption::Regional]
);
}

#[cfg(windows)]
#[test]
fn a_settings_file_beside_the_executable_is_portable() {
let folder = std::env::temp_dir().join(format!("rufust-portable-{}", std::process::id()));
std::fs::create_dir_all(&folder).expect("folder");
let exe = folder.join("rufust.exe");
let appdata = PathBuf::from(r"C:\Users\someone\AppData\Roaming");
assert_eq!(
windows_path(Some(&exe), Some(appdata.clone())),
Some(appdata.join("Rufust").join("settings.conf"))
);
let beside = folder.join("settings.conf");
std::fs::write(&beside, "").expect("marker");
assert_eq!(
windows_path(Some(&exe), Some(appdata)),
Some(beside.clone())
);
assert_eq!(windows_path(Some(&exe), None), Some(beside));
std::fs::remove_dir_all(&folder).expect("cleanup");
}
}
6 changes: 6 additions & 0 deletions docs/PROJECT_CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ information, metadata, executable permissions, unprivileged contents, direct
version launch, extraction fallback, Xvfb GUI startup, and loader compatibility
on Debian, Fedora, and Arch.

Every copy of the version is checked against `Cargo.toml` by
`scripts/version.sh check` in CI. `scripts/version.sh bump X.Y.Z` rewrites the
plain version strings; the changelog entries (Debian, RPM, AppStream, the
"Changes in" section of `CAPABILITIES.md`, this baseline, and the release
notes) are written by hand, and the check names any that are missing.

Release publication supports a `v*` tag or a matching `release/v<PACKAGE_VERSION>`
branch. The release branch path exists so an authenticated repository agent can
publish through the reviewed workflow without locally stored GitHub credentials.
Expand Down
3 changes: 2 additions & 1 deletion docs/WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ get-info access, which needs no elevation.

- File chooser: the common Open dialog, owned by the workbench window.
- Theme: `RUFUST_THEME`, else the "app mode" (`AppsUseLightTheme`) setting.
- Settings: `%APPDATA%\Rufust\settings.conf`.
- Settings: `%APPDATA%\Rufust\settings.conf`, or a `settings.conf` that
already sits beside `rufust.exe`, which makes that copy portable.
- Regional options for the Windows User Experience dialog: the system and user
locales, display language, keyboard layout, and time zone key name, read
from Windows as upstream does.
Expand Down
4 changes: 3 additions & 1 deletion packaging/windows/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ Rufust can:
- format drives as FAT, FAT32 (any size), exFAT, NTFS, or UDF, with an
optional bad-block test.

Settings are kept in %APPDATA%\Rufust\settings.conf.
Settings are kept in %APPDATA%\Rufust\settings.conf. To keep them with a
portable copy instead, put an empty file named settings.conf next to
rufust.exe before starting it.

The executable is not code-signed yet, so Windows SmartScreen may ask you to
confirm the first launch. Verify the download against SHA256SUMS from the
Expand Down
20 changes: 20 additions & 0 deletions scripts/ci/apt-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Install apt packages on a CI runner, retrying when the mirror is unreachable.
# Usage: scripts/ci/apt-install.sh <package>...
set -euo pipefail

options=(-o Acquire::Retries=3 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30)
for attempt in 1 2 3 4 5; do
# `apt-get update` exits 0 when it only warns about unreachable indexes, so
# the install decides whether the attempt worked.
if sudo apt-get "${options[@]}" update &&
sudo apt-get "${options[@]}" install -y "$@"; then
exit 0
fi
if [ "$attempt" -lt 5 ]; then
echo "apt attempt $attempt failed; retrying in $((attempt * 30))s" >&2
sleep $((attempt * 30))
fi
done
echo "apt could not install the packages after 5 attempts" >&2
exit 1
78 changes: 78 additions & 0 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash
# Keep every copy of the release version in step with Cargo.toml.
#
# scripts/version.sh check fail if any file disagrees (CI runs this)
# scripts/version.sh bump X.Y.Z rewrite the plain version strings
#
# `bump` leaves the changelog entries to you: Debian, RPM, AppStream, the
# "Changes in" section of docs/CAPABILITIES.md, and the baseline and release
# notes. `check` then names any that are still missing.
set -euo pipefail
cd "$(dirname "$0")/.."

current() {
sed -n 's/^version = "\([0-9][0-9.]*\)"\r\{0,1\}$/\1/p' Cargo.toml | head -n 1
}

# file|extended regex that must match, with @V@ standing for the version.
entries() {
cat <<'LIST'
apps/rufust/ui/appwindow.slint|app-version: "@V@"
.github/workflows/release.yml|PACKAGE_VERSION: @V@
packaging/arch/PKGBUILD|^pkgver=@V@
packaging/rpm/rufust.spec|^Version: +@V@
packaging/windows/rufust.iss|/DVersion=@V@
docs/BUILDING.md|/DVersion=@V@
docs/BUILDING.md|rufust\.AppImage @V@
packaging/rpm/rufust.spec|^\* .* - @V@-1
packaging/debian/changelog|^rufust \(@V@-1\)
packaging/metainfo/io.github.nitrodiesel.rufust.metainfo.xml|<release version="@V@"
docs/CAPABILITIES.md|^## Changes in @V@
docs/PROJECT_CONTEXT.md|^## Current baseline: @V@
.github/workflows/release.yml|New in @V@:
LIST
}

check() {
local version failed=0 file pattern
version="$(current)"
[ -n "$version" ] || { echo "no workspace version in Cargo.toml" >&2; exit 1; }
while IFS='|' read -r file pattern; do
pattern="${pattern//@V@/${version//./\.}}"
if ! grep -Eq -- "$pattern" "$file"; then
echo "$file: nothing matches '$pattern'" >&2
failed=1
fi
done < <(entries)
# The newest changelog entries must be this version, not just mention it.
head -n 1 packaging/debian/changelog | grep -q "($version-1)" ||
{ echo "packaging/debian/changelog: newest entry is not $version-1" >&2; failed=1; }
grep -m 1 '<release version=' packaging/metainfo/io.github.nitrodiesel.rufust.metainfo.xml |
grep -q "\"$version\"" ||
{ echo "metainfo: newest release is not $version" >&2; failed=1; }
[ "$failed" -eq 0 ] || exit 1
echo "version $version is consistent"
}

bump() {
local new="$1" old
[[ "$new" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "usage: $0 bump X.Y.Z" >&2; exit 2; }
old="$(current)"
local o="${old//./\.}"
sed -i "s/^version = \"$o\"/version = \"$new\"/" Cargo.toml
sed -i "s/app-version: \"$o\"/app-version: \"$new\"/" apps/rufust/ui/appwindow.slint
sed -i "s/PACKAGE_VERSION: $o/PACKAGE_VERSION: $new/" .github/workflows/release.yml
sed -i "s/^pkgver=$o/pkgver=$new/" packaging/arch/PKGBUILD
sed -i "s/^\(Version: *\)$o/\1$new/" packaging/rpm/rufust.spec
sed -i "s|/DVersion=$o|/DVersion=$new|" packaging/windows/rufust.iss docs/BUILDING.md
sed -i "s/rufust\.AppImage $o /rufust.AppImage $new /" docs/BUILDING.md
cargo update --workspace --offline >/dev/null 2>&1 || cargo update --workspace
echo "bumped $old -> $new; now write the changelog entries:"
check || true
}

case "${1:-}" in
check) check ;;
bump) bump "${2:-}" ;;
*) echo "usage: $0 check | bump X.Y.Z" >&2; exit 2 ;;
esac