Friday, May 13, 2016

CreateYumRepository

구축 환경


  • OS
    • CentOS 6
  • Arch
    • x86_64

RPM Build Server 구축


Install RPM for Build & Repository

$ yum install rpm-build
$ yum install createrepo
$ yum install rng-tools

Create GPG Key

/proc/sys/kernel/random/entropy_avail 의 값 증가 시키기(1000이상)

$ rngd -r /dev/urandom

GPG key 생성하기(Default 옵션으로 진행)

$ gpg --gen-key

gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: YoungJoo.Kim
Email address: vozltx@gmail.com
Comment: Vozlt Corp.
You selected this USER-ID:
    "YoungJoo.Kim (Vozlt Corp.) <vozltx@gmail.com>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

can't connect to `/root/.gnupg/S.gpg-agent': 그런 파일이나 디렉터리가 없습니다
gpg-agent[1841]: directory `/root/.gnupg/private-keys-v1.d' created

                                                                                                                                                                                      3Please re-enter this passphrase                                                                                                                3                                                                                                                                               3Passphrase ***********_____________________________                                                                                            3                                                                                                                                               3      <OK>                             <Cancel>            

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key A511F848 marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   2048R/A511F848 2013-02-19
      Key fingerprint = 5DBB 3608 1F7C 8114 D27D  923A F79D 8B55 A511 F848
uid                  YoungJoo.Kim (Vozlt Corp.) <vozltx@gmail.com>
sub   2048R/FEAA622E 2013-02-19

GPG Key 생성 확인

$ gpg --list-keys

/root/.gnupg/pubring.gpg
------------------------
pub   2048R/A511F848 2013-02-19
uid                  YoungJoo.Kim (Vozlt Corp.) <vozltx@gmail.com>
sub   2048R/FEAA622E 2013-02-19

GPG Key 내보내기(Rpm 으로 묶어서 배포)

$ gpg --export -a 'YoungJoo.Kim' > RPM-GPG-KEY-CentOS-6-Vozlt

GPG Key 설치하기(빌드시에는 안해도 됨)

$ rpm --import RPM-GPG-KEY-CentOS-6-Vozlt

/etc/rpm/macros.key 작성하기(빌드만 하려면 4, 5 제외하고 여기까지만 하면 됨)

$ vi /etc/rpm/macros.key

# %_signature, %_gpg_name 을 정확하게 기재한다.(gpg --list-keys 로 확인)
%_sourcedir         %{_topdir}/SOURCES/%{name}
%_signature         gpg
%_gpg_name          YoungJoo.Kim (Vozlt Corp.) <vozltx@vozlt.org>
%packager           Vozlt manager <vozltx@vozlt.org>
%vendor             Vozlt Corp.
%dist               .el6.vozlt
%_topdir            /usr/src/redhat

관련 링크

GPG Key Manual

RPM Repository Server 구축


Repository Directory 생성

$ mkdir -p /repository/centos/6/SRPMS
$ mkdir -p /repository/centos/6/i386
$mkdir -p /repository/centos/6/x86_64

GPG Key 복사

$ cp -af RPM-GPG-KEY-CentOS-6-Vozlt /repository/centos/6

RPM 저장

$ cp -af /usr/src/redhat/RPMS/x86_64/*.rpm /repository/centos/6/x86_64/
$ createrepo /repository/centos/6/x86_64

YUM RPM Repository 등록

remote 구축시

$ vi /etc/yum.repos.d/Vozlt.repo

[vozlt]
name=CentOS-$releasever - rpms.example.com
baseurl=http://rpms.example.com/centos/$releasever/$basearch/
gpgcheck=1
gpgkey=http://rpms.example.com/centos/$releasever/RPM-GPG-KEY-CentOS-6-Vozlt

local 구축시

$ vi /etc/yum.repos.d/Vozlt-local.repo

[vozlt]
name=CentOS-$releasever - rpms.example.com
baseurl=file:///repository/centos/$releasever/$basearch/
gpgcheck=1
gpgkey=file:///repository/centos/$releasever/RPM-GPG-KEY-CentOS-6-Vozlt

Repository WebRoot 설정

/repository

Repository 등록 확인

$ yum clean all
$ yum repolist



Post a Comment