Is there a way on Linux to know uninstalled list of dependencies of a program downloaded in form of source code?
Assistant
When you download a program's source code on Linux, it often comes with a list of dependencies needed to build and run the program. These dependencies are typically listed in documentation files such as , , or specific build configuration files like , , or a file in the case of Python projects.
User
I use Debian and apt build-dep apparently known what dependencies to install but before I just need the list of missing dependencies. It seems that there should be a command to known it.
Assistant
To find out the list of missing build dependencies for a package on Debian-based systems without actually installing them, you can use apt-get combined with some additional command-line tools. The idea is to run the apt-get build-dep command in a way that gets the list of packages it would install but without applying any changes. Here's a method to achieve this:
First, ensure you have apt-rdepends installed. This tool is useful for recursively listing a package's dependencies:
The -s flag in apt-get runs the command in "simulate" mode, where it only shows what would happen without actually making any changes.
User
Good way. How to know a memory amount that is required for installation these new packages provided with apt-get -s build-dep ?
Assistant
To estimate the amount of memory required for installing new packages (specifically disk space, since memory usage during installation is usually not significant), you can use the simulation mode of apt-get combined with some additional processing to extract the relevant information. Here's how you can do it:
Use the apt-get -s command to simulate the build dependency installation and capture the disk space information:
apt-get -s build-dep <package-name>
Look for output lines that provide information about disk space:
Near the end of the output, you should see a line like "After this operation, X MB of additional disk space will be used.", which gives the total additional disk space required.
For a more concise command to extract just the disk space information, you can use grep and awk:
Output of apt-get -s build-dep doesn't have "MB" or "After this operation" data.
Assistant
If the apt-get -s build-dep <package-name> command does not provide the disk space usage information, there is another approach you can use to determine the approximate additional disk space required for installing the new packages.
Here's a more step-by-step approach to find out the disk space for these packages:
List the Packages: First, get the list of packages that will be installed using the apt-get -s build-dep command.
Check Disk Space for Each Package: Use the apt-cache command with the show option to list information about each package. This command includes the "Installed-Size" field, which tells you the disk space needed for each package when installed, measured in kilobytes.
README
INSTALL
configure.ac
CMakeLists.txt
requirements.txt
However, there's no direct command that lists uninstalled dependencies because dependency resolution and installation are typically managed by package managers. Still, you can follow these steps to identify what might be missing:
Check Documentation: Look for any README or INSTALL files included with the source code. These files often list required dependencies.
Configure Script: If the project uses the GNU Build System, running ./configure often checks for required dependencies and will report what is missing.
CMake: For CMake-based projects, running cmake will attempt to locate dependencies and report missing ones.
Manual Inspection: Look at the build scripts or configuration files. For instance:
configure.ac: This file often uses AC_CHECK_LIB or similar macros to check for libraries.
CMakeLists.txt: This file might contain find_package() or find_library() commands.
requirements.txt: For Python projects, this file lists Python packages required.
Use a Dependency Manager:
If the project supports a particular package manager (e.g., pip for Python, npm for Node.js, bundler for Ruby), use it to install dependencies automatically.
For compiled languages, you might use pkg-config to find what libraries might be needed and ensure they are installed.
Check Log Outputs: After running the build command, check for errors in the output logs to identify which libraries or programs are missing.
Build Dependency Tools:
apt-get build-dep (Debian/Ubuntu): If the software is available in the repositories, you might use this to install all build dependencies with sudo apt-get build-dep <package-name>.
dnf builddep (Fedora) or yum (CentOS/Red Hat): Similar to apt-get, used for installing build dependencies.
In summary, identifying uninstalled dependencies for source code projects involves checking documentation, analyzing configuration scripts, and using available system tools or package managers to help install what’s needed.
Using grep "^Inst" extracts lines where apt-get indicates an intention to install a package that isn't currently installed (these lines start with Inst).
To get a cleaner list of just the package names (without additional information), you can further filter the output:
This uses awk to print the second field from each line, which corresponds to the package name.
This approach effectively provides a list of missing build dependencies for a specified package, allowing you to review them before any installation is attempted.
This command will output something like "XYZ MB", indicating the amount of additional disk space needed.
By simulating this process, you get a good estimate of the disk space required without actually making any changes to your system.
This approach allows you to see and plan for the disk space requirements of new packages before proceeding with the actual installation.
Here's how you can sum up the disk space:
apt-get -s build-dep <package-name> | grep "^Inst" | awk '{print $2}' | xargs apt-cache show | grep "Installed-Size" | awk '{total += $2} END {print total " KB"}'
xargs apt-cache show runs apt-cache show on each package name extracted.
grep "Installed-Size" filters only lines containing the disk size.
awk '{total += $2} END {print total " KB"}' sums up the sizes and prints the total in kilobytes.
This command gives you an approximate total disk space requirement for the new packages. Note that this size is for the installed packages only; it does not account for temporary space used during installation, like package archives (which are typically removed after installation).