Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions apt-private/private-install.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,51 @@ bool InstallPackages(CacheFile &Cache, APT::PackageVector &HeldBackPackages, boo
if (_config->FindI("quiet",0) < 2 &&
_config->FindB("APT::Get::Assume-Yes",false) == false)
{
if (YnPrompt(_("Do you want to continue?")) == false)
{
c2out << _("Abort.") << std::endl;
exit(1);
bool dangerousPrompt = false;
if (_config->FindB("APT::Get::AutomaticRemove", false))
{
// Define the list of dangerous package name prefixes
const char* dangerousPrefixes[] = {
"deepin-", "dde-", "linux-headers-", "linux-image-",
"systemd", "xserver-", "nvidia-", "mesa-"
};
const size_t prefixCount = sizeof(dangerousPrefixes) / sizeof(dangerousPrefixes[0]);

for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); !Pkg.end(); ++Pkg)
{
if (!Cache[Pkg].Delete())
continue; // Only check packages marked for deletion

const char* pkgName = Pkg.Name();
for (size_t i = 0; i < prefixCount; ++i)
{
// Check if the package name prefix matches the dangerous list
if (strncmp(pkgName, dangerousPrefixes[i], strlen(dangerousPrefixes[i])) == 0)
{
dangerousPrompt = true;
goto foundDangerous;
}
}
}
}
foundDangerous:

if (dangerousPrompt)
{
const char *redPrompt = _("\033[31mThe current uninstallation operation involves system-critical packages. Continuing may cause system instability. Are you sure you want to continue?\033[0m");
if (YnPrompt(redPrompt) == false)
{
c2out << _("Abort.") << std::endl;
exit(1);
}
}
else
{
if (YnPrompt(_("Do you want to continue?")) == false)
{
c2out << _("Abort.") << std::endl;
exit(1);
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
apt (2.8.0deepin3) unstable; urgency=medium

* add a prompt for uninstalling critical system packages

-- lhdjply <[email protected]> Mon, 23 Jun 2025 12:01:10 +0800

apt (2.8.0deepin2) unstable; urgency=medium

* add a warning regarding `apt upgrade' usage.
Expand Down
6 changes: 6 additions & 0 deletions po/apt-all.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr ""

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr ""
Expand Down
6 changes: 6 additions & 0 deletions po/apt.c.pot
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr ""

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: cmdline/apt-mark.cc:340
#, c-format
msgid "%s was already set on hold.\n"
Expand Down
6 changes: 6 additions & 0 deletions po/apt.pot
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr ""

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc:373
msgid "Abort."
msgstr ""
Expand Down
6 changes: 6 additions & 0 deletions po/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "هل تريد الاستمرار؟"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "إجهاض."
Expand Down
6 changes: 6 additions & 0 deletions po/ast.po
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "¿Quies continuar?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Encaboxar."
Expand Down
6 changes: 6 additions & 0 deletions po/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Искате ли да продължите?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Прекъсване."
Expand Down
6 changes: 6 additions & 0 deletions po/bs.po
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Da li želite nastaviti?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Odustani."
Expand Down
6 changes: 6 additions & 0 deletions po/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Voleu continuar?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Avorta."
Expand Down
6 changes: 6 additions & 0 deletions po/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Chcete pokračovat?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Přerušeno."
Expand Down
6 changes: 6 additions & 0 deletions po/cy.po
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Ydych chi eisiau mynd ymlaen?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Erthylu."
Expand Down
6 changes: 6 additions & 0 deletions po/da.po
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Vil du fortsætte?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Afbryder."
Expand Down
6 changes: 6 additions & 0 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Möchten Sie fortfahren?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Abbruch."
Expand Down
6 changes: 6 additions & 0 deletions po/dz.po
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "ཁྱོན་ཀྱི་འཕྲོ་མཐུད་ནི་འབད་ནི་ཨིན་ན་"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "བར་བཤོལ་འབད།"
Expand Down
6 changes: 6 additions & 0 deletions po/el.po
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Θέλετε να συνεχίσετε;"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Εγκατάλειψη."
Expand Down
6 changes: 6 additions & 0 deletions po/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "¿Desea continuar?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Anulado."
Expand Down
6 changes: 6 additions & 0 deletions po/eu.po
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Aurrera jarraitu nahi al duzu?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Abortatu."
Expand Down
6 changes: 6 additions & 0 deletions po/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Haluatko jatkaa?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Keskeytä."
Expand Down
6 changes: 6 additions & 0 deletions po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Souhaitez-vous continuer ?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Annulation."
Expand Down
6 changes: 6 additions & 0 deletions po/gl.po
Original file line number Diff line number Diff line change
Expand Up @@ -1967,6 +1967,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Quere continuar?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Interromper."
Expand Down
6 changes: 6 additions & 0 deletions po/hu.po
Original file line number Diff line number Diff line change
Expand Up @@ -2014,6 +2014,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Folytatni akarja?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Megszakítva."
Expand Down
6 changes: 6 additions & 0 deletions po/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Continuare?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Interrotto."
Expand Down
6 changes: 6 additions & 0 deletions po/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "続行しますか?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "中断しました。"
Expand Down
6 changes: 6 additions & 0 deletions po/km.po
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "តើ​អ្នក​ចង់​បន្តឬ​ [បាទ ចាស/ទេ​] ? "

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "បោះបង់ ។"
Expand Down
6 changes: 6 additions & 0 deletions po/ko.po
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "계속 하시겠습니까?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "중단."
Expand Down
6 changes: 6 additions & 0 deletions po/ku.po
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,12 @@ msgstr ""
msgid "Do you want to continue?"
msgstr "Dixwazî bidomînî?"

#: apt-private/private-install.cc
msgid "\033[31mThe current uninstallation operation involves system-critical "
"packages. Continuing may cause system instability. Are you sure you "
"want to continue?\033[0m"
msgstr ""

#: apt-private/private-install.cc
msgid "Abort."
msgstr "Betal."
Expand Down
Loading
Loading