You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.9 KiB

%global _hardened_build 1
%define gitea_user git
%define gitea_group git
%define gitea_home /var/lib/gitea/
%define gitea_logdir /var/log/gitea/
Name : gitea
Version : 1.11.5
Release : 1%{dist}
License : MIT
URL : http://gitea.io
Summary : Git with a cup of tea
Source0 : gitea.service
Source1 : gitea.logrotate
BuildRequires: golang
BuildRequires: git
Requires : git
%description
Gitea is a community managed fork of Gogs, lightweight code hosting solution written in Go and published under the MIT license.
%prep
%setup -T -q -c %{name}-%{version}
export GOPATH=`pwd`
mkdir -p src/github.com/go-gitea/
cd src/github.com/go-gitea/
git clone https://github.com/go-gitea/gitea
%build
export GOPATH=`pwd`
cd src/github.com/go-gitea/gitea
git checkout tags/v%{version}
sed -i 's|^var Version = "1.[0-9].[0-9]-dev"$|var Version = "'%{version}'"|g' main.go
GO111MODULE=on go build -v -ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid "%{version}" -X 'main.Version="%{version}"'"
sed -i 's|^STATIC_ROOT_PATH =$|STATIC_ROOT_PATH = /usr/share/gitea/templates/default/|g' custom/conf/app.ini.sample
sed -i 's|^ROOT =$|ROOT = /var/lib/gitea/repositories/|g' custom/conf/app.ini.sample
sed -i 's|^APP_DATA_PATH = data$|APP_DATA_PATH = /var/lib/gitea/data|g' custom/conf/app.ini.sample
sed -i 's|^PROVIDER_CONFIG = data/sessions$|PROVIDER_CONFIG = /var/lib/gitea/data/sessions|g' custom/conf/app.ini.sample
sed -i 's|^AVATAR_UPLOAD_PATH = data/avatars$|AVATAR_UPLOAD_PATH = /var/lib/gitea/data/avatars|g' custom/conf/app.ini.sample
sed -i 's|^PATH = data/attachments$|PATH = /var/lib/gitea/data/attachments|g' custom/conf/app.ini.sample
sed -i 's|^ROOT_PATH =$|ROOT_PATH = /var/log/gitea|g' custom/conf/app.ini.sample
sed -i 's|^TEMP_PATH = data/tmp/uploads$|TEMP_PATH = /var/lib/gitea/data/tmp/uploads|g' custom/conf/app.ini.sample
npm install
npx eslint web_src/js webpack.config.js
npx webpack
npx lessc web_src/less/index.less public/css/index.css
npx lessc web_src/less/themes/arc-green.less o> public/css/theme-arc-green.css
npx postcss --use autoprefixer --use cssnano --no-map --replace public/css/*
%install
install -p -D -m 0644 %{SOURCE0} %{buildroot}%{_unitdir}/gitea.service
mkdir -p %{buildroot}/%{gitea_home}/conf/
install -p -D -m 0644 src/github.com/go-gitea/gitea/custom/conf/app.ini.sample %{buildroot}%{gitea_home}/conf/app.ini
cp -r src/github.com/go-gitea/gitea/options/locale %{buildroot}%{gitea_home}/conf/
cp -r src/github.com/go-gitea/gitea/options/license %{buildroot}%{gitea_home}/conf/
cp -r src/github.com/go-gitea/gitea/options/label %{buildroot}%{gitea_home}/conf/
cp -r src/github.com/go-gitea/gitea/options/readme %{buildroot}%{gitea_home}/conf/
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/gitea
mkdir -p %{buildroot}%{_datadir}/%{name}/templates/default/
cp -r src/github.com/go-gitea/gitea/templates %{buildroot}%{_datadir}/%{name}/templates/default/
cp -r src/github.com/go-gitea/gitea/public %{buildroot}%{_datadir}/%{name}/templates/default/
install -p -D -m 0555 src/github.com/go-gitea/gitea/gitea %{buildroot}%{_bindir}/gitea
install -p -d -m 0700 %{buildroot}%{gitea_home}
install -p -d -m 0700 %{buildroot}%{gitea_logdir}
%pre
getent group %{gitea_group} > /dev/null || groupadd -r %{gitea_group}
getent passwd %{gitea_user} > /dev/null || \
useradd -r -d %{gitea_home} -g %{gitea_group} \
-s /bin/bash -c "git user" %{gitea_user}
exit 0
%post
%systemd_post gitea.service
%preun
%systemd_preun gitea.service
%postun
%systemd_postun gitea.service
%files
%config(noreplace) %{gitea_home}/conf/app.ini
%{gitea_home}/conf/locale/*
%{gitea_home}/conf/license/*
%{gitea_home}/conf/label/*
%{gitea_home}/conf/readme/*
%{_sysconfdir}/logrotate.d/%{name}
%{_bindir}/gitea
%{_unitdir}/gitea.service
%{_datadir}/%{name}/templates/
%attr(700,%{gitea_user},%{gitea_group}) %dir %{gitea_home}
%attr(700,%{gitea_user},%{gitea_group}) %dir %{gitea_logdir}
%changelog