rpmパッケージをビルドしてリポジトリを構成する

この記事では、rpmパッケージを作成し、リポジトリを整理するプロセスについて詳しく説明します。 このトピックに興味のある人は誰でも猫の下に行くようお願いします。







あなたがあなたに明らかなことをめくることができるように、私は非常に詳細に書くことを約束しました。







目次





システムのインストール



劇場はハンガーから始まります

私たちのサービスは、オペレーティングシステムがインストールされた瞬間から始まります。 当然、rpmパッケージをビルドするには、rhelディストリビューションを選択します。 この場合、 CentOS 7が選択されました。







CentOSをダウンロード



イメージが置かれるディレクトリを作成し、そこに移動します。







mkdir ~/centos && cd $_
      
      





次に、検証に必要な画像とファイルを直接ダウンロードできます。







 wget https://mirror.yandex.ru/centos/7/isos/x86_64/CentOS-7-x86_64-Everything-1708.iso wget https://mirror.yandex.ru/centos/7/isos/x86_64/sha256sum.txt.asc
      
      





または、最初にインストールするaria2プログラムの助けを借りてトレントを介して:







 sudo yum install -y epel-release sudo yum install -y aria2 aria2c https://mirror.yandex.ru/centos/7/isos/x86_64/CentOS-7-x86_64-Everything-1708.torrent cd ~/centos/CentOS-7-x86_64-Everything-1708
      
      





画像を確認



イメージのダウンロードだけでは不十分です。その整合性と信頼性を確認する必要があります。







CentOS 7のキーをダウンロードします。







 wget http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
      
      





キーを見てインポートします。







 gpg --quiet --with-fingerprint RPM-GPG-KEY-CentOS-7 pub 4096R/F4A80EB5 2014-06-23 CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org> Key fingerprint = 6341 AB27 53D7 8A78 A7C2 7BB1 24C6 A8A7 F4A8 0EB5 gpg --import RPM-GPG-KEY-CentOS-7 gpg: key F4A80EB5: public key "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)
      
      





画像のチェックサムを使用して、ファイルの署名を確認します。







 gpg --verify sha256sum.txt.asc 2>&1 | grep "Good signature" gpg: Good signature from "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
      
      





ご覧のとおり、すべてが正常であり、イメージ自体の整合性を確認できます。







 sha256sum -c sha256sum.txt.asc 2>&1 | grep OK CentOS-7-x86_64-Everything-1708.iso: OK
      
      





画像をメディアに書き込む



イメージの完全性とその真正性を確信した後、すでに記録してインストールしておくといいでしょう! それではそれをやってみましょうが、最初に何を書き込むかを決めます。







イメージをディスクに書き込む



このイメージを書き込むには、両面DVDが必要です。 最初にwodimをインストールして、それを見つけて記録するとします。







 sudo yum install -y wodim sudo wodim dev=/dev/cdrom -eject -v CentOS-7-x86_64-Everything-1708.iso
      
      





USBフラッシュドライブへのイメージの書き込み



両面DVDはどういうわけか古風なので、16 GBのフラッシュドライブを使用してイメージを書き込みましょう。ただし、その前に/ dev / sdaはフラッシュドライブですが、別のドライブがあります。 fdiskコマンドを参照してください。







 sudo dd if=CentOS-7-x86_64-Everything-1708.iso of=/dev/sda bs=1M status=progress; sync eject /dev/sda
      
      





status=progress



サポートされていない場合、旧式の方法:







 watch -n 10 "sudo kill -USR1 $(pgrep ^dd)"
      
      





またはこのように:







 watch -n 10 "sudo pkill -usr1 dd"
      
      





ただし、pvを使用できます。







 sudo yum install -y epel-release sudo yum install -y pv sudo su dd if=CentOS-7-x86_64-Everything-1708.iso | pv | dd of=/dev/sda
      
      





設置



Centos 7のインストール方法は、ここで決定します。RAIDについては、LVMなどについて考えることができます。

最小パッケージを設定します。







インストールプロセスはこのビデオで見ることができます。







プリセット



システムをインストールした後、サーバーを構成する必要があります。







パッケージの更新とインストール



まず、インストールされているすべてのパッケージを更新してから、epelリポジトリをインストールします。これには、多くの便利な機能があります。







 sudo yum update -y sudo yum install -y epel-release
      
      





次のステップは、ビルドする必要があるパッケージのグループと、リポジトリーのデプロイに必要ないくつかのパッケージをインストールすることです。







 sudo yum groupinstall -y "Development Tools" sudo yum install -y glibc-static tree wget vim createrepo sudo yum install -y httpd httpd-devel mod_ssl python2-certbot-apache vsftpd
      
      





Ssh



