summaryrefslogtreecommitdiffstats
path: root/mkrepo
blob: 0e6c16588be842b29a21a1d8b4ee5e2bc83d4978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
#set -x
TMP=/tmp/liste.$(basename $PWD)

nom=${PWD#/home/rpmbuild/site/rpms/}
if [ "${nom%%/*}" = "temp" ]
then
  dis=enterprise
  ver=8
  old=2
  dst=/data/rpms/old
elif [ "$nom" = "SRPMS" ]
then
  dis=fedora
  ver=36
  old=8
  dst=/data/rpms/SRPMS.remi
else
  dis=${nom%%/*}
  ver=${nom#$dis/}
  ver=${ver%%/*}
  old=2
  dst=/data/rpms/old
fi

if [ "$dis" == "fedora" ]; then
	# Fedora
	if [ "$ver" -ge 36 ]
	then echo "key 2022"
		GPG_PATH=/home/remi/.gnupgrpm
		GPG_NAME="845160D23149DAD504F0A32D83C0639E1FEF0014"
	elif [ "$ver" -ge 34 ]
	then echo "key 2021"
		GPG_PATH=/home/remi/.gnupg2021
		GPG_NAME="B1ABF71E14C9D74897E198A8B19527F1478F8947"
	elif [ "$ver" -ge 32 ]
	then echo "key 2020"
		GPG_PATH=/home/remi/.gnupg2020
		GPG_NAME="34C10BDBCC6F1B252E50BA1A0714919E4C21A808"
	elif [ "$ver" -ge 30 ]
	then echo "key 2019"
		GPG_PATH=/home/remi/.gnupg2019
		GPG_NAME="5F136145BF10369B7685D8DE503666CCBBAE6F1B"
	else echo "older key"
		exit 1
	fi
else
	# Enterprise
	if [ "$ver" -ge 9 ]
	then echo "key 2021"
		GPG_PATH=/home/remi/.gnupg2021
		GPG_NAME="B1ABF71E14C9D74897E198A8B19527F1478F8947"
	elif [ "$ver" -ge 8 ]
	then echo "key 2018"
		GPG_PATH=/home/remi/.gnupg2018
		GPG_NAME="6B38FEA7231F87F52B9CA9D8555097595F11735A"
	else echo "old key"
		GPG_PATH=/home/remi/.gnupgrpm
		GPG_NAME="1EE04CCE88A4AE4AA29A5DF5004E6F4700F97F56"
	fi
fi

if [ ${1:-check} != nocheck ]; then
	echo "+ Controle des signatures"
	rpm -K *.rpm | grep -v 'signatures.*OK' | cut -d: -f1 | tee $TMP
	if [ -s $TMP ]
	then
		rpmsign --define "_gpg_path $GPG_PATH" --define "_gpg_name $GPG_NAME"  --addsign $(cat $TMP)
	else
		echo OK.
	fi
fi

if [ ${2:-clean} != noclean ]; then
	echo "+ Nettoyage des anciens ($old)"

	cleanoldrpm $old $dst

	# https://bugzilla.redhat.com/show_bug.cgi?id=1899852 - repomanage is broken, reports not existing packages
	# use old deprecated yum command see https://bugzilla.redhat.com/1537981
	#dnf repomanage --old --keep=$old . | tee $TMP
	#repomanage --old --keep=$old . --setopt=metadata_expire=1 2>/dev/null | tee $TMP
	#LST=$(cat $TMP)
	#if [ -n "$LST" ]
	#then	mv $LST /data/rpms/old/
	#fi
fi

cache=/home/rpmbuild/site/rpms/.createrepocache/$nom
mkdir -p $cache
check=sha256
#if [ "$dis" == "fedora" -a "$ver" -ge 99 ]; then
if true; then
  cleanoldmeta repodata
  echo "+ Génération repodata (createrepo_c, $check)"
  createrepo_c --workers 4 		     \
               --cachedir $cache 	 \
               --unique-md-filenames \
               --retain-old-md 8     \
               --changelog-limit 3   \
               --compress-type=bz2   \
               --quiet               \
               --database $(pwd)
else
  cleanoldmeta repodata
  echo "+ Génération repodata (createrepo, $check)"
    createrepo --workers 4 		 \
               --cachedir $cache 	 \
               --checksum $check 	 \
               --unique-md-filenames \
               --retain-old-md 8     \
               --changelog-limit 3   \
               --compress-type=bz2   \
               --database .
fi
rm -f repodata/repomd.xml.asc
gpg --armor --detach-sign --default-key "$GPG_NAME" --homedir "$GPG_PATH" repodata/repomd.xml

#echo "+ Génération repoview"
#nom=${PWD#/home/rpmbuild/site/rpms/}
#echo repoview --quiet --url http://rpms.remirepo.net/$nom \
#	--template-dir /home/rpmbuild/site/rpms/repotmpl \
#	--title "Remi's RPM repository - ${nom//\// - }" .
#LANG=C repoview --quiet --url http://rpms.remirepo.net/$nom \
#	--template-dir /home/rpmbuild/site/rpms/repotmpl \
#	--title "Remi's RPM repository - ${nom//\// - }" .