Showing posts with label terminal. Show all posts
Showing posts with label terminal. Show all posts

Monday, May 16, 2022

Podman 清除建置失敗的殘餘容器資料

使用 podman build 建置容器時,建置失敗的中間容器會被留下來,而且不會被 podman system prune -a 清除。

$ podman system prune -a
WARNING! This command removes:
	- all stopped containers
	- all networks not used by at least one container
	- all images without at least one container associated with them
	- all build cache

Are you sure you want to continue? [y/N] y
Error: Image used by fbcfbb...7e8: image is in use by a container

這個原因看起來是因為 podman system prune 清除的對象是 Podman 本身產生的資料,而 podman build 背後是透過 Buildah 來進行建置,而這部份就不被認為是 Podman 的直接行為。細節可以參考在 #7889 Failed to remove image, image is in use by container 這個 Issue 裡的描述。

處理的方式就是手動刪除,先執行 podman ps --all --storage 把所有的容器列出來,再用 podman rm 刪掉。

$ podman ps --all --storage
CONTAINER ID  IMAGE                                      COMMAND     CREATED      STATUS      PORTS       NAMES
b396d84310a4  docker.io/library/ubuntu:16.04             buildah     10 days ago  storage                 ubuntu-working-container
fbcfbbc3c233  docker.io/library/bd7139...bed-tmp:latest  buildah     10 days ago  storage                 793b78...79a-working-container
$ podman rm b396d84310a4 fbcfbbc3c233

Monday, January 30, 2017

在 OS X 下編譯 GnuPG 2

現在 GnuPG 1.4 classic 似乎不維護了,在下載網頁都沒連結 XD ... 現在看起來在 stable release 取而代之的是 2.0 系列。在 2.0 系列進行了模組化的設計,把一些功能抽成函式庫,因次編譯時要先分別編譯那些函式庫,再編譯 GnuPG 本體,稍微比較麻煩一點。

首先要下載原始碼檔案,這部分就變成要下載很多包: https://www.gnupg.org/download/

在 2.0.30 中,除了 GnuPG 本體之外,還要:

  • libgpg-error
  • libgcrypt
  • libksba
  • libassuan
  • nPth
  • Pinentry

除了 GnuPG 提供的程式之外,另外還要 GNU Pth: https://www.gnu.org/software/pth/

安裝順序需要依照相依性來安排,整個建置指令如下所示。

$ cd pth-2.0.7/
$ ./configure --prefix=${PREFIX}
$ make
$ make install
$ cd npth-1.3/
$ ./configure --prefix=${PREFIX}
$ make
$ make install
$ cd libgpg-error-1.26/
$ ./configure --prefix=${PREFIX}
$ make
$ make install
$ cd libksba-1.3.5/
$ ./configure --prefix=${PREFIX} --with-libgpg-error-prefix=${PREFIX}
$ make
$ make install
$ cd libassuan-2.4.3/
$ ./configure --prefix=${PREFIX} --with-libgpg-error-prefix=${PREFIX}
$ make
$ make install
$ cd libgcrypt-1.7.6/
$ ./configure --prefix=${PREFIX} --with-libgpg-error-prefix=${PREFIX} --with-pth-prefix=${PREFIX}
$ make
$ make install

下面這個步驟會建置輸入密碼用的介面程式,在這邊我使用 TTY 模組 (就是傳統的直接在終端機畫面輸入) 來輸入密碼,在終端機畫面上還有一個 NCurses 模組可以選擇,不過個人不太習慣。

$ cd pinentry-1.0.0/
$ ./configure --prefix=${PREFIX} --disable-pinentry-gtk2 --disable-pinentry-gnome3 --disable-pinentry-qt --disable-pinentry-qt5 --disable-pinentry-curses --enable-pinentry-tty --with-libgpg-error-prefix=${PREFIX} --with-libassuan-prefix=${PREFIX}
$ make
$ make install