サーバーを快適かつ安全に管理するには、SSHを構成します。







キーを使用する方が安全なので、作業コンピューター上のサーバーにアクセスするためのキーを作成します。







 ssh-keygen
      
      





キーをサーバーに追加します。







 ssh-copy-id chelaxe@rpmbuild
      
      





またはハンドル:







 mkdir ~/.ssh chmod 700 ~/.ssh vim ~/.ssh/authorized_keys ssh-rsa AAAA...tzU= ChelAxe (DFH) <chelaxe@gmail.com> chmod 600 ~/.ssh/authorized_keys
      
      





サービス自体でナットを締める必要があります。 構成ファイルのコピーを作成して、編集を開始します。







 sudo cp /etc/ssh/sshd_config{,.bak} sudo vim /etc/ssh/sshd_config
      
      





ファイルは、次の行を追加/変更/コメント解除する必要があります。







 #       192.168.0.2 ListenAddress 192.168.0.2 #     30  LoginGraceTime 30 #   root  PermitRootLogin no #     MaxAuthTries 3 #     PasswordAuthentication no #  10     ClientAliveInterval 600 ClientAliveCountMax 0 #     chelaxe AllowUsers chelaxe #       chelaxe AllowGroups chelaxe #  sshd     SSH2 Protocol 2
      
      





サービスを再起動します。







 sudo systemctl restart sshd
      
      





ファイアウォール



サーバーへのアクセスを制限することが重要です。 このため、ファイアウォールを構成します。







 sudo firewall-cmd --permanent --zone=public --remove-service=dhcpv6-client sudo firewall-cmd --permanent --zone=public --remove-service=ssh sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.0.0/28" service name="ssh" accept' sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --permanent --zone=public --add-service=ftp sudo firewall-cmd --permanent --list-all public target: default icmp-block-inversion: no interfaces: sources: services: http https ftp ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: rule family="ipv4" source address="192.168.0.0/28" service name="ssh" accept sudo firewall-cmd --reload
      
      





ここでは、外部アクセスとssh用のhttp https ftpサービスを追加しましたが、これは192.168.0.0/28ネットワークのみです。







組立現場の準備



アセンブリサイト自体を準備しましょう。 アセンブリは、スナップショットテクノロジを積極的に使用して、別の仮想ホストで実行される可能性が最も高いことに注意する価値がありますが、ここでは全体をすべて説明します。 また、アセンブリの場合は、管理者ではない別のユーザーを選択する必要があります(つまり、 sudo



は使用できません)。







ディレクトリの作成



必要なディレクトリを作成します。







 mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} sudo mkdir /var/www/repo sudo chown -R chelaxe:chelaxe /var/www/repo ln -s /var/www/repo ~/rpmbuild/REPO tree ~/rpmbuild/ /home/chelaxe/rpmbuild/ ├── BUILD ├── BUILDROOT ├── REPO -> /var/www/repo ├── RPMS ├── SOURCES ├── SPECS └── SRPMS 7 directories, 0 files
      
      





PGP署名の構成



収集したパッケージには署名が必要です。これにより、整合性と信頼性が確保されます。







独自のキーを使用するか、キーがない場合は作成します。 仕事用コンピューターにキーを作成します。







キーがない場合は作成します。







 gpg --gen-key
      
      





いくつかの質問に答えるよう求められます。

キータイプ、選択(1)RSAおよびRSA(デフォルト)、キーサイズ:4096、有効期間:6m、当社名:Alexander F. Mikhaylov、メール:chelaxe@gmail.com、コメント、ここでキーが必要な理由を指定できます:リポジトリと待機...







突然すべての答えがgpg: cancelled by user



後、このgpg: cancelled by user



、コマンドを実行gpg: cancelled by user









 script /dev/null
      
      





繰り返します。







ビューキー:







 gpg --fingerprint chelaxe@gmail.com pub 2048R/E6D53D4D 2014-05-07 Key fingerprint = EE2A FF9A 2BE3 318E 9346 A675 8440 3961 E6D5 3D4D uid ChelAxe (DFH) <chelaxe@gmail.com>
      
      





秘密鍵を保存します。







 gpg --export-secret-keys --armor chelaxe@gmail.com > chelaxe-privkey.asc
      
      





レビュー用のキーを作成します。







 gpg --output chelaxe-revoke.asc --gen-revoke chelaxe@gmail.com
      
      





公開鍵をキーサーバーにエクスポートします。







 gpg --keyserver pgp.mit.edu --send-keys E6D53D4D
      
      





これで、キーをサーバーにインポートできます。







 gpg --import ~/chelaxe-privkey.asc rm -rf ~/chelaxe-privkey.asc
      
      





