diff options
author | CoprDistGit <infra@openeuler.org> | 2025-02-20 14:25:14 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2025-02-20 14:25:14 +0000 |
commit | e11b5955d137cdc7a6316e50349fc8532762c2ee (patch) | |
tree | 61fb33b75db627d02b8c0a1b45bc1d97c2c786ad | |
parent | 1a6560cfe754b38a6c3b94a6e2f66494c5295df1 (diff) |
automatic import of hello-cangjie-eur
-rw-r--r-- | hello_cangjie_eur.spec | 84 |
1 files changed, 66 insertions, 18 deletions
diff --git a/hello_cangjie_eur.spec b/hello_cangjie_eur.spec index e07b0cf..189dd62 100644 --- a/hello_cangjie_eur.spec +++ b/hello_cangjie_eur.spec @@ -1,6 +1,6 @@ Name: hello-cangjie-eur Version: 0.0.8 -Release: 13%{?dist} +Release: 15%{?dist} Summary: Cangjie Eur demo. License: MIT Source: https://github.com/stevending1st/%{name}/archive/refs/tags/v%{version}.tar.gz @@ -11,7 +11,10 @@ Requires(pre): wget %description A demo for Cangjie and Eur. -%global output_name hello_cangjie_eur +%global cangjie_zip_name Cangjie-0.53.13-linux.tar.gz +%global cangjie_x86_64_download_url "https://cangjie-lang.cn/v1/files/auth/downLoad?nsId=142267&fileName=Cangjie-0.53.13-linux_x64.tar.gz&objectKey=6719f1eb3af6947e3c6af327" +%global cangjie_aarch64_download_url "https://cangjie-lang.cn/v1/files/auth/downLoad?nsId=142267&fileName=Cangjie-0.53.13-linux_aarch64.tar.gz&objectKey=6719f1ec3af6947e3c6af328" + %global output_dir_name %{name}-%{version}-%{release}.%{_arch} %global command main @@ -21,12 +24,12 @@ A demo for Cangjie and Eur. # 根据环境设置下载地址 %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" + %global download_url %{cangjie_x86_64_download_url} %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" + %global download_url %{cangjie_aarch64_download_url} %endif @@ -35,43 +38,88 @@ A demo for Cangjie and Eur. 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} +if [ ! -f %{_builddir}/%{cangjie_zip_name} ]; then + wget -O %{cangjie_zip_name} %{download_url} fi +tar -xvf %{cangjie_zip_name} -tar -xvf Cangjie-0.53.13-linux.tar.gz +cd %{_builddir}/%{buildsubdir} +source %{_builddir}/cangjie/envsetup.sh +cjpm build -o %{name} %install -cd %{_builddir}/%{name}-%{version} -rm -rf %{_buildrootdir}/* -source %{_builddir}/cangjie/envsetup.sh -cjpm install --root %{_buildrootdir}/%{output_dir_name} -mkdir -p %{_buildrootdir}/%{output_dir_name}%{_bindir} cd %{_buildrootdir}/%{output_dir_name} -cp -p %{_buildrootdir}/%{output_dir_name}/bin/%{output_name} .%{_bindir}/%{name} +%{__install} -p -D -m 755 %{_builddir}/%{buildsubdir}/target/release/bin/%{name} %{_buildrootdir}/%{output_dir_name}%{_bindir}/%{name} ln -sf %{_bindir}/%{name} .%{_bindir}/%{command} + %clean rm -rf %{buildroot} +%pre +if [ $1 == 1 ] ; then + # 获取当前系统架构 + ARCH=$(uname -m) + + # 下载目录 + DOWNLOAD_CANGJIE_PATH=/tmp + + # 配置 Cangjie 语言环境 + if [ "$ARCH" == "x86_64" ]; then + DOWNLOAD_URL=%{cangjie_x86_64_download_url} + else + DOWNLOAD_URL=%{cangjie_aarch64_download_url} + fi + if [ ! -f $DOWNLOAD_CANGJIE_PATH/%{cangjie_zip_name} ]; then + wget -O $DOWNLOAD_CANGJIE_PATH/%{cangjie_zip_name} $DOWNLOAD_URL + fi + if [ ! -d $DOWNLOAD_CANGJIE_PATH/cangjie ]; then + tar -xvf $DOWNLOAD_CANGJIE_PATH/%{cangjie_zip_name} -C $DOWNLOAD_CANGJIE_PATH + fi + + %{__install} -d -m 755 /usr/local/lib64/%{name}/ + %{__install} -D -p -m 755 ${DOWNLOAD_CANGJIE_PATH}/cangjie/runtime/lib/linux_${ARCH}_llvm/* /usr/local/lib64/%{name}/ + + echo "/usr/local/lib64/%{name}" >> /etc/ld.so.conf.d/%{name}.conf + + if [ -e /usr/lib/wsl/lib/libcuda.so.1 ]; then + cd /usr/lib/wsl/lib + rm libcuda.so libcuda.so.1 + ln -s libcuda.so.1.1 libcuda.so.1 + fi + + /usr/sbin/ldconfig +fi + + +%postun +if [ $1 == 0 ] ; then + rm -f /usr/local/lib64/%{name}/ + rm -f /etc/ld.so.conf.d/%{name}.conf 2>/dev/null ||: + /usr/sbin/ldconfig +fi + + %files # %license add-license-file-here # %doc add-docs-here +%defattr(-,root,root,-) %{_bindir}/%{name} %{_bindir}/%{command} -%exclude /bin/%{output_name} -%exclude /.packages.toml %changelog +* Thu Feb 20 2025 stevending1st <stevending1st@163.com> - 0.0.8-15 +- Configure the runtime environment library; replace the method of creating executable files. + * Sat Feb 15 2025 stevending1st <stevending1st@163.com> -Add pre, post and postun script. +- Add pre, post and postun script. * Thu Jan 02 2025 stevending1st <stevending1st@163.com> -Project init. +- Initial version. |