From 4da836c535da16cc834f1d4cb0ae0b38e988ef2f Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 10:05:25 +0200 Subject: [PATCH 01/10] Working state, all from crates.io --- Cargo.toml | 1 - src/main.rs | 21 +++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5bf9c83..df9b4ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" description = "A simple demonstration of the Iced GUI library." license = "MIT" -#license-file = "LICENSE.txt" repository = "no" # This application was created and tested with Rust version 1.81.0-nightly diff --git a/src/main.rs b/src/main.rs index eac61be..375c709 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use race::Race; use iced::widget::{button, column, combo_box, row, text, Column, ComboBox, Text}; use iced::{Alignment, Padding}; +use iced::{Element, Sandbox}; /// Represents the state of our application and handles /// message matching and updating the state accordingly. @@ -36,7 +37,9 @@ enum Command { Closed, } -impl State { +impl Sandbox for State { + type Message = Command; + // Constructor for the state, nothing special here. fn new() -> Self { Self { @@ -47,6 +50,10 @@ impl State { } } + fn title(&self) -> String { + String::from("Test Example") + } + // On each update, we recieve a command and update the state accordingly. fn update(&mut self, command: Command) { match command { @@ -60,7 +67,7 @@ impl State { // Called every frame to render the user interface. // Changes to the state are reflected here. - fn view(&self) -> Column { + fn view(&self) -> Element { // Our combo box let combo_box: ComboBox = combo_box::ComboBox::new( &self.races, @@ -93,14 +100,16 @@ impl State { .align_items(Alignment::Start) .spacing(10) .width(iced::Length::Fill) + .into() } } fn main() { // Iced::run is an entry point for the application. // It may fail so we match on the result. - match iced::run("Test Example", State::update, State::view) { - Ok(_) => {} - Err(error) => eprintln!("Error: {}", error), - } + // match iced::run("Test Example", State::update, State::view) { + // Ok(_) => {} + // Err(error) => eprintln!("Error: {}", error), + // } + State::run(iced::Settings::default()); } From c2e9464a061305ba6e34d74a454fa4d21595361d Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 10:08:27 +0200 Subject: [PATCH 02/10] Working RPM build --- SolutionTM.spec | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ build_rpm.sh | 35 +++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 SolutionTM.spec create mode 100755 build_rpm.sh diff --git a/SolutionTM.spec b/SolutionTM.spec new file mode 100644 index 0000000..8a4796a --- /dev/null +++ b/SolutionTM.spec @@ -0,0 +1,56 @@ +# Generated by rust2rpm 26 +%bcond_without check + +# prevent library files from being installed +%global cargo_install_lib 0 + +%global crate SolutionTM + +Name: SolutionTM +Version: 0.1.0 +Release: %autorelease +Summary: Simple demonstration of the Iced GUI library + +SourceLicense: MIT +# FIXME: paste output of %%cargo_license_summary here +License: MIT +# LICENSE.dependencies contains a full license breakdown + +URL: no +Source: %{crate}-%{version}.tar.gz +Source: %{crate}-%{version}-vendor.tar.gz + +BuildRequires: cargo-rpm-macros >= 26 +BuildRequires: cargo >= 1.78 + +%global _description %{expand: +A simple demonstration of the Iced GUI library.} + +%description %{_description} + +%prep +%autosetup -n %{crate}-%{version} -p1 -a1 +%cargo_prep -v vendor + +%build +%cargo_build +%{cargo_license_summary} +%{cargo_license} > LICENSE.dependencies +%{cargo_vendor_manifest} + +%install +%cargo_install + +%if %{with check} +%check +%cargo_test +%endif + +%files +%license LICENCE.txt +%license LICENSE.dependencies +%license cargo-vendor.txt +%{_bindir}/SolutionTM + +%changelog +%autochangelog diff --git a/build_rpm.sh b/build_rpm.sh new file mode 100755 index 0000000..22084a6 --- /dev/null +++ b/build_rpm.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# This is a simple script to build an RPM package from a spec file. + +# We need to install the required dependencies to build RPM packages. +# We also need to set up the RPM build tree: +# +# $ sudo dnf install rpm-build rpmdevtools dnf-plugins-core +# $ rpmdev-setuptree +# +# To install the builddeps: +# +# $ sudo dnf builddep SolutionTM.spec + +version=0.1.0 +name=SolutionTM + +source_tar=$name-$version.tar.gz +vendor_tar=$name-$version-vendor.tar.gz + +# First, we need a tarball of the source code in this very repo. +git archive --format=tar.gz --prefix=$name-$version/ -o SolutionTM-$version.tar.gz HEAD + +# If we want an unclean build, comment out the above line and use the following instead. +# git ls-files | tar --transform='s,^,$name-$version/,' -T - -czf $source_tar + +# Then we need a vendor tarball of the dependencies. +cargo vendor --versioned-dirs --offline vendor +tar -cvzf $vendor_tar vendor + +# Then we move the tarball to the SOURCES directory. +mv $source_tar ~/rpmbuild/SOURCES/ +mv $vendor_tar ~/rpmbuild/SOURCES/ + +rpmbuild -ba $name.spec \ No newline at end of file From 88cfe7d8ba15df060527922baa2e642d1e6fc594 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 12:07:26 +0200 Subject: [PATCH 03/10] Containerignore --- .containerignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .containerignore diff --git a/.containerignore b/.containerignore new file mode 100644 index 0000000..e147e34 --- /dev/null +++ b/.containerignore @@ -0,0 +1,3 @@ +vendor +target +rpmbuild \ No newline at end of file From 75a1bd2f3d2f5bd4a5c6c1b3354719c7f613b791 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 12:08:30 +0200 Subject: [PATCH 04/10] Containerfile --- Containerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Containerfile diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..7263e92 --- /dev/null +++ b/Containerfile @@ -0,0 +1,15 @@ +# This image is used for building the RPMs for SolutionTM + +FROM fedora:40 as build + +# Some general tools used for RPM building +RUN dnf install rpm-build rpmdevtools dnf-plugins-core git -y +RUN rpmdev-setuptree + +# Get the build deps +ADD ./SolutionTM.spec ./ +RUN dnf builddep ./SolutionTM.spec -y + +# Where the source will be mounted +RUN mkdir /source +WORKDIR /source \ No newline at end of file From a97604e18e16764b12517c23ff3e5541730db476 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 12:08:58 +0200 Subject: [PATCH 05/10] Podman rpm build convenience script --- build_podman.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 build_podman.sh diff --git a/build_podman.sh b/build_podman.sh new file mode 100755 index 0000000..eed885d --- /dev/null +++ b/build_podman.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# First we build the 'Containerfile' for podman +podman build -t solutiontm:latest -f Containerfile || exit 1 + +# Run it, mount repo as /source and execute "bash build_rpm.sh" +podman run -i -v $(pwd):/source:Z solutiontm:latest bash build_rpm.sh || exit 1 \ No newline at end of file From 3b63d4fe6b829c653c19db22008a9387a97826a6 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 12:09:07 +0200 Subject: [PATCH 06/10] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2c78e12..4df31e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target vendor +rpmbuild *.tar.* From a262510dc7981dc2cbab034f161f7e67980abe3b Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 12:09:24 +0200 Subject: [PATCH 07/10] Currently unused set_versions.sh script --- set_versions.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 set_versions.sh diff --git a/set_versions.sh b/set_versions.sh new file mode 100755 index 0000000..df1e4bc --- /dev/null +++ b/set_versions.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Currently not used + +$name=SolutionTM +$version=0.1.0 + +# If git is unclean, exit +if ! git diff-index --quiet HEAD --; then + echo "Git is unclean. Please commit your changes before building the RPM package." + exit 1 +fi + +# These should all set the first occurrence of the +# version number in the respective files. + +# Set the version number in the spec file. +sed -i "0,/Version: .*/s/Version: .*/Version: $version/" $name.spec + +# Set the version number in the Cargo.toml file. +sed -i "0,/version = \".*\"/s/version = \".*\"/version = \"$version\"/" Cargo.toml + +# Set the version number in the Cargo.lock file. +sed -i "0,/version = \".*\"/s/version = \".*\"/version = \"$version\"/" Cargo.lock + +git diff \ No newline at end of file From 368f29324a1a37015c90094e0205d791a9bca9db Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 12:10:06 +0200 Subject: [PATCH 08/10] build_rpm now uses local rpmbuild directory --- build_rpm.sh | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/build_rpm.sh b/build_rpm.sh index 22084a6..4352357 100755 --- a/build_rpm.sh +++ b/build_rpm.sh @@ -15,6 +15,29 @@ version=0.1.0 name=SolutionTM +rpmbuild=$PWD/rpmbuild +mkdir -p $rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + +echo "Building RPM package for $name version $version." + +# Check so that all versions are coherent + +grep -q "Version:.*$version" $name.spec +if [ $? -eq 0 ]; then + echo "Version number in spec file is $version." +else + echo "Version number in spec file is not $version. Exiting." + exit 1 +fi + +grep -q "version = \"$version\"" Cargo.toml +if [ $? -eq 0 ]; then + echo "Version number in Cargo.toml is $version." +else + echo "Version number in Cargo.toml is not $version. Exiting." + exit 1 +fi + source_tar=$name-$version.tar.gz vendor_tar=$name-$version-vendor.tar.gz @@ -25,11 +48,11 @@ git archive --format=tar.gz --prefix=$name-$version/ -o SolutionTM-$version.tar. # git ls-files | tar --transform='s,^,$name-$version/,' -T - -czf $source_tar # Then we need a vendor tarball of the dependencies. -cargo vendor --versioned-dirs --offline vendor +cargo vendor --versioned-dirs vendor tar -cvzf $vendor_tar vendor # Then we move the tarball to the SOURCES directory. -mv $source_tar ~/rpmbuild/SOURCES/ -mv $vendor_tar ~/rpmbuild/SOURCES/ +mv $source_tar $rpmbuild/SOURCES/ +mv $vendor_tar $rpmbuild/SOURCES/ -rpmbuild -ba $name.spec \ No newline at end of file +rpmbuild --define "_topdir $rpmbuild" -ba $name.spec \ No newline at end of file From abac34fa2ff0cd63ce47ddb1d608c6ed2d1bb6ae Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 13:16:17 +0200 Subject: [PATCH 09/10] Background compilation/rpm build with podman --- build_podman.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_podman.sh b/build_podman.sh index eed885d..f8c4753 100755 --- a/build_podman.sh +++ b/build_podman.sh @@ -4,4 +4,5 @@ podman build -t solutiontm:latest -f Containerfile || exit 1 # Run it, mount repo as /source and execute "bash build_rpm.sh" -podman run -i -v $(pwd):/source:Z solutiontm:latest bash build_rpm.sh || exit 1 \ No newline at end of file +podman run -d -v $(pwd):/source:Z -n rpmbuild solutiontm:latest bash build_rpm.sh || exit 1 +echo "Continuing build in background..." From bdc7b77eaecbd64bf78cd805af999e16a862a8ff Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Mon, 10 Jun 2024 13:16:39 +0200 Subject: [PATCH 10/10] Typos and substituting variable names in build.rpm.sh --- build_rpm.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build_rpm.sh b/build_rpm.sh index 4352357..0ed40bc 100755 --- a/build_rpm.sh +++ b/build_rpm.sh @@ -41,11 +41,14 @@ fi source_tar=$name-$version.tar.gz vendor_tar=$name-$version-vendor.tar.gz +echo "Building source tarball $source_tar." +echo "Building vendor tarball $vendor_tar." + # First, we need a tarball of the source code in this very repo. -git archive --format=tar.gz --prefix=$name-$version/ -o SolutionTM-$version.tar.gz HEAD +git archive --format=tar.gz --prefix=$name-$version/ -o $source_tar HEAD # If we want an unclean build, comment out the above line and use the following instead. -# git ls-files | tar --transform='s,^,$name-$version/,' -T - -czf $source_tar +# git ls-files | tar --transform="s,^,$name-$version/," -T - -czf $source_tar # Then we need a vendor tarball of the dependencies. cargo vendor --versioned-dirs vendor