gpgユーティリティの場所を確認します。







 which gpg /usr/bin/gpg
      
      





パッケージに署名するためのファイルを構成します。







 vim ~/.rpmmacros %_signature gpg %_gpg_path /home/chelaxe/.gnupg %_gpg_name ChelAxe %_gpgbin /usr/bin/gpg
      
      





リポジトリを作成する



次に、リポジトリ自体を整理します。







パッケージを保存するディレクトリを作成します。







 mkdir ~/rpmbuild/REPO/Packages
      
      





キーをリポジトリにエクスポートします。







 gpg --export -a 'ChelAxe' > ~/rpmbuild/REPO/RPM-GPG-KEY-chelaxe
      
      





リポジトリ自体を作成し、メタデータに署名します。







 createrepo ~/rpmbuild/REPO gpg --detach-sign --armor ~/rpmbuild/REPO/repodata/repomd.xml
      
      





リポジトリパッケージ



システムにリポジトリを自動インストールするためのパッケージを収集します。







 cd ~/rpmbuild/SOURCES mkdir chelaxe-release && cd $_
      
      





yumのリポジトリファイル:







 vim ~/rpmbuild/SOURCES/chelaxe-release/chelaxe.repo [chelaxe] name=ChelAxe Official Repository - $basearch baseurl=https://repo.chelaxe.ru/ enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-chelaxe
      
      





パッケージのキーをエクスポートします。







 gpg --export -a 'ChelAxe' > ~/rpmbuild/SOURCES/chelaxe-release/RPM-GPG-KEY-chelaxe
      
      





アーカイブ内のすべてを収集します。







 cd ~/rpmbuild/SOURCES tar -czf chelaxe-release.tar.gz chelaxe-release/
      
      





パッケージのSPECSファイルを作成します。







 cd ~/rpmbuild/SPECS vim ~/rpmbuild/SPECS/chelaxe-release.spec Name: chelaxe-release Version: 1.0 Release: 1%{?dist} Summary: ChelAxe repository configuration Vendor: DFH Packager: ChelAxe Group: System Environment/Base License: GPL URL: https://repo.chelaxe.ru Source0: https://repo.chelaxe.ru/%{name}.tar.gz BuildArch: noarch %description This package contains the ChelAxe official repository GPG key as well as configuration for yum. %prep %setup -q -n %{name} %install %__rm -rf %{buildroot} install -d -m 755 %{buildroot}%{_sysconfdir}/yum.repos.d install -p -m 644 chelaxe.repo %{buildroot}%{_sysconfdir}/yum.repos.d/chelaxe.repo install -d -m 755 %{buildroot}%{_sysconfdir}/pki/rpm-gpg install -p -m 644 RPM-GPG-KEY-chelaxe %{buildroot}%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-chelaxe %post rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-chelaxe %clean %__rm -rf %{buildroot} %files %defattr(-,root,root,-) %{_sysconfdir}/yum.repos.d/chelaxe.repo %{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-chelaxe %changelog * Tue May 1 2018 ChelAxe (DFH) <chelaxe@gmail.com> - 1.0-1%{?dist} - Initial package.
      
      





パッケージを収集します。







 rpmbuild -ba --sign ~/rpmbuild/SPECS/chelaxe-release.spec
      
      





この時点で、PGPキーのパスワードが求められます。







作成したパッケージをリポジトリにコピーして更新します。







 cp ~/rpmbuild/RPMS/noarch/chelaxe-release-1.0-1.el7.centos.noarch.rpm ~/rpmbuild/REPO/ createrepo --update ~/rpmbuild/REPO
      
      





メタデータに署名することを忘れないでください:







 gpg --detach-sign --armor ~/rpmbuild/REPO/repodata/repomd.xml
      
      





次に、システムにリポジトリをインストールします。







 sudo yum install -y ~/rpmbuild/REPO/chelaxe-release-1.0-1.el7.centos.noarch.rpm
      
      





将来、このパッケージはhttps://repo.chelaxe.ru/chelaxe-release-1.0-1.el7.centos.noarch.rpmで利用可能になる予定です







インストール後、chelaxeリポジトリとPGPキーが表示されます。







 rpm -q gpg-pubkey --qf '%{name}-%{version}-%{release} --> %{summary}\n' | grep ChelAxe gpg-pubkey-e6d53d4d-5369c520 --> gpg(ChelAxe (DFH) <chelaxe@gmail.com>)
      
      





ここで最も重要なことはSPECファイルです。それらについては記述しませんが、いくつかのリンクを提供します。







  1. https://www.altlinux.org/Spec
  2. https://docs.fedoraproject.org/quick-docs/en-US/creating-rpm-packages.html
  3. https://www.opennet.ru/docs/HOWTO-RU/RPM-HOWTO-48.html


