From 571328c925ea0a532a3f2142d5809ab6a56d9962 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Sat, 1 Jun 2024 15:46:11 +0200 Subject: [PATCH 1/2] Run all tests --- .gitignore | 4 ++ .packit.yaml | 22 ++++++----- rust-atuin.spec => atuin.spec | 73 +++++++++++++++++++---------------- rust2rpm.toml | 29 +++++++++----- 4 files changed, 77 insertions(+), 51 deletions(-) create mode 100644 .gitignore rename rust-atuin.spec => atuin.spec (61%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..469552a --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.src.rpm +atuin-*/ +*.tar.gz +*.tar.xz diff --git a/.packit.yaml b/.packit.yaml index 68c0e79..aea511a 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -1,18 +1,22 @@ packages: atuin: - specfile_path: rust-atuin.spec - files_to_sync: - - rust-atuin.spec - - .packit.yaml + specfile_path: atuin.spec upstream_package_name: atuin - downstream_package_name: rust-atuin + downstream_package_name: atuin actions: + # Note: in upstream, the License has to be fixed manually after rust2rpm is run + # Copy from %cargo_license_summary in the build.log + fix-spec-file: + - sh -c 'tar -xf ${PACKIT_PROJECT_ARCHIVE}' + - sh -c 'rust2rpm --vendor ./atuin-${PACKIT_PROJECT_VERSION}' + # For this repo we manually sed to correct the file + # TODO: find the bundled dependencies + # - sh -c 'sed -i -znre "s|(SourceLicense:\s*)(.*)\n.*\n(License:\s*)# FIXME|\3\2|p" atuin.spec' create-archive: - - spectool -g -s0 rust-atuin.spec - - sh -c 'rust2rpm --vendor atuin ${PACKIT_PROJECT_VERSION}' - - sh -c 'echo atuin-${PACKIT_PROJECT_VERSION}.crate' + - spectool -g -s0 atuin.spec + - sh -c 'echo v${PACKIT_PROJECT_VERSION}.tar.gz' get-current-version: - - rpmspec -q --qf "%{Version}" --srpm rust-atuin.spec + - rpmspec -q --qf "%{Version}" --srpm atuin.spec srpm_build_deps: - rust2rpm diff --git a/rust-atuin.spec b/atuin.spec similarity index 61% rename from rust-atuin.spec rename to atuin.spec index ce4ecdb..d8fa0fa 100644 --- a/rust-atuin.spec +++ b/atuin.spec @@ -1,48 +1,35 @@ # Generated by rust2rpm 26 %bcond_without check -# prevent library files from being installed -%global cargo_install_lib 0 - -%global crate atuin - -Name: rust-atuin +Name: atuin Version: 18.2.0 Release: %autorelease Summary: magical shell history -License: MIT -URL: https://crates.io/crates/atuin -Source: %{crates_source} +SourceLicense: MIT +# FIXME: paste output of %%cargo_license_summary here +License: # FIXME +# LICENSE.dependencies contains a full license breakdown + +URL: https://atuin.sh +Source: https://github.com/atuinsh/atuin/archive/refs/tags/v%{version}.tar.gz Source: atuin-18.2.0-vendor.tar.xz -BuildRequires: cargo-rpm-macros >= 26 +BuildRequires: cargo-rpm-macros >= 25 +%if %{with check} +BuildRequires: postgresql-test-rpm-macros +%endif %global _description %{expand: -Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, it provides optional and fully encrypted synchronisation of your history between machines, via an Atuin server.} +Atuin replaces your existing shell history with a SQLite database, and records +additional context for your commands. Additionally, it provides optional and fully +encrypted synchronisation of your history between machines, via an Atuin server. +} %description %{_description} -%package -n %{crate} -Summary: %{summary} -License: MIT -# LICENSE.dependencies contains a full license breakdown - -%description -n %{crate} %{_description} - -%files -n %{crate} -%license LICENSE -%license LICENSE.dependencies -%license cargo-vendor.txt -%doc README.md -%{_bindir}/atuin -%{_datadir}/bash-completion/completions/atuin -%{_datadir}/fish/completions/atuin -%{_datadir}/zsh/site-functions/atuin -%config %{_sysconfdir}/profile.d/atuin.sh - %prep -%autosetup -n %{crate}-%{version} -p1 -a1 +%autosetup -n atuin-%{version} -p1 -a1 %cargo_prep -v vendor %build @@ -69,10 +56,30 @@ EOF %if %{with check} %check -# * These tests are skipped because they required a Postgres database to be -# running, which is not possible in the build environment. -%cargo_test -- -- --skip sync --skip change_password --skip multi_user_test --skip registration +# start a postgres instance for the tests to use +export PGTESTS_LOCALE="C.UTF-8" +export PGTESTS_USERS="atuin:pass" +export PGTESTS_DATABASES="atuin:atuin" +export PGTESTS_PORT=5432 +%postgresql_tests_run +%cargo_test %endif +%files +%license LICENSE +%license atuin/LICENSE +%license LICENSE.dependencies +%license cargo-vendor.txt +%doc CHANGELOG.md +%doc CODE_OF_CONDUCT.md +%doc CONTRIBUTING.md +%doc CONTRIBUTORS +%doc README.md +%{_bindir}/atuin +%{_datadir}/bash-completion/completions/atuin +%{_datadir}/fish/completions/atuin +%{_datadir}/zsh/site-functions/atuin +%config %{_sysconfdir}/profile.d/atuin.sh + %changelog %autochangelog diff --git a/rust2rpm.toml b/rust2rpm.toml index 0526b9b..5202b37 100644 --- a/rust2rpm.toml +++ b/rust2rpm.toml @@ -1,4 +1,6 @@ [package] +url = "https://atuin.sh" +source-url = "https://github.com/atuinsh/atuin/archive/refs/tags/v%{version}.tar.gz" extra-files = [ "%{_datadir}/bash-completion/completions/atuin", "%{_datadir}/fish/completions/atuin", @@ -7,18 +9,27 @@ extra-files = [ ] summary = "magical shell history" +cargo-install-lib = true -description = "Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, it provides optional and fully encrypted synchronisation of your history between machines, via an Atuin server." +description = """ +Atuin replaces your existing shell history with a SQLite database, and records +additional context for your commands. Additionally, it provides optional and fully +encrypted synchronisation of your history between machines, via an Atuin server. +""" -[tests] -skip = [ - "sync", - "change_password", - "multi_user_test", - "registration" +[requires] +test = [ + "postgresql-test-rpm-macros", ] -comments = [ - "These tests are skipped because they required a Postgres database to be running, which is not possible in the build environment." + +[scripts.check] +pre = [ + "# start a postgres instance for the tests to use", + "export PGTESTS_LOCALE=\"C.UTF-8\"", + "export PGTESTS_USERS=\"atuin:pass\"", + "export PGTESTS_DATABASES=\"atuin:atuin\"", + "export PGTESTS_PORT=5432", + "%postgresql_tests_run", ] From 19526b72223f0e2d67bdf4bd25eb65d714ef5d72 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Sat, 1 Jun 2024 22:48:55 +0200 Subject: [PATCH 2/2] Update .packit.yaml Signed-off-by: Cristian Le --- .packit.yaml | 11 ++++++----- atuin.spec | 29 ++++++++++++++++++++++++----- license.txt | 23 +++++++++++++++++++++++ 3 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 license.txt diff --git a/.packit.yaml b/.packit.yaml index aea511a..09a964b 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -4,14 +4,15 @@ packages: upstream_package_name: atuin downstream_package_name: atuin actions: - # Note: in upstream, the License has to be fixed manually after rust2rpm is run - # Copy from %cargo_license_summary in the build.log fix-spec-file: - sh -c 'tar -xf ${PACKIT_PROJECT_ARCHIVE}' - sh -c 'rust2rpm --vendor ./atuin-${PACKIT_PROJECT_VERSION}' - # For this repo we manually sed to correct the file - # TODO: find the bundled dependencies - # - sh -c 'sed -i -znre "s|(SourceLicense:\s*)(.*)\n.*\n(License:\s*)# FIXME|\3\2|p" atuin.spec' + # Note: These should not be automated because workspace packages vary case-by-case and rust2rpm does not support + # such automation. Adding simple sed expansion to make it more easily reproduced + # Patch the license file + - sh -c 'sed -i "/SourceLicense/{N;N;N;s/.*/cat license.txt/e}" ${PACKIT_DOWNSTREAM_PACKAGE_NAME}.spec' + # Change the default %cargo_install + - sh -c 'sed -i "s|%cargo_install|install -Dpm0755 target/rpm/atuin -t %{buildroot}%{_bindir}/|" ${PACKIT_DOWNSTREAM_PACKAGE_NAME}.spec' create-archive: - spectool -g -s0 atuin.spec - sh -c 'echo v${PACKIT_PROJECT_VERSION}.tar.gz' diff --git a/atuin.spec b/atuin.spec index d8fa0fa..551ef37 100644 --- a/atuin.spec +++ b/atuin.spec @@ -6,10 +6,29 @@ Version: 18.2.0 Release: %autorelease Summary: magical shell history -SourceLicense: MIT -# FIXME: paste output of %%cargo_license_summary here -License: # FIXME -# LICENSE.dependencies contains a full license breakdown +%global _license %{shrink: +((Apache-2.0 OR MIT) AND BSD-3-Clause) AND +(0BSD OR MIT OR Apache-2.0) AND +(Apache-2.0) AND +(Apache-2.0 OR BSL-1.0) AND +(Apache-2.0 OR BSL-1.0 OR MIT) AND +(Apache-2.0 OR ISC OR MIT) AND +(Apache-2.0 OR MIT) AND +(Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND +(BSD-2-Clause OR Apache-2.0 OR MIT) AND +(BSD-3-Clause) AND +(BSL-1.0) AND +(ISC) AND +(MIT) AND +(MIT AND BSD-3-Clause) AND +(MIT OR Apache-2.0) AND +(MIT OR Apache-2.0 OR BSD-1-Clause) AND +(MIT OR Apache-2.0 OR Zlib) AND +(MPL-2.0) AND +(Unlicense OR MIT) +} + +License: %_license URL: https://atuin.sh Source: https://github.com/atuinsh/atuin/archive/refs/tags/v%{version}.tar.gz @@ -39,7 +58,7 @@ encrypted synchronisation of your history between machines, via an Atuin server. %{cargo_vendor_manifest} %install -%cargo_install +install -Dpm0755 target/rpm/atuin -t %{buildroot}%{_bindir}/ # Generate all of the shell-completions for completion in bash fish zsh; do %{buildroot}%{_bindir}/atuin gen-completions --shell $completion -o . diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..2807753 --- /dev/null +++ b/license.txt @@ -0,0 +1,23 @@ +%global _license %{shrink: +((Apache-2.0 OR MIT) AND BSD-3-Clause) AND +(0BSD OR MIT OR Apache-2.0) AND +(Apache-2.0) AND +(Apache-2.0 OR BSL-1.0) AND +(Apache-2.0 OR BSL-1.0 OR MIT) AND +(Apache-2.0 OR ISC OR MIT) AND +(Apache-2.0 OR MIT) AND +(Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND +(BSD-2-Clause OR Apache-2.0 OR MIT) AND +(BSD-3-Clause) AND +(BSL-1.0) AND +(ISC) AND +(MIT) AND +(MIT AND BSD-3-Clause) AND +(MIT OR Apache-2.0) AND +(MIT OR Apache-2.0 OR BSD-1-Clause) AND +(MIT OR Apache-2.0 OR Zlib) AND +(MPL-2.0) AND +(Unlicense OR MIT) +} + +License: %_license