diff options
author | CoprDistGit <infra@openeuler.org> | 2025-02-23 14:18:46 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2025-02-23 14:18:46 +0000 |
commit | e697e5e58f3f7e5287cdfb931d99341e77f34e3f (patch) | |
tree | 07d434bf6f9727f3673390e83227afa3dd7f7d00 | |
parent | a3df32bd253e280d82b5b578dbe16b44ecc22a58 (diff) |
automatic import of file-classify
-rw-r--r-- | file-classify.spec | 139 | ||||
-rw-r--r-- | sources | 0 | ||||
-rw-r--r-- | v0.0.2.tar.gz | 6 |
3 files changed, 145 insertions, 0 deletions
diff --git a/file-classify.spec b/file-classify.spec new file mode 100644 index 0000000..6e90d21 --- /dev/null +++ b/file-classify.spec @@ -0,0 +1,139 @@ +Name: file-classify +Version: 0.0.2 +Release: 1%{?dist} +Summary: Classify the files. +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 +Move files to different folders based on their extensions and types. + +%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 + +%global debug_package %{nil} +%define __requires_exclude (libcangjie-runtime\.so|libsecurec\.so) + +# 根据环境设置下载地址 +%ifarch x86_64 +# 这里的指令仅在 x86_64 架构下运行 + %global download_url %{cangjie_x86_64_download_url} +%endif + +%ifarch aarch64 +# 这里的指令仅在 ARM 架构下运行 + %global download_url %{cangjie_aarch64_download_url} +%endif + + +%prep +%autosetup -n %{name}-%{version} +cd %{_builddir}/%{name}-%{version} +bash ./create_crt_links.sh + + +%build +cd %{_builddir} +# 检查文件是否存在,并设置一个宏 +if [ ! -f %{_builddir}/%{cangjie_zip_name} ]; then + wget -O %{cangjie_zip_name} %{download_url} +fi +tar -xvf %{cangjie_zip_name} + +cd %{_builddir}/%{buildsubdir} +source %{_builddir}/cangjie/envsetup.sh +cjpm build -o %{name} + +echo "" > %{_builddir}/%{name} + + +%install +cd %{_buildrootdir}/%{output_dir_name} +%{__install} -p -D -m 755 %{_builddir}/%{buildsubdir}/target/release/bin/%{name} %{_buildrootdir}/%{output_dir_name}%{_bindir}/%{name} +ln -sf %{_bindir}/%{name} .%{_bindir}/%{command} +%{__install} -p -D -m 777 %{_builddir}/%{name} %{_buildrootdir}/%{output_dir_name}%{_sysconfdir}/%{name} + + +%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 + + +%post +if [ $1 == 1 ] && [ -s %{_sysconfdir}/%{name} ] ; then + if [ -z "$FILE_CLASSIFY_OUTPUT_FILE" ] ; then + if [ -f "/var/tmp/%{name}" ]; then + OUTPUT_PATH=$(cat /var/tmp/%{name}) + fi + else + OUTPUT_PATH="$FILE_CLASSIFY_OUTPUT_FILE" + fi + + if [ -n "$OUTPUT_PATH" ]; then + echo "$OUTPUT_PATH" > %{_sysconfdir}/%{name} + fi +fi + + +%postun +if [ $1 == 0 ] ; then + rm -rf /usr/local/lib64/%{name}/ 2>/dev/null ||: + 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} +%config(noreplace) %{_sysconfdir}/%{name} + + +%changelog +* Sun Feb 23 2025 stevending1st <stevending1st@163.com> - 0.0.1-1 +- Initial version. diff --git a/v0.0.2.tar.gz b/v0.0.2.tar.gz new file mode 100644 index 0000000..5100dab --- /dev/null +++ b/v0.0.2.tar.gz @@ -0,0 +1,6 @@ +--2025-02-23 22:12:14-- https://github.com/stevending1st/file-classify/archive/refs/tags/v0.0.2.tar.gz +Resolving github.com (github.com)... 20.205.243.166 +Connecting to github.com (github.com)|20.205.243.166|:443... connected. +HTTP request sent, awaiting response... 404 Not Found +2025-02-23 22:12:15 ERROR 404: Not Found. + |