我找不到关于 Debian 软件包在被删除时应该如何表现的确切信息。它应该删除数据吗?例如对于 mysql,我读到数据保留这对我来说听起来很合逻辑(使用清除将删除所有内容)。
但这里我找到了以下文字:
remove 和 purge 之间的区别在于,remove 只会删除数据和可执行文件,而 purge 还会删除所有配置文件。
那么,事实到底是什么呢?
更新 如我所愿为 ElasticSearch 打包一个我需要知道期望是什么。
答案1
清除或删除都不会删除 mysql 数据目录。参见示例
root@mail:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 34
Server version: 5.1.41-3ubuntu12.10 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database so;
Query OK, 1 row affected (0.00 sec)
mysql> use so;
Database changed
mysql> CREATE TABLE example_autoincrement (
-> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> data VARCHAR(100)
-> );
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO example_autoincrement (data) VALUES ('Hello world');
Query OK, 1 row affected (0.00 sec)
mysql> Bye
root@mail:~# apt-get remove mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libnet-daemon-perl libdbi-perl libhtml-template-perl mysql-server-core-5.1 mysql-client-core-5.1 libdbd-mysql-perl libplrpc-perl mysql-server-5.1 mysql-client-5.1
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
mysql-server
0 upgraded, 0 newly installed, 1 to remove and 49 not upgraded.
After this operation, 131kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 52161 files and directories currently installed.)
Removing mysql-server ...
root@mail:~# ls /var/lib/mysql/
debian-5.1.flag ibdata1 ib_logfile0 ib_logfile1 mail.pid mysql mysql_upgrade_info so
root@mail:~# apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
mysql-server
0 upgraded, 1 newly installed, 0 to remove and 49 not upgraded.
Need to get 94.8kB of archives.
After this operation, 131kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main mysql-server 5.1.41-3ubuntu12.10 [94.8kB]
Fetched 94.8kB in 0s (98.4kB/s)
Selecting previously deselected package mysql-server.
(Reading database ... 52158 files and directories currently installed.)
Unpacking mysql-server (from .../mysql-server_5.1.41-3ubuntu12.10_all.deb) ...
Setting up mysql-server (5.1.41-3ubuntu12.10) ...
root@mail:~# /etc/init.d^C
root@mail:~# service mysql start
start: Job is already running: mysql
root@mail:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.1.41-3ubuntu12.10 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| so |
+--------------------+
3 rows in set (0.00 sec)
mysql> Bye
root@mail:~# apt-get purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libnet-daemon-perl libdbi-perl libhtml-template-perl mysql-server-core-5.1 mysql-client-core-5.1 libdbd-mysql-perl libplrpc-perl mysql-server-5.1 mysql-client-5.1
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
mysql-server*
0 upgraded, 0 newly installed, 1 to remove and 49 not upgraded.
After this operation, 131kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 52161 files and directories currently installed.)
Removing mysql-server ...
root@mail:~#
root@mail:~#
root@mail:~# ls /var/lib/mysql/
debian-5.1.flag ibdata1 ib_logfile0 ib_logfile1 mail.pid mysql mysql_upgrade_info so
root@mail:~#
答案2
我认为它所指的“数据”是软件包中附带的任何不可执行资源,例如 /usr/share 中找到的内容。您是否特别关注 mysql 或其他软件包?
如果数据对您来说很重要,那么您无论如何都应该备份它。
答案3
因为我想为 ElasticSearch 打包一个,所以我需要知道预期是什么。
如果我理解正确的话,您正在将 ElasticSearch 打包为 .deb 以供分发。
如果是这种情况,并且你正在构建一个用于公开分发的 .deb 包,我建议你 1) 完整阅读关于打包的相关章节Debian 开发者参考并在适当的 Debian 邮件列表(可能是 Debian-Developer)上询问。
一般来说,remove
只会删除与软件包相关的二进制文件和库,而purge
将删除二进制文件、库、文档和配置文件。如果软件包在至少事先不通知用户的情况下销毁用户数据,则被认为是不礼貌的行为。
我真的建议您在决定如何继续之前先咨询一位经验丰富的 Debian 维护者 - 特别是如果您想将此包提交到 Debian 存储库。
另一个说法:作为一名长期的 Debian 用户,几乎没有什么比第三方以 .deb 形式分发其软件更让我恼火的了,而这不符合标准的 Debian 惯例。如果您想留住用户,请确保您的软件包得到良好维护并符合 Debian 团队制定的准则。