summaryrefslogtreecommitdiff
path: root/hello_cangjie_eur.spec
blob: bad4ca69c23894a0f477706a25646e9aee1a5b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
Name:           hello-cangjie-eur
Version:        0.0.8
Release:        4%{?dist}
Summary:        Cangjie Eur demo.
License:        MIT
Source:         https://github.com/stevending1st/%{name}/archive/refs/tags/v%{version}.tar.gz

BuildRequires:  wget, dnf-plugins-core, binutils, glibc-devel, gcc-c++, openssl
Requires(pre):  wget

%description
A demo for Cangjie and Eur.

%global debug_package %{nil}

# 根据环境设置下载地址
%ifarch x86_64
# 这里的指令仅在 x86_64 架构下运行
   %global download_url "https://cangjie-lang.cn/v1/files/auth/downLoad?nsId=142267&fileName=Cangjie-0.53.13-linux_x64.tar.gz&objectKey=6719f1eb3af6947e3c6af327"
%endif

%ifarch aarch64
# 这里的指令仅在 ARM 架构下运行
   %global download_url "https://cangjie-lang.cn/v1/files/auth/downLoad?nsId=142267&fileName=Cangjie-0.53.13-linux_aarch64.tar.gz&objectKey=6719f1ec3af6947e3c6af328"
%endif


%prep
%autosetup -n %{name}-%{version}
cd %{_builddir}/%{name}-%{version}
bash ./create_crt_links.sh

%build
cd %{_builddir}

# 检查文件是否存在,并设置一个宏
if [ ! -f %{_builddir}/Cangjie-0.53.13-linux.tar.gz ]; then
   wget -O Cangjie-0.53.13-linux.tar.gz %{download_url}
fi

tar xvf Cangjie-0.53.13-linux.tar.gz


%install
cd %{_builddir}/%{name}-%{version}
rm -rf %{_buildrootdir}/*
source %{_builddir}/cangjie/envsetup.sh
cjpm install --root %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}


%clean
rm -rf %{buildroot}


%pre
#!/bin/bash
# 根据环境设置下载地址
%ifarch x86_64
# 这里的指令仅在 x86_64 架构下运行
  %global download_url "https://cangjie-lang.cn/v1/files/auth/downLoad?nsId=142267&fileName=Cangjie-0.53.13-linux_x64.tar.gz&objectKey=6719f1eb3af6947e3c6af327"
%endif

%ifarch aarch64
# 这里的指令仅在 ARM 架构下运行
  %global download_url "https://cangjie-lang.cn/v1/files/auth/downLoad?nsId=142267&fileName=Cangjie-0.53.13-linux_aarch64.tar.gz&objectKey=6719f1ec3af6947e3c6af328"
%endif

cd %{_libdir}

# 检查文件是否存在,并设置一个宏
# if [ ! -f %{_libdir}/Cangjie-0.53.13-linux.tar.gz ]; then
#   wget -O Cangjie-0.53.13-linux.tar.gz %{download_url}
# fi

# tar xvf Cangjie-0.53.13-linux.tar.gz
# rm -rf Cangjie-0.53.13-linux.tar.gz

echo "================================"
echo $HOME/.bashrc
cat $HOME/.bashrc
echo "================================"
echo "source %{_libdir}/cangjie/envsetup.sh" >> $HOME/.bashrc
cat $HOME/.bashrc
echo "================================"
source $HOME/.bashrc


%post
#!/bin/bash
echo "alias main='/usr/bin/%{name}'" >> $HOME/.bashrc
source $HOME/.bashrc


%postun
#!/bin/bash
rm -rf %{_libdir}/cangjie

sed -i '\|source .*/cangjie/envsetup.sh|d' $HOME/.bashrc
sed -i "\|alias main='/usr/bin/%{name}'|d" $HOME/.bashrc


%files
# %license add-license-file-here
# %doc add-docs-here
/bin/hello_cangjie_eur
%exclude /.packages.toml


%changelog
* Thu Jan 02 2025 stevending1st <stevending1st@163.com>
Project init. 
* Sat Feb 15 2025 stevending1st <stevending1st@163.com>
Add pre, post and postun script.