DEV Community

Duygu Ölmez for Açıklab

Posted on • Updated on

Debian Üzerinde Rpm (Centos 8) Deposu Oluşturma

Debian tabanlı bir işletim sistemi üzerinde rpm deposu aynalamak için aşağıdaki adımları izlemek yeterlidir.

1.Debian Sunucu

1.1.Gerekli paketler indirilir.

sudo apt install yum-utils createrepo
Enter fullscreen mode Exit fullscreen mode

1.2.İndirmek istenilen depolar debian sunucunuzdaki ls -al /etc/yum/repos.d/ dizinine .repo uzantısı ile eklenir ve yum update komutu çalıştırılır.

echo """[baseos]
name=CentOS Linux 8 - BaseOS
baseurl=http://mirror.centos.org/centos/8/BaseOS/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum/repos.d/Centos-8-BaseOS.repo

echo """[powertools]
name=CentOS Linux 8 - PowerTools
baseurl=http://mirror.centos.org/centos/8/PowerTools/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum/repos.d/Centos-8-PowerTools.repo

echo """[extras]
name=CentOS Linux 8 - Extras
baseurl=http://mirror.centos.org/centos/8/extras/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum/repos.d/Centos-8-Extras.repo

echo """[appstream]
name=CentOS Linux 8 - AppStream
baseurl=http://mirror.centos.org/centos/8/AppStream/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum/repos.d/Centos-8-AppStream.repo

echo """[devel]
name=CentOS Linux 8 - Devel
baseurl=http://mirror.centos.org/centos/8/Devel/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum/repos.d/Centos-8-Devel.repo
Enter fullscreen mode Exit fullscreen mode
root@repo:/# yum update
appstream | 4.3 kB  00:00:00     
appstream/primary_db | 2.7 MB  00:00:00     
baseos | 3.9 kB  00:00:00     
devel | 3.8 kB  00:00:00     
devel/primary_db | 8.4 kB  00:00:00     
extras | 1.5 kB  00:00:00     
Setting up Update Process
No Packages marked for Update
Enter fullscreen mode Exit fullscreen mode

1.3.rpm paketlerinizin indirileceği depolama alanı olşuturulur.

mkdir -p /storage/centos/8/{BaseOS,Devel,extras,AppStream,PowerTools}/x86_64/os/
Enter fullscreen mode Exit fullscreen mode

1.4.Depodaki paketler indirilir.

reposync -g -l -d -m -a x86_64 --repoid=baseos --newest-only --download-metadata --download_path=/storage/centos/8/BaseOS/x86_64/os/ --norepopath
reposync -g -l -d -m -a x86_64 --repoid=appstream --newest-only --download-metadata --download_path=/storage/centos/8/AppStream/x86_64/os/ --norepopath
reposync -g -l -d -m -a x86_64 --repoid=extras --newest-only --download-metadata --download_path=/storage/centos/8/extras/x86_64/os/ --norepopath
reposync -g -l -d -m -a x86_64 --repoid=devel --newest-only --download-metadata --download_path=/storage/centos/8/Devel/x86_64/os/ --norepopath
reposync -g -l -d -m -a x86_64 --repoid=powertools --newest-only --download-metadata --download_path=/storage/centos/8/PowerTools/x86_64/os/ --norepopath
Enter fullscreen mode Exit fullscreen mode

1.5.Paketler indirildikten sonra aşağıdaki şekilde görüntülenebilmelidir.

ls -al /storage/centos/8/extras/x86_64/os/Packages/
Enter fullscreen mode Exit fullscreen mode

1.6.Index dosyaları oluşturulmalıdır.

createrepo /storage/centos/8/BaseOS/x86_64/os/
createrepo /storage/centos/8/extras/x86_64/os/
createrepo /storage/centos/8/Devel/x86_64/os/
createrepo /storage/centos/8/AppStream/x86_64/os/
createrepo /storage/centos/8/PowerTools/x86_64/os/
Enter fullscreen mode Exit fullscreen mode

1.7.Depoyu yayınlayacak bir web servisi yüklenir, örneğin apache2.

apt install apache2
Enter fullscreen mode Exit fullscreen mode

1.8.Indirilen depo apache içerisine linklenir.

rm /var/www/html/index.html
ln -s /storage/centos /var/www/html/
Enter fullscreen mode Exit fullscreen mode

2. Crontab for reposync

2.1. Paketlerin düzenli olarak aynalanması için /etc/centos.sh adında bir dosya oluşturulur ve içerisine aşağıdaki betik yazılır

base_path=/storage/
for i in $( ls /etc/yum/repos.d/ | grep ".repo")
do
        echo $i
        destination_path=$(grep baseurl /etc/yum/repos.d/$i | grep -oP 'centos/(.*)'  | grep -oP '/(.*)' )
        destination_path=$(grep baseurl /etc/yum/repos.d/$i | grep -oP 'centos/(.*)' )
        echo $base_path$destination_path
        repo_id=$(grep -oP "\[\K(.*)"  /etc/yum/repos.d/$i | sed 's/.$//')
        echo $repo_id
        reposync -g -l -d -m -a x86_64 --repoid=$repo_id --newest-only --download-metadata --download_path=$base_path$destination_path --norepopath
        echo reposync -g -l -d -m -a x86_64 --repoid=$repo_id --newest-only --download-metadata --download_path=$base_path$destination_path --norepopath
        createrepo $base_path$destination_path
done  
Enter fullscreen mode Exit fullscreen mode

2.2. Betik çalıştırışır hale getirilir.

sudo chmod +x /etc/centos.sh
Enter fullscreen mode Exit fullscreen mode

2.3 sudo crontab -e komutu çalıştırılır ve açılan metin dosyasının en sonuna aşağıdaki cron satırı eklenir.

0 5 * * * /etc/centos.sh
Enter fullscreen mode Exit fullscreen mode

3.Centos 8 GPG Keyinin Web Sunucuna Eklenmesi

3.1. Deponun indirildiği centos dizinine gidilir. wget ile php anahtarı çekilir.

cd /storage/centos
wget https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
Enter fullscreen mode Exit fullscreen mode

4.Centos 8 İstemci

4.1.Centos 8 üzerinde depoyu kullanabilmek için aşağıdaki formatta .repo dosyalarına depo sunucunuzu yazmanız yeterli.

echo """[baseos]
name=CentOS Linux 8 - BaseOS
baseurl=http://10.10.10.10/8/x86_64/BaseOS/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum.repos.d/Centos-8-BaseOS.repo

echo """[extras]
name=CentOS Linux 8 - Extras
baseurl=http://10.10.10.10/8/x86_64/extras/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum.repos.d/Centos-8-Extras.repo

echo """[appstream]
name=CentOS Linux 8 - AppStream
baseurl=http://10.10.10.10/centos/8/AppStream/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum.repos.d/Centos-8-AppStream.repo

echo """[devel]
name=CentOS Linux 8 - Devel
baseurl=http://10.10.10.10/centos/8/Devel/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum.repos.d/Centos-8-Devel.repo

echo """[powertools]
name=CentOS Linux 8 - PowerTools
baseurl=http://10.10.10.10/centos/8/PowerTools/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum.repos.d/Centos-8-PowerTools.repo
Enter fullscreen mode Exit fullscreen mode

4.2.Depo güncellenerek paket kurulumu yapılabilir.

sudo yum update
Enter fullscreen mode Exit fullscreen mode

Top comments (0)