DEV Community

Duygu Ölmez for Açıklab

Posted on • Updated on

Debian Üzerinde Rpm (Centos 7) 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 7 - Base
baseurl=http://mirror.centos.org/centos/7/os/x86_64
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum/repos.d/Centos-7-Base.repo

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

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

Enter fullscreen mode Exit fullscreen mode
root@repo:/# yum update   
baseos | 3.9 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/7/{os,updates,extras}/x86_64/
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/7/os/x86_64/ --norepopath
reposync -g -l -d -m -a x86_64 --repoid=updates --newest-only --download-metadata --download_path=/storage/centos/7/updates/x86_64/ --norepopath
reposync -g -l -d -m -a x86_64 --repoid=extras --newest-only --download-metadata --download_path=/storage/centos/7/extras/x86_64/ --norepopath
Enter fullscreen mode Exit fullscreen mode

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

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

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

createrepo /storage/centos/7/os/x86_64/
createrepo /storage/centos/7/updates/x86_64/
createrepo /storage/centos/7/extras/x86_64/
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-7
Enter fullscreen mode Exit fullscreen mode

4.Centos 7 İstemci

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

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

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

echo """[extras]
name=CentOS Linux 7 - Extras
baseurl=http://10.10.10.10/centos/7/extras/x86_64/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial""" > /etc/yum.repos.d/Centos-7-Extras.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

Latest comments (0)