そして1つの便利なコマンド:







 rpm --showrc
      
      





アセンブリ用の既製のマクロが表示されます。







ビルドTmux



次に、たとえば有用なものを収集しましょう。 tmux-ターミナルマルチプレクサを収集します。これがないと、私は快適に作業できません。 tmuxはCentOS 7のベースリポジトリにありますが、バージョンは1.8であり、2.7をビルドすることに注意してください。 また、ベースリポジトリのパッケージにはlibevent依存関係がありますが、最新の静的ライブラリを使用してtmuxをビルドします。







調理ソース



tmuxのソースと必要なライブラリをダウンロードします。







 cd ~/rpmbuild/SOURCES wget https://github.com/tmux/tmux/releases/download/2.7/tmux-2.7.tar.gz wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz.asc wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.1.tar.gz wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.1.tar.gz.sig
      
      





ソースコードをチェックするためにGPGキーをエクスポートします。







 gpg --recv-keys 8EF8686D gpg --recv-keys F7E48EDB
      
      





ファイルの確認:







 gpg --verify libevent-2.1.8-stable.tar.gz.asc libevent-2.1.8-stable.tar.gz 2>&1 | grep "Good signature" gpg: Good signature from "Azat Khuzhin <a3at.mail@gmail.com>" gpg --verify ncurses-6.1.tar.gz.sig ncurses-6.1.tar.gz 2>&1 | grep "Good signature" gpg: Good signature from "Thomas Dickey <dickey@invisible-island.net>"
      
      





tmux構成ファイルを準備します。







 vim ~/rpmbuild/SOURCES/tmux.conf #   : #   set-option -g buffer-limit 50 #      set-option -g command-alias[100] zoom="resize-pane -Z" #    set-option -g default-terminal "screen-256color" #    escape set-option -g escape-time 500 #     set-option -g exit-empty off #     set-option -g exit-unattached off #     set-option -g focus-events off #       set-option -g history-file ~/.tmux_history #        set-option -g message-limit 100 #        escape set-option -g set-clipboard on #    set-option -g terminal-overrides[100] "xterm:colors=256" set-option -g terminal-overrides[101] "xterm*:colors=256" set-option -g terminal-overrides[102] "screen:colors=256" set-option -g terminal-overrides[103] "screen*:colors=256" #    # set-option -g user-keys[100] "\e[5;30012~" #   : #     set-option -g activity-action other #       set-option -g assume-paste-time 1 #    set-option -g base-index 1 #  ""   set-option -g bell-action other #     ( default-shell) # set-option -g default-command "vim" # Shell   set-option -g default-shell "/bin/bash" #     set-option -g destroy-unattached off #       set-option -g detach-on-destroy on #     set-option -g display-panes-active-colour "red" #    set-option -g display-panes-colour "green" #     set-option -g display-panes-time 1000 #        .  set-option -g display-time 750 #      set-option -g history-limit 2000 #      set-option -g key-table "root" #      set-option -g lock-after-time 1800 #     set-option -g lock-command "vlock" #     #  : message-command-attr message-command-bg message-command-fg set-option -g message-command-style "bg=black,fg=yellow" #     #  : message-attr message-bg message-fg set-option -g message-style "bg=yellow,fg=black" #   #   2.1  : mode-mouse mouse-resize-pane mouse-select-pane mouse-select-window set-option -g mouse off #   set-option -g prefix Cb #   set-option -g prefix2 Ca #    set-option -g renumber-windows on #        set-option -g repeat-time 500 #    set-option -g set-titles on #    set-option -g set-titles-string "#{session_name}" #  ""   set-option -g silence-action other #    set-option -g status on #     set-option -g status-interval 1 #       set-option -g status-justify left #       set-option -g status-keys vi #      set-option -g status-left " [#{session_name}]#{?session_many_attached,*,} #{version} #[reverse] #[default] " #      set-option -g status-left-length 20 #      #  : status-left-attr status-left-bg status-left-fg set-option -g status-left-style "default" #    set-option -g status-position bottom #      set-option -g status-right " #[reverse] #[default] %a %d %b %Y %H:%M:%S [%V/%j] " #      set-option -g status-right-length 40 #      #  : status-right-attr status-right-bg status-right-fg set-option -g status-right-style "default" #    #  : status-attr status-bg status-fg set-option -g status-style "bg=green,fg=black" #       set-option -g update-environment[100] "TERMINFO" #    # set-option -g user-keys[100] "\e[1~" #       set-option -g visual-activity off #    ""   set-option -g visual-bell off #    ""   set-option -g visual-silence off #       set-option -g word-separators " -_@" #   : #      set-option -gw aggressive-resize on #      set-option -gw allow-rename on #       set-option -gw alternate-screen on #    set-option -gw automatic-rename on #     set-option -gw automatic-rename-format "#{?pane_in_mode,[tmux],#{pane_current_command}}#{?pane_dead,[dead],}" #    set-option -gw clock-mode-colour "green" #    set-option -gw clock-mode-style 24 #       set-option -gw force-height 0 #       set-option -gw force-width 0 #    set-option -gw main-pane-height 24 #    set-option -gw main-pane-width 80 #       set-option -gw mode-keys vi #      #  : mode-attr mode-bg mode-fg set-option -gw mode-style "bg=yellow,fg=black" #     set-option -gw monitor-activity on #  ""   set-option -gw monitor-bell on #  ""  .  . set-option -gw monitor-silence 0 #    set-option -gw other-pane-height 0 #    set-option -gw other-pane-width 0 #     #  : pane-active-border-attr pane-active-border-bg pane-active-border-fg set-option -gw pane-active-border-style "fg=green" #    set-option -gw pane-base-index 1 #     set-option -gw pane-border-format "#{?pane_active,#[reverse],}#{?window_zoomed_flag,#[fg=red],} #{pane_index}:#{=6:pane_current_command} #[default]" #     set-option -gw pane-border-status top #    #  : pane-border-attr pane-border-bg pane-border-fg set-option -gw pane-border-style "fg=green" #       set-option -gw remain-on-exit off #       set-option -gw synchronize-panes off #    set-option -gw window-active-style "default" #         #  : window-status-activity-attr window-status-activity-bg window-status-activity-fg set-option -gw window-status-activity-style "fg=red" #     ""    #  : window-status-bell-attr window-status-bell-bg window-status-bell-fg set-option -gw window-status-bell-style "fg=red" #        set-option -gw window-status-current-format " #{window_index}:#{window_name} " #        #  : window-status-current-attr window-status-current-bg window-status-current-fg set-option -gw window-status-current-style "reverse" #       set-option -gw window-status-format " #{window_index}:#{window_name}#{?window_activity_flag,#,}#{?window_bell_flag,!,}#{?window_silence_flag,~,} " #        #  : window-status-last-attr window-status-last-bg window-status-last-fg set-option -gw window-status-last-style "default" #        set-option -gw window-status-separator "" #       set-option -gw window-status-style "default" #   set-option -gw window-style "default" #    set-option -gw wrap-search on #    set-option -gw xterm-keys on #    #    Alt +  bind-key -rT root M-Up select-pane -U bind-key -rT root M-Down select-pane -D bind-key -rT root M-Left select-pane -L bind-key -rT root M-Right select-pane -R #     bind-key -T root M-PageUp copy-mode -eu #      bind-key -T prefix Ms set-option -gw synchronize-panes\; display-message " : #{?synchronize-panes,on,off}" #   bind-key -T prefix Ml lock-session #   bind-key -T prefix Mr source-file /etc/tmux.conf\; display-message " " #   # bind-key -T prefix Me #   #   new-session -s "work"
      
      