接下來要建置 GnuPG 的本體:

$ cd gnupg-2.0.30/
$ ./configure --prefix=${PREFIX} --with-libgpg-error-prefix=${PREFIX} --with-pth-prefix=${PREFIX} --with-libgcrypt-prefix=${PREFIX} --with-libassuan-prefix=${PREFIX} --with-ksba-prefix=${PREFIX} --with-pinentry-pgm=${PREFIX}/bin/pinentry

組態好之後直接進行 make; make install 會出現一些關於 intmax_t 宣告上的錯誤,是因為使用到了錯誤的 stdint.h 所導致。錯誤訊息看起來像是這樣:

unknown type name 'intmax_t'
    extern intmax_t

避過的方法是修改產生出來的 Makefile 中關於 stdint.h 的路徑,步驟是:

  1. 編輯 gl/Makefile
  2. 找到這行: ABSOLUTE_STDINT_H = "///Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include/stdint.h"
  3. 換成這樣: ABSOLUTE_STDINT_H = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/stdint.h"

路徑需要跟著 Xcode 安裝的 SDK 路徑所調整。

接著在繼續進行 make; make install 即可。

$ make
$ make install

Sunday, January 10, 2010

在 Snow Leopard 下開啓 ls 的色彩化輸出

首先,給 bash 的設定要放在 ~/.bash_profile 裡頭,預設是沒有這個檔案的。因為透過 Terminal.app 啓動 bash 是透過 login 來作的,因此 ~/.bashrc 不會有作用。

在 ~/.bash_profile 裡面加上 export CLICOLOR=1 就可以啓動 ls 的 colorize output 了,要透過指令列開啓的話,則是使用 -G 選項,而不是在 GNU ls 下得 --color 選項。

Thursday, January 01, 2009

Mac OS X 上更新 locate database

在 OS X 上要更新 locate 的 database 有兩個方法,一個是直接執行 /usr/libexec/locate.updatedb 這個更新用的指令稿,另一個是執行 /etc/periodic/weekly/500.weekly 或是長像類似的東西,後者是用來每週定期執行用的指令稿,有比較好的權限處理。

在 man locate 裡頭是說 /etc/periodic/weekly/310.locate 是定期執行用的指令稿,不過在我的機器上沒有這個檔案。

不管是執行哪個,可能都要利用 sudo 去執行,除非把資料庫檔案的權限改掉。

sudo /etc/periodic/weekly/500.weekly

Saturday, May 10, 2008

在 Mac OS X 的 Terminal.app 下在遠端 screen 無法使用 backspace

狀況是這樣子,在 Mac OS X 的終端機裡,連線到遠端的主機後,在遠端主機執行的 screen 會不理會 backspace 鍵。

我在 debian 上遇到這個問題,其他的 distribution 可能也會有這個問題,不過我不確定。

基本上原因就是 Terminal.app 送出的終端機識別字串沒有被識別,解決方法有修改終端機識別字串,或是有點掩耳盜鈴似的告訴 screen 應該怎麼識別終端機。

修改終端機識別字串,在 Mac 上執行這個指令:

defaults write com.apple.Terminal TermCapString xterm

覆寫掉遠端的終端機名稱描述,在遠端主機執行這個指令:

export TERM=xterm

或是,我是把下面這個丟到 .bashrc 裡:

alias screen ='TERM=xterm screen'

Sunday, January 28, 2007

PuTTY 0.59

在前幾天 PuTTY 出了 0.59 版,比較受到我注意的有 Serial 連線能力。

然後也有提到一些 cipher 效能改善的修正,我自己是覺得可能是還好吧!因為現在電腦都很快,除非是跑 sftp/scp 不然單純用 ssh 的話可能感覺不太出來。

嗯,既然在 cipher 有變動的話,也許以 PuTTY 為基礎的 WinSCP 接下來也會更著更新也不一定。