postinst는 debconf 때문에 항상 실패합니다.

postinst는 debconf 때문에 항상 실패합니다.

내 패키지에 debconf를 사용하는 데 문제가 있습니다. package.config 파일에서 mysql 비밀번호를 요청합니다.

. /usr/share/debconf/confmodule
db_input high mypkg/mysql_root_pw
db_go

그런 다음 postinst에서 debconf에 비밀번호를 요청하고 이를 구성 파일에 씁니다.

. /usr/share/debconf/confmodule
db_get mypkg/mysql_root_pw
# write pw to config file

내가 할 때 이것은 작동합니다 dpkg-reconfigure --force mypkg. 그러나 사용할 때 apt-get -f install(내 pkg가 손상되었다고 표시되기 때문에 수행해야 함) 항상 실패합니다.

Setting up mypkg (1.5.4-3) ...
debconf (developer): frontend started
debconf (developer): frontend running, package name is mypkg
debconf (developer): starting /var/lib/dpkg/info/mypkg.config configure 
debconf (developer): <-- INPUT low mypkg/mysql_root_pw
debconf (developer): --> 30 question skipped
dpkg: error processing mypkg (--configure):
 subprocess installed post-installation script returned error exit status 30
Errors were encountered while processing:
 mypkg

스크립트를 편집했는데 /var/lib/dpkg/info/mypkg.postinstdebconf 라이브러리를 소스로 사용하는 줄에서 오류가 발생합니다.

. /usr/share/debconf/confmodule

이는 아마도 debconf가 원래 설치의 값을 이미 갖고 있고 질문을 다시 표시하지 않기 때문일 것입니다. 하지만 이미 가지고 있는지 묻는 것을 어떻게 건너뛸 수 있으며 왜 그럴 때가 아니라 해당 줄에서 실패합니까 db_get?

Google에서 검색했는데 이에 대한 유용한 정보를 많이 찾을 수 없는 것 같습니다.

답변1

그래서 마침내 이 작업을 수행하게 되었습니다. debconf에 이미 값이 있으면 postinst에서 첫 번째 질문을 받을 때 debconf가 항상 실패합니다. 마침내 내 시스템에 있는 다른 패키지의 postinst 및 구성 파일을 확인하려는 (명백한) 아이디어가 생겼고 이것이 비결입니다.

귀하의 구성에서

. /usr/share/debconf/confmodule
db_input high mypkg/mysql_root_pw || true
db_go || true

그게 다야. 내 postinst debconf에서 값을 요청하면 만족됩니다. 분명히 어떤 값도 얻지 못할 때를 처리해야 합니다.

또한 postinst에 a를 추가했는데 db_stop, 필요한지는 모르겠지만 완성을 위해 추가하겠습니다.

mypkg.postinst

. /usr/share/debconf/confmodule
db_get mypkg/mysql_root_pw
mysql_root_pw=$RET
db_get mypkg/some_other_value
some_other_value=$RET
db_stop
# do something with the $mysql_root_pw and $some_other_value vars

이것이 언젠가 다른 사람에게 도움이 되기를 바랍니다.

건배

관련 정보