クッキングSPECファイル



このファイルは、以前のSPECファイルよりも興味深いものになります。







 cd ~/rpmbuild/SPECS vim ~/rpmbuild/SPECS/tmux.spec %define libevent 2.1.8 %define ncurses 6.1 Name: tmux Version: 2.7 Release: 1%{?dist} Summary: A terminal multiplexer Vendor: DFH Packager: ChelAxe Group: Applications/System License: ISC and BSD URL: https://github.com/%{name}/%{name} Source0: https://github.com/%{name}/%{name}/releases/download/%{version}/%{name}-%{version}.tar.gz Source1: https://github.com/libevent/libevent/releases/download/release-%{libevent}-stable/libevent-%{libevent}-stable.tar.gz Source2: ftp://ftp.gnu.org/gnu/ncurses/ncurses-%{ncurses}.tar.gz Source3: tmux.conf BuildRequires: gcc, gcc-c++, make, glibc-static %description tmux is a "terminal multiplexer", it enables a number of terminals (or windows) to be accessed and controlled from a single terminal. tmux is intended to be a simple, modern, BSD-licensed alternative to programs such as GNU screen. %prep %setup -q -a1 -a2 %build %__mkdir "libs" pushd "libevent-%{libevent}-stable" %_configure \ --prefix="$(pwd)/../libs" \ --disable-shared %__make install popd pushd "ncurses-%{ncurses}" %_configure \ --prefix="$(pwd)/../libs" \ --with-default-terminfo-dir="/usr/share/terminfo" \ --with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo:$HOME/.terminfo" %__make install popd %_configure \ --enable-static \ --prefix="/usr" \ CFLAGS="-Ilibs/include -Ilibs/include/ncurses" \ LDFLAGS="-Llibs/lib -Llibs/include -Llibs/include/ncurses" \ LIBEVENT_CFLAGS="-Ilibs/include" \ LIBEVENT_LIBS="-Llibs/lib -levent" \ LIBNCURSES_CFLAGS="-Ilibs/include" \ LIBNCURSES_LIBS="-Llibs/lib -lncurses" %__make %install %__rm -rf %{buildroot} %make_install install -d -m 755 %{buildroot}%{_sysconfdir} install -p -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/tmux.conf %clean %__rm -rf %{buildroot} %files %defattr(-,root,root,-) %doc README TODO CHANGES example_tmux.conf %config(noreplace) %{_sysconfdir}/tmux.conf %{_bindir}/tmux %{_mandir}/man1/tmux.1.gz %changelog * Fri Jun 29 2018 ChelAxe (DFH) <chelaxe@gmail.com> - 2.7-1%{?dist} - Rebuild for new version tmux. * Tue May 1 2018 ChelAxe (DFH) <chelaxe@gmail.com> - 2.6-1%{?dist} - Initial package.
      
      





