From 815c010db8a5de07f737fe86735d033459f41c7c Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Sun, 16 Feb 2025 13:50:19 +0000 Subject: automatic import of hello-cangjie-eur --- hello_cangjie_eur.spec | 59 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/hello_cangjie_eur.spec b/hello_cangjie_eur.spec index 47cf4d7..ce0bdb6 100644 --- a/hello_cangjie_eur.spec +++ b/hello_cangjie_eur.spec @@ -54,14 +54,55 @@ cjpm install --root %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch} rm -rf %{buildroot} %pre -echo "================================" -echo $HOME/.bashrc -cat $HOME/.bashrc -echo "================================" -echo "source %{_libdir}/cangjie/envsetup.sh" >> $HOME/.bashrc -cat $HOME/.bashrc -echo "================================" -source $HOME/.bashrc +#!/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 +chmod 0755 %{_libdir}/cangjie/envsetup.sh + +for user_dir in /home/* +do + # 检查是否为目录 + if [ -d "$user_dir" ]; then + # 获取 .bashrc 的完整路径 + bashrc="$user_dir/.bashrc" + content="source %{_libdir}/cangjie/envsetup.sh" + + # 检查 .bashrc 是否存在 + if [ -f "$bashrc" ]; then + # 检查是否已经包含 "$content" + if ! grep -Fxq "$content" "$bashrc"; then + # 在 .bashrc 文件末尾添加 "$content" + echo "$content" >> "$bashrc" + fi + else + echo "$content" >> "$bashrc" + fi + + source "$bashrc" + echo "===================" + cat "$bashrc" + echo "$bashrc" + echo "===================" + fi +done %post for user_dir in /home/* @@ -102,7 +143,7 @@ do # 检查 .bashrc 是否存在 if [ -f "$bashrc" ]; then - # sed -i '\|source %{_libdir}/cangjie/envsetup.sh|d' "$bashrc" + sed -i '\|source %{_libdir}/cangjie/envsetup.sh|d' "$bashrc" sed -i "\|alias main='/usr/bin/%{output_name}'|d" "$bashrc" source "$bashrc" fi -- cgit v1.2.3