Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a Debian package's Build-Depends and Depends

If I have a debian/control file with Build-Depends and Depends entries.

How do I install both sets of dependencies?

At the moment I'm using the following command to create a stub package that depends on the Build-Depends but not the Depends.

$ mk-build-deps --build-dep \
&& dpkg -i *.deb \
|| apt-get update && apt-get install --fix-broken --yes \
like image 238
Joshua Barnett Avatar asked Dec 04 '17 11:12

Joshua Barnett


People also ask

How do I check deb package dependencies?

If you have downloaded a DEB package on your system and want to know which dependencies will be installed along with the package, you can use the -I (capitalized i, not lowercase L) or --info flag with the command.

Which command is used to install a Debian package?

Install Software Using Dpkg Command Dpkg is a package manager for Debian and its derivatives such as Ubuntu and Linux Mint. It is used to install, build, remove and manage . deb packages.


1 Answers

Assuming this is a standard package in your apt repositories, you should be able to simply run

apt-get build-dep PACKAGE [PACKAGE…]

Generally speaking, the best solution is to find a package with the same dependencies (better yet, an identical yet different version of the same package) and just build-dep it. This solves 99+% of these issues in my experience.


I don't know mk-build-deps at all, but you can run this to see what dependencies are called out in the debian/control file in package "PACKAGE":

echo $(awk '
  /^(Build-)?Depends:/ || /^ / && deps {
    sub(/^[^ ]+: /, "")
    deps = 1
    dep_str = dep_str ", " $0
    next
  }
  { deps=0 }
  END {
    split(dep_str, dep_array, /, */)
    for (d in dep_array) {
      dep = dep_array[d]
      gsub(/[^a-z0-9_.-].*$/, "", dep)
      if (dep && !seen[dep]++) print dep
    }
  }' PACKAGE/debian/control)

(This examines the Debian control file for Build-Depends and Depends lines and presents just the dependencies that are listed, excluding any variables (which I believe are already included in other hits from the file).

AWK code walkthrough: If it is a Build-Depends or Depends line, or it's a whitespace-indended line following such a line, remove the line label, note we're in a dependency line (dep = 1), and save it into dep_str. On other lines, remove the marker saying we're continuing a dependency line. After parsing the input, split the dependency string dep_str into an array delimited by commas and optional trailing whitespace, then iterate through that array. Scrub invalid characters from the end of the dependency name (these are version info) and if anything remains and hasn't been seen (here) before, print it on its own line.

Replace echo with apt-get install if you like, but you might need to prune out the items you're looking to customize and/or manually install first.

After that, you should have an easier time with dpkg -i *.deb. Feel free to try apt-get install --fix-broken at any time if you're stuck.

like image 79
Adam Katz Avatar answered Jan 02 '23 20:01

Adam Katz