大量的試驗和在此錯誤後是什麼似乎工作最好暫且:
期間(後)安裝時間
我做的sqlite的DB文件被生成該文件的postinst內,使用的bash腳本,並使用表的建立和主/外鍵賦值語句常數如下
#!/bin/bash
set -e
CREATE_TBL_PROBLEMS="CREATE TABLE tblProblems(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Name TEXT NOT NULL UNIQUE
)"
CREATE_TBL_MAIN="CREATE TABLE tblMain (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
DBVersion TEXT NOT NULL,
DBrDate TEXT NOT NULL)"
CREATE_TBL_EVENTS="CREATE TABLE tblEvents (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
User TEXT NOT NULL,
NoOfInfections INTEGER NOT NULL,
NoOfHealings INTEGER NOT NULL,
DateTime TEXT NOT NULL,
VirusDBID INTEGER NOT NULL,
FOREIGN KEY(tblMainID) REFERENCES tblMain(ID)
)"
CREATE_TBL_ISSUES="CREATE TABLE tblIssues (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
FilePath TEXT NOT NULL,
Inode INTEGER NOT NULL UNIQUE,
ScanEventID INTEGER NOT NULL,
MalwareID INTEGER NOT NULL,
FOREIGN KEY(EventID) REFERENCES tblEvents(ID),
FOREIGN KEY(ProblemID) REFERENCES tblProblems(ID)
)"
主要挑戰如下:應用程序應該放在由root擁有的/ usr/share/myapplication中,而常用的做法是,並且db文件(sqlite)應該是用戶擁有的文件。所以後者被放置在/ home/user1 /中。所有MyApplication如下:
USER_HOME=$(eval echo ~${SUDO_USER})
echo "USER HOME IS " ${USER_HOME}
case "$1" in
configure)
mkdir -p "${USER_HOME}"/.myapplication
echo "Creating tables needed for myapplication"
sqlite3 "${USER_HOME}"/.myapplication/mydbfile.sqlite "${CREATE_TBL_MAIN}; ${CREATE_TBL_EVENTS}; ${CREATE_TABLE_ISSUES}; ${CREATE_TBL_PROBLEMS}"
echo "Assigning myapplication.sqlite file to user " "${SUDO_USER}"
chown -R "${SUDO_USER}":"${SUDO_USER}" "${USER_HOME}"/.myapplication/
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
所有MyApplication的安裝是照顧內規則文件的通過連續調用安裝-m
關於依賴性,Tshepang是對的,就應該在控制文件中聲明。 但是,我還沒有弄清楚,在某些情況下(機器),如果它們丟失,它們會自動安裝,而在其他情況下,只要依賴包丟失,安裝就會中止。