組立



パッケージを収集し、リポジトリに追加します。







 rpmbuild -ba --sign ~/rpmbuild/SPECS/tmux.spec cp ~/rpmbuild/RPMS/x86_64/tmux-2.7-1.el7.centos.x86_64.rpm ~/rpmbuild/REPO/Packages/ createrepo --update ~/rpmbuild/REPO
      
      





メタデータに署名することを忘れないでください:







 gpg --detach-sign --armor ~/rpmbuild/REPO/repodata/repomd.xml
      
      





何が起こったのか、どのように起こったかを見てください







 tree ~/rpmbuild/ -L 2 /home/chelaxe/rpmbuild/ ├── BUILD │  ├── chelaxe-release │  └── tmux-2.7 ├── BUILDROOT ├── REPO -> /var/www/repo ├── RPMS │  ├── noarch │  └── x86_64 ├── SOURCES │  ├── chelaxe-release │  ├── chelaxe-release.tar.gz │  ├── libevent-2.1.8-stable.tar.gz │  ├── libevent-2.1.8-stable.tar.gz.asc │  ├── ncurses-6.1.tar.gz │  ├── ncurses-6.1.tar.gz.sig │  ├── tmux-2.7.tar.gz │  └── tmux.conf ├── SPECS │  ├── chelaxe-release.spec │  └── tmux.spec └── SRPMS ├── chelaxe-release-1.0-1.el7.centos.src.rpm └── tmux-2.7-1.el7.centos.src.rpm
      
      





インストールと起動



パッケージをインストールします。







 sudo yum clean all sudo yum install -y tmux
      
      





tmuxを起動して喜ぶ:







 tmux attach-session
      
      





fbidaを収集する



コンソールで画像を表示するための一連のアプリケーションであるfbidaを収集します。 このパッケージはCentos 7では見つかりませんでした。







調理ソース



fbidaソースをダウンロードします。







 cd ~/rpmbuild/SOURCES wget https://www.kraxel.org/releases/fbida/fbida-2.14.tar.gz wget https://www.kraxel.org/releases/fbida/fbida-2.14.tar.gz.asc
      
      





ソースコードをチェックするためにGPGキーをエクスポートします。







 gpg --recv-keys D3E87138
      
      





ファイルの確認:







 gpg --verify fbida-2.14.tar.gz.asc fbida-2.14.tar.gz 2>&1 | grep "Good signature" gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      
      





クッキングSPECファイル



このSPECファイルにはさらに依存関係があります。







 cd ~/rpmbuild/SPECS vim ~/rpmbuild/SPECS/fbida.spec Name: fbida Version: 2.14 Release: 1%{?dist} Summary: FrameBuffer Imageviewer Vendor: DFH Packager: ChelAxe Group: Applications/Multimedia License: GPLv2+ URL: https://www.kraxel.org/blog/linux/fbida/ Source: https://www.kraxel.org/releases/fbida/fbida-%{version}.tar.gz BuildRequires: libexif-devel fontconfig-devel libjpeg-turbo-devel BuildRequires: libpng-devel libtiff-devel pkgconfig BuildRequires: giflib-devel libcurl-devel libXpm-devel BuildRequires: pixman-devel libepoxy-devel libdrm-devel BuildRequires: mesa-libEGL-devel poppler-devel poppler-glib-devel BuildRequires: freetype-devel mesa-libgbm-devel Requires: libexif fontconfig libjpeg-turbo Requires: libpng libtiff giflib Requires: libcurl libXpm pixman Requires: libepoxy libdrm mesa-libEGL Requires: poppler poppler-glib freetype Requires: mesa-libgbm ImageMagick dejavu-sans-mono-fonts %description fbi displays the specified file(s) on the linux console using the framebuffer device. PhotoCD, jpeg, ppm, gif, tiff, xwd, bmp and png are supported directly. For other formats fbi tries to use ImageMagick's convert. %prep %setup -q %{__sed} -i -e "s,/X11R6,,g" GNUmakefile %install %__rm -rf %{buildroot} %make_install PREFIX=/usr %clean %__rm -rf %{buildroot} %files %defattr(-,root,root,-) %doc Changes COPYING INSTALL README TODO VERSION %{_prefix}/* %changelog * Tue May 1 2018 ChelAxe (DFH) <chelaxe@gmail.com> - 2.14-1%{?dist} - Initial package.
      
      





