如何跟踪 Linux 中已安装的软件/系统配置,以便在全新安装 Linux 后可以恢复?

如何跟踪 Linux 中已安装的软件/系统配置,以便在全新安装 Linux 后可以恢复?

我一直在考虑为 Linux 编写某种实用程序来跟踪我安装的所有软件和配置。在进行全新安装后,我可以运行它,并将我的 Ubuntu 副本恢复为全新安装之前的状态。

我不知道到底从哪里开始。我知道您可以从 获取用户安装的软件列表dpkg -i | grep ii

答案1

Debian 及其后代有一个工具,允许您创建简单的包(仅具有依赖项)。它非常适合这项工作。

它的名字叫equivs-build(我不知道这个名字从何而来)。它将创建一个.deb.你可以安装它gdebi

这是一个 makefile(如果需要,您可以手动执行。make 文件只增加了 10% 的便利,但记录了过程。)

#create source
%.equivs-control: src/%.equivs-control
        @echo %linking "$@" from "$<"
        ln -s -t . "$<"

#make deb
%.deb: %.equivs-control
        @echo %making "$@" from "$<"
        equivs-build "$<"

#install one
.PHONY: %.install
%.install: %.deb
        @echo %installing "$<"
        sudo gdebi "$<"

但首先您需要安装一些工具。

#!/bin/bash
ln -fs -T ../equivs src
ln -fs -t . src/makefile

#install what we need
sudo apt-get install equivs gdebi-core make

一个配置文件src/my-packages_1.0_all.equivs-control

Section: local
Priority: optional
#Homepage: https:
Standards-Version: 3.9.2
Package: my-packages
Version: 1.0
Maintainer: ctrl-alt-delor@local>

Depends: python3-pystache, equivs, make, gdebi-core, intel-microcode, firmware-linux, multiarch-support, cpufrequtils, openssh-server, stow, etckeeper, ntp, bomstrip, nodejs, dos2unix, faketime, wget, nocache, schedtool, cpulimit, smem, inotify-tools, keepassx, mawk, mmv, yakuake, xdotool, acl, gparted, gufw, htop, sshfs, bindfs, k4dirstat, openssh-client, vim, rsync, emacs, vim, avahi-discover, yaml-mode, markdown, pandoc, dc, xinput, iotop, strace, curl, screen, kdesdk-dolphin-plugins, cvs, easygit, git, git-flow, git-gui, gitg, tig, kdesvn, subversion, hgview, mercurial-common, tortoisehg-nautilus, python-dulwich, task-british-desktop, task-british-kde-desktop, task-desktop, task-english, task-kde-desktop, task-laptop, redshift-plasmoid, gtk2-engines-oxygen, kde-config-gtk-style, kde-config-gtk-style-preview, libreoffice-style-oxygen, appmenu-qt, vlc, konversation, encfs, diffpdf, diffuse, dirdiff, kdiff3, meld, tor, idle3, ipython3-qtconsole, backintime-kde, couchapp, augeas-lenses, augeas-tools, augeas-doc, python3-augeas, sass-elisp, ruby-sass, eclipse-jdt, eclipse-mercurialeclipse, python3-requests, filepp, texlive-latex-base, texlive-latex-extra, tth, golang-mode, zenmap, wireshark

# Readme: <README.Debian file; defaults to a generic one>
Description: All of the stuff I want installed.
 This is managed by my install script system.

要使用: - 运行 shell 脚本(这会启动此安装系统) - 运行make my-packages_1.0_all.install

如果弄乱文件名,请小心,部分来自Package: line,部分内置于工具中。


还有其他配置管理工具可以做更多的事情,值得一看。

相关内容