diff --git a/epkg-0.3.0.tar.gz b/epkg-0.3.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..028b8179ce1dab444f0a6eac84eafa5e775ca9fa Binary files /dev/null and b/epkg-0.3.0.tar.gz differ diff --git a/epkg.spec b/epkg.spec new file mode 100644 index 0000000000000000000000000000000000000000..6ff66863b4237c55e9da7ef66a788914ce74215b --- /dev/null +++ b/epkg.spec @@ -0,0 +1,127 @@ +Name: epkg +Version: 0.3.0 +Release: 1 +Summary: A new type of software package +License: MulanPSL-2.0+ +URL: https://gitee.com/openeuler/epkg +Source0: %{name}-%{version}.tar.gz +Source1: rootfs.tar.gz + +Requires: coreutils, tar +BuildRequires: cargo, rust + +%global debug_package %{nil} +%if "%{_arch}" != "x86_64" && "%{_arch}" != "aarch64" +%error "Unsupported architecture: %{_arch}. Only x86_64 and aarch64 are supported." +exit 1 +%endif + +%description +epkg is a new type of software package format developed by the openEuler community. It supports multiple environments and versions, addressing software package compatibility issues. + +# Global path definitions +%global opt_epkg /opt/epkg +%global cache_root %{opt_epkg}/cache +%global store_root %{opt_epkg}/store +%global common_root %{opt_epkg}/users/public/envs/common +%global pkg_cache %{opt_epkg}/cache/packages +%global channel_cache %{opt_epkg}/cache/channel +%global rc_path /etc/profile.d/epkg.sh + +%prep +%setup -q -b 0 -n %{name}-%{version} +%setup -q -b 1 -n rootfs + +%build +# 进入源码目录编译epkg-manager +cd %{_builddir}/%{name}-%{version} +cargo build --release + +%install +rm -rf %{buildroot} + +# create directory structure +mkdir -p %{buildroot}%{cache_root} +mkdir -p %{buildroot}%{pkg_cache} +mkdir -p %{buildroot}%{channel_cache} +mkdir -p %{buildroot}%{store_root} +mkdir -p %{buildroot}%{common_root}/profile-1/usr/{app-bin,bin,sbin,lib,lib64} +mkdir -p %{buildroot}%{common_root}/profile-1/etc/epkg +cd %{buildroot}%{common_root}/profile-1 +ln -sT usr/bin bin +ln -sT usr/sbin sbin +ln -sT usr/lib lib +ln -sT usr/lib64 lib64 +cd %{buildroot}%{common_root}/ +ln -sT profile-1 profile-current + +# epkg-manager +mv %{_builddir}/%{name}-%{version}/ %{buildroot}%{cache_root}/epkg-manager/ +mv %{buildroot}%{cache_root}/epkg-manager/target/release/epkg %{buildroot}%{common_root}/profile-1/usr/bin/epkg +rm -rf %{buildroot}%{cache_root}/epkg-manager/target + +# rootfs +mv %{_builddir}/rootfs/epkg-helper-%{_arch} %{buildroot}%{cache_root}/ +mv %{_builddir}/rootfs/elf-loader-%{_arch} %{buildroot}%{cache_root}/ + +# unpack +cp -a %{buildroot}%{cache_root}/epkg-manager/bin %{buildroot}%{common_root}/profile-1/usr/ +cp -a %{buildroot}%{cache_root}/epkg-manager/lib/epkg %{buildroot}%{common_root}/profile-1/usr/lib/ +cp %{buildroot}%{cache_root}/epkg-manager/channel/openEuler-24.03-LTS-channel.yaml %{buildroot}%{common_root}/profile-1/etc/epkg/channel.yaml +cp -a %{buildroot}%{cache_root}/epkg-manager/build %{buildroot}%{opt_epkg}/ +cp %{buildroot}%{cache_root}/elf-loader-%{_arch} %{buildroot}%{common_root}/profile-1/usr/bin/elf-loader +cp %{buildroot}%{cache_root}/epkg-helper-%{_arch} %{buildroot}%{common_root}/profile-1/usr/bin/epkg-helper + +# chmod +chmod -R 755 %{buildroot}%{opt_epkg} +chmod 4755 %{buildroot}%{common_root}/profile-1/usr/bin/epkg +chmod 4755 %{buildroot}%{common_root}/profile-1/usr/bin/epkg-helper + +%post +# Add epkg environment configuration to system profile +mkdir -p $(dirname %{rc_path}) +cat << EOF >> %{rc_path} + +# epkg begin +source %{common_root}/profile-current/usr/lib/epkg/epkg-rc.sh +# epkg end +EOF + +%postun +# Remove epkg directories +rm -rf %{opt_epkg} +rm -rf %{rc_path} + +# Get all users including root +all_users=$(getent passwd | awk -F: '$3 >= 1000 {print $1 ":" $6}') +all_users=$(echo "$all_users" | grep -v '^nobody:') +all_users="$all_users root:/root" + +for t_user in $all_users; do + IFS=':' read -r user home <<< "$t_user" + if [ -d "$home/.epkg/" ]; then + rm -rf "$home/.epkg/" + fi + if [ -d "$home/.cache/epkg/" ]; then + rm -rf "$home/.cache/epkg/" + fi + if [ -f "$home/.bashrc" ]; then + if grep -q '# epkg begin' "$home/.bashrc" && grep -q '# epkg end' "$home/.bashrc"; then + sed -i '/# epkg begin/,/# epkg end/d' "$home/.bashrc" + fi + fi +done + +%files +%{opt_epkg}/ + +%changelog +* Tue Mar 18 2025 rkingkoyo - 0.3.0-1 +- Update version to 0.3.0 + +* Fri Mar 7 2025 rkingkoyo - 0.2.0-5 +- Update version to 0.2.0 +- update epkg.spec + +* Tue Feb 25 2025 rkingkoyo - 0.1.0-1 +- Initial package release \ No newline at end of file diff --git a/rootfs.tar.gz b/rootfs.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..6d0124e2ab82c6694cba371b4ccc9175afc31949 Binary files /dev/null and b/rootfs.tar.gz differ