組立



:







 sudo yum install -y libexif-devel fontconfig-devel libjpeg-turbo-devel libpng-devel libtiff-devel pkgconfig giflib-devel libcurl-devel libXpm-devel ImageMagick dejavu-sans-mono-fonts pixman-devel libepoxy-devel libdrm-devel mesa-libEGL-devel poppler-devel poppler-glib-devel mesa-libgbm-devel rpmbuild -ba --sign ~/rpmbuild/SPECS/fbida.spec cp ~/rpmbuild/RPMS/x86_64/fbida-2.14-1.el7.centos.x86_64.rpm ~/rpmbuild/REPO/Packages/ createrepo --update ~/rpmbuild/REPO
      
      





:







 gpg --detach-sign --armor ~/rpmbuild/REPO/repodata/repomd.xml
      
      







:







 sudo yum clean all sudo yum install -y fbida
      
      





http/https



http/https.







カスタマイズ



Apache:







 sudo mv /etc/httpd/conf.d/welcome{.conf,.bak} sudo cp /etc/httpd/conf/httpd{.conf,.bak}
      
      





// :







 sudo vim /etc/httpd/conf/httpd.conf #       Listen 192.168.0.2:80 # Email     ServerAdmin chelaxe@gmail.com ServerName repo.chelaxe.ru #    Apache ServerSignature Off ServerTokens Prod sudo cp /etc/httpd/conf.d/ssl{.conf,.bak} sudo vim /etc/httpd/conf.d/ssl.conf #       Listen 192.168.0.2:443 https # OCSP (Online Certificate Status Protocol) SSLStaplingCache "shmcb:logs/stapling-cache(128000)"
      
      





:







 sudo apachectl configtest Syntax OK
      
      





:







 sudo systemctl start httpd sudo systemctl enable httpd
      
      





:







 #      - cd /etc/ssl/certs sudo openssl dhparam -out dhparam.pem 4096 #     HKPK (HTTP Public Key Pinning) sudo openssl x509 -noout -in /etc/pki/tls/certs/localhost.crt -pubkey | openssl asn1parse -noout -inform pem -out /tmp/public.key #      HKPK (HTTP Public Key Pinning) openssl dgst -sha256 -binary /tmp/public.key | openssl enc -base64 aQxRkBUlhfQjidLUovOlxdZe/4ygObbDG7l+RgwzSWA= rm -rf /tmp/public.key
      
      





VirtualHost :







 sudo vim /etc/httpd/conf.d/repo.conf <VirtualHost "192.168.0.2:80"> ServerAdmin "chelaxe@gmail.com" ServerName "repo.chelaxe.ru" DocumentRoot "/var/www/repo" <Directory "/var/www/repo"> AllowOverride None Options Indexes </Directory> </VirtualHost> <VirtualHost "192.168.0.2:443"> ServerAdmin "chelaxe@gmail.com" ServerName "repo.chelaxe.ru" DocumentRoot "/var/www/repo" <Directory "/var/www/repo"> AllowOverride None Options Indexes </Directory> SSLEngine on # HSTS (HTTP Strict Transport Security) Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" # HKPK (HTTP Public Key Pinning) Header set Public-Key-Pins "pin-sha256=\"aQxRkBUlhfQjidLUovOlxdZe/4ygObbDG7l+RgwzSWA=\"; max-age=2592000; includeSubDomains" #    Header set X-Robots-Tag "none" #    XSS- Header set X-XSS-Protection "1; mode=block" #   - Header always append X-Frame-Options DENY #    MIME  Header set X-Content-Type-Options nosniff #   XSS- Header set Content-Security-Policy "default-src 'self';" # OCSP (Online Certificate Status Protocol) SSLUseStapling on #   SSL (   CRIME) SSLCompression off #  SSLv2  SSLv3 SSLProtocol all -SSLv2 -SSLv3 #   SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH #      SSLHonorCipherOrder on #      - # cat /etc/ssl/certs/dhparam.pem >> /etc/pki/tls/certs/localhost.crt #  2.4.8   # SSLOpenSSLConfCmd DHParameters "/etc/ssl/certs/dhparam.pem" SSLOptions +StrictRequire SSLCertificateFile "/etc/pki/tls/certs/localhost.crt" SSLCertificateKeyFile "/etc/pki/tls/private/localhost.key" </VirtualHost>
      
      





なぜなら Centos 7 Apache 2.4.6, 2.4.8, - :







 sudo bash -c "cat /etc/ssl/certs/dhparam.pem >> /etc/pki/tls/certs/localhost.crt"
      
      





HTTP/2 , Apache HTTP/2.







:







 sudo apachectl configtest Syntax OK sudo systemctl reload httpd
      
      





Let's Encrypt



, Let's Encrypt:







 sudo certbot --apache --agree-tos --email chelaxe@gmail.com -d repo.chelaxe.ru
      
      





, rewrite https. VirtualHost http:







 RewriteEngine on RewriteCond %{SERVER_NAME} =repo.chelaxe.ru RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
      
      





VirtualHost https:







 Include /etc/letsencrypt/options-ssl-apache.conf SSLCertificateFile /etc/letsencrypt/live/repo.chelaxe.ru/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/repo.chelaxe.ru/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/repo.chelaxe.ru/chain.pem
      
      





Include /etc/letsencrypt/options-ssl-apache.conf



.







- :







 sudo bash -c "cat /etc/ssl/certs/dhparam.pem >> /etc/letsencrypt/live/repo.chelaxe.ru/cert.pem"
      
      





HKPK (HTTP Public Key Pinning):







 #     HKPK (HTTP Public Key Pinning) sudo openssl x509 -noout -in /etc/letsencrypt/live/repo.chelaxe.ru/cert.pem -pubkey | openssl asn1parse -noout -inform pem -out /tmp/public.key #      HKPK (HTTP Public Key Pinning) openssl dgst -sha256 -binary /tmp/public.key | openssl enc -base64 aidlhfQjoxRkbvOlxdZLBUe/4ygOUDG7l+RgwzQbSWA= rm -rf /tmp/public.key
      
      





:







  # HKPK (HTTP Public Key Pinning) Header set Public-Key-Pins "pin-sha256=\"aidlhfQjoxRkbvOlxdZLBUe/4ygOUDG7l+RgwzQbSWA=\"; max-age=2592000; includeSubDomains"
      
      





:







 sudo apachectl configtest Syntax OK sudo systemctl reload httpd
      
      





. :







 sudo crontab -e SHELL=/bin/bash MAILTO=chelaxe@gmail.com @daily certbot renew >> /var/log/certbot-renew.log
      
      





, - HKPK (HTTP Public Key Pinning).







.htaccess



.htaccess



, , :







 sudo chown apache:apache ~/rpmbuild/REPO/.htaccess sudo chmod 600 ~/rpmbuild/REPO/.htaccess sudo chcon -R -t httpd_sys_content_t ~/rpmbuild/REPO/.htaccess
      
      





AllowOverride



All



. :







 IndexIgnore .htaccess
      
      





.







vsftpd



:







 hide_file={.htaccess} deny_file={.htaccess}
      
      





.htaccess AccessFileName



:







 AccessFileName .acl
      
      





mod_autoindex



Apache . noscript



html5, css3, javascript, jquery, bootstrap, backbone, awesome , :







repo.chelaxe.ru







javascript :







LINKS2







web vsftpd , .htaccess



.







mod_autoindex



nginx:







  1. http://www.oglib.ru/apman/mod/mod_autoindex.html
  2. https://habr.com/post/353478/


ftp



:







 sudo systemctl start vsftpd sudo systemctl enable vsftpd
      
      





:







 sudo cp /etc/vsftpd/vsftpd{.conf,.bak} sudo vim /etc/vsftpd/vsftpd.conf anonymous_enable=YES local_enable=NO write_enable=NO local_umask=022 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_std_format=YES listen=NO pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES force_dot_files=NO anon_root=/var/www/repo no_anon_password=YES hide_ids=YES sudo usermod -d /var/www/repo ftp
      
      





SeLinux:







 sudo semanage fcontext -a -t public_content_t '/var/www/repo(/.*)?' sudo restorecon -Rv '/var/www/repo'
      
      





:







 sudo systemctl restart vsftpd
      
      





.htaccess



— , ftp:







 sudo chcon -R -t httpd_sys_content_t ~/rpmbuild/REPO/.htaccess
      
      





おわりに



. , .








All Articles