Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add helper script for rpm spec file generation
- Loading branch information
1 parent
ede1519
commit acdf384
Showing
3 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env arsh | ||
|
||
error() : Nothing { | ||
echo 1>&2 \[error\] $@ | ||
shctl set trace_on_exit | ||
exit 1 | ||
} | ||
|
||
gen_rpm_spec() { | ||
var src = $1 :- error "require src" | ||
var dest = $2 :- error "require dest" | ||
var version = $3 :- error "require version" | ||
|
||
var content = "$(cat $src)" :- error "$src: content is broken" | ||
$content = " | ||
function(VERSION: String, dest: String) => { | ||
cat << EOF > \$dest | ||
$content | ||
|
||
EOF | ||
}" | ||
var func = $MODULE._func($content)()! as (String, String) -> Void | ||
$func($version, $dest) | ||
} | ||
|
||
[<CLI(toplevel: $true)>] | ||
typedef _Param() { | ||
[<Option(required: $true, short: "v", long: "version", help: "specify package version (such as 0.0.0)")>] | ||
var version = "" | ||
|
||
[<Arg(required: $true, placeholder: "target_dir")>] | ||
var target = "" | ||
} | ||
|
||
_main(param: _Param) { | ||
shctl set errraise | ||
$/^\d+\.\d+\.\d+$/ =~ $param.version || error "invalid version number: ${param.version}" | ||
var dir = "${param.target}/arsh" | ||
mkdir -p $dir | ||
assert test -f $SCRIPT_DIR/rpm/arsh.spec.in | ||
gen_rpm_spec $SCRIPT_DIR/rpm/arsh.spec.in $dir/arsh.spec ${param.version} | ||
curl -Lf "https://github.com/sekiguchi-nagisa/arsh/archive/refs/tags/v${param.version}.tar.gz" \ | ||
> "$dir/arsh-${param.version}.tar.gz" | ||
cp $SCRIPT_DIR/../LICENSE $dir/ | ||
} | ||
|
||
shctl is-sourced || _main $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# | ||
# spec file for package arsh | ||
# | ||
# Copyright (c) 2024 SUSE LLC | ||
# Copyright (c) 2024 Nagisa Sekiguchi <s dot nagisa dot xyz at gmail dot com> | ||
# | ||
# All modifications and additions to the file contributed by third parties | ||
# remain the property of their copyright owners, unless otherwise agreed | ||
# upon. The license for this file, and modifications and additions to the | ||
# file, is the same license as for the pristine package itself (unless the | ||
# license for the pristine package is not an Open Source License, in which | ||
# case the license is the MIT License). An "Open Source License" is a | ||
# license that conforms to the Open Source Definition (Version 1.9) | ||
# published by the Open Source Initiative. | ||
|
||
# Please submit bugfixes or comments via https://bugs.opensuse.org/ | ||
# | ||
|
||
|
||
Summary: A statically typed scripting language with shell-like features | ||
Name: arsh | ||
|
||
Version: ${VERSION} | ||
Release: 0.%{?dist} | ||
|
||
License: Apache-2.0 | ||
Group: System/Shells | ||
URL: https://github.com/sekiguchi-nagisa/arsh | ||
|
||
Source0: %{name}-%{version}.tar.gz | ||
BuildRequires: gcc-c++ | ||
BuildRequires: git | ||
BuildRequires: pcre2-devel >= 10.30 | ||
BuildRequires: re2c >= 2.0 | ||
BuildRoot: %{_tmppath}/%{name}-%{version}-build | ||
Requires: bash-completion | ||
Requires: fzf | ||
|
||
%if 0%{?suse_version} || 0%{?is_opensuse} | ||
Requires: libpcre2-8-0 >= 10.30 | ||
%else | ||
Requires: pcre2 >= 10.30 | ||
%endif | ||
|
||
%if 0%{?rhel} && 0%{?rhel} < 8 | ||
BuildRequires: cmake3 | ||
%else | ||
BuildRequires: cmake | ||
%endif | ||
|
||
%description | ||
|
||
A statically typed scripting language with shell-like features. | ||
|
||
%if 0%{?suse_version} || 0%{?is_opensuse} | ||
%endif | ||
|
||
%prep | ||
%setup -q -n %{name}-%{version} | ||
|
||
%build | ||
%if 0%{?rhel} && 0%{?rhel} < 8 | ||
%cmake3 -DUSE_CTEST=off -DCMAKE_BUILD_TYPE=RELWITHDEBINFO | ||
%else | ||
%cmake -DUSE_CTEST=off -DCMAKE_BUILD_TYPE=RELWITHDEBINFO | ||
%endif | ||
%if 0%{?cmake_build:1} | ||
%cmake_build | ||
%else | ||
make %{?_smp_mflags} | ||
%endif | ||
|
||
%install | ||
%if 0%{?cmake_install:1} | ||
%cmake_install | ||
%else | ||
%make_install | ||
%endif | ||
|
||
%files | ||
%defattr(0755,root,root) | ||
%{_bindir}/* | ||
%{_datadir}/arsh | ||
%{_datadir}/arsh/completions | ||
%{_datadir}/arsh/modules | ||
|
||
%defattr(0644,root,root) | ||
%{_datadir}/arsh/completions/* | ||
%{_datadir}/arsh/modules/* | ||
%if 0%{?suse_version} < 1500 | ||
%doc LICENSE | ||
%else | ||
%license LICENSE | ||
%endif | ||
|
||
%changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters