Linux
創建一個在清除目錄後不刪除目錄的 Debian 軟體包
我正在嘗試創建一個 Debian 軟體包,該軟體包在清除後不會刪除空目錄。具體來說,我正在創建自己的包,其中包含一些我信任的 CA 證書。
我正在遵循 Debian 建議的將證書安裝到
/usr/local/share/ca-certificates
. 我遇到的問題是該ca-certificates
軟體包/usr/local/share/ca-certificates
在安裝時創建,我希望該目錄在我的軟體包被清除時保留。我的目標是將我的信任鏈安裝到
/usr/local/share/ca-certificates/mychain
,但是當我的 Debian 軟體包被刪除時,我希望 dpkg如果它是空的,則不要刪除它,因為該軟體包明確創建了該目錄。/usr/local/share/ca-certificates``ca-certificates
我四處尋找一個明確的答案,但我設法找到的只是長長的論壇文章和電子郵件執行緒。
添加
postrm
腳本:#!/bin/sh set -e case "$1" in purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) # Recreate the /usr/local/share/ca-certificates directory, since we are # ignoring Debian Policy by intentionally installing here. Removal of # ca-certificates-local removes this directory if empty. if [ ! -e /usr/local/share/ca-certificates ]; then if mkdir /usr/local/share/ca-certificates 2>/dev/null; then chown root:staff /usr/local/share/ca-certificates chmod 2775 /usr/local/share/ca-certificates fi fi ;; *) echo "postrm called with unknown argument \`$1'" >&2 exit 1 ;; esac #DEBHELPER# exit 0
此程式碼來自ca-certificates-local:
這是一個範例存根源程序包,它在 local/ 目錄中包含一個虛擬 CA 證書。刪除虛擬證書,將您信任的本地根 CA(以 PEM 格式,文件名以“.crt”結尾)複製到 local/ 目錄,根據需要編輯 debian/ 目錄中的文件,然後建構您的自定義包。
因此,創建和安裝此類軟體包的快速方法:
git clone git://anonscm.debian.org/collab-maint/ca-certificates.git ~/ca-certificates cd ~/ca-certificates/examples/ca-certificates-local/ rm local/Local_Root_CA.crt cp <path-to-your-cert> local/ # edit debian/control: change package-name, description, etc # install build dependencies: http://unix.stackexchange.com/questions/177505/how-to-install-parse-build-dependencies-from-debian-control/211319#211319 dpkg-buildpackage dpkg -i ../<package-name-version>.deb