Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2021-01-04 10:14:50 +08:00
commit 13e221e037
6 changed files with 413 additions and 208 deletions

View File

@ -1,189 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (FSSlc)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Check Dependencies of a Package in Ubuntu/Debian-based Linux Distributions)
[#]: via: (https://itsfoss.com/check-dependencies-package-ubuntu/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
How to Check Dependencies of a Package in Ubuntu/Debian-based Linux Distributions
======
Installing applications via command line is quite easy in Ubuntu/Debian. All you need to do is to use apt install package_name.
But what if you want to know the dependencies of a package before or after installing it?
In this tutorial, Ill show you various ways to see the dependencies of a package in Ubuntu and other Debian-based Linux distributions that use [APT package management system][1].
### What is package dependency in Ubuntu?
If you didnt know already, when you install a software package in Linux, sometimes, it needs other packages to function properly. These additional packages are called dependencies. If these dependency packages are not installed on the system, it is usually installed automatically with the package.
For example, the [GUI tool HandBrake for converting video formats][2] needs [FFmpeg][3], [GStreamer][4]. So for HandBrake, FFmpeg and GStreamer are the dependencies.
If you dont have these packages installed on your system, they will be automatically installed when you [install HandBrake on Ubuntu][5].
### Check dependencies of a package in Ubuntu and Debian based distributions
As it often happens in Linux, there are more than one way to achieve the same result. Lets see various ways to see the dependencies of a package.
#### Checking dependencies with apt show
You can use the [apt show command][6] to display details of a package. Part of this information is dependencies and you can see it in the line starting with Depends.
For example, heres what it shows for [ubuntu-restricted-extras][7] package.
```
[email protected]:~$ apt show ubuntu-restricted-extras
Package: ubuntu-restricted-extras
Version: 67
Priority: optional
Section: multiverse/metapackages
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 14.3 kB
Depends: ubuntu-restricted-addons
Recommends: libavcodec-extra, ttf-mscorefonts-installer, unrar
Download-Size: 3,200 B
APT-Manual-Installed: yes
APT-Sources: http://us.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages
Description: Commonly used media codecs and fonts for Ubuntu
This collection of packages includes:
- MP3 and other audio codec software to play various audio formats
(GStreamer plugins)
- software to install the Microsoft Web fonts
- the Adobe Flash plugin
- LAME, software to create compressed audio files.
.
This software does not include libdvdcss2, and will not let you play
encrypted DVDs. For more information, see
https://help.ubuntu.com/community/RestrictedFormats/PlayingDVDs
.
These software packages are from the Multiverse channel, restricted by
copyright or legal issues in some countries. For more information, see
http://www.ubuntu.com/ubuntu/licensing
```
As you can see, ubuntu-restricted-extras package depends on ubuntu-restricted-addons package.
Heres a catch! The dependency package may also depend on some other package and the chain could go on. Thankfully, the APT package manager handles this for you by automatically installing all the dependencies (most of the time).
What is recommended package?
Did you notice the line starting with Recommends in the above output?
Recommended packages are not direct dependencies for the package but they enable additional features.
As you can see, ubuntu-restricted-extras has ttf-mscorefonts-installer as recommended package for installing Microsoft Fonts on Ubuntu.
The recommended packages are also installed by default and if you explicitly want to forbid the installation of recommended package, use the no-install-recommends flag like this:
sudo apt install no-install-recommends package_name
#### Use apt-cache for getting just the dependencies information
The apt show has way too many information. If you want to get the dependencies in a script, the apt-cache command gives you a better and clean output.
```
apt-cache depends package_name
```
The output looks much clean, does it not?
![][8]
#### Check the dependencies of a DEB file using dpkg
Both apt and apt-cache command works on the packages that are available from the repositories. But if you download a DEB file, these command wont work.
In this case, you can use the dpkg command with -I or info option.
```
dpkg -I path_to_deb_file
```
The dependencies can be seen in the line starting with Depends.
![][9]
#### Checking dependencies and reverse dependencies with apt-rdepends
If you want more details on the dependencies, you can use the apt-rdepends tool. This tool creates the complete dependency tree. So, you get the dependency of a package and the dependencies of the dependencies as well.
It is not a regular apt command and youll have to install it from the universe repository:
```
sudo apt install apt-rdepends
```
The output is usually quite large depending on the dependency tree.
```
Reading package lists... Done
Building dependency tree
Reading state information... Done
shutter
Depends: procps
Depends: xdg-utils
imagemagick
Depends: imagemagick-6.q16 (>= 8:6.9.2.10+dfsg-2~)
imagemagick-6.q16
Depends: hicolor-icon-theme
Depends: libc6 (>= 2.4)
Depends: libmagickcore-6.q16-6 (>= 8:6.9.10.2)
Depends: libmagickwand-6.q16-6 (>= 8:6.9.10.2)
hicolor-icon-theme
libc6
Depends: libcrypt1 (>= 1:4.4.10-10ubuntu4)
Depends: libgcc-s1
libcrypt1
Depends: libc6 (>= 2.25)
```
The apt-rdepends tool is quite versatile. It can also calculate the reverse dependencies. Which means, you can see what other packages depend on a certain package.
```
apt-rdepends -r package_name
```
The output could be pretty big because it will print the reverse dependency tree.
```
[email protected]:~$ apt-rdepends -r ffmpeg
Reading package lists... Done
Building dependency tree
Reading state information... Done
ffmpeg
Reverse Depends: ardour-video-timeline (>= 1:5.12.0-3ubuntu4)
Reverse Depends: deepin-screen-recorder (5.0.0-1build2)
Reverse Depends: devede (4.15.0-2)
Reverse Depends: dvd-slideshow (0.8.6.1-1)
Reverse Depends: green-recorder (>= 3.2.3)
```
I hope this quick tutorial was helpful in improving your command line knowledge a bit. Stay tuned for more such tips.
--------------------------------------------------------------------------------
via: https://itsfoss.com/check-dependencies-package-ubuntu/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://wiki.debian.org/Apt
[2]: https://itsfoss.com/handbrake/
[3]: https://ffmpeg.org/
[4]: https://gstreamer.freedesktop.org/
[5]: https://itsfoss.com/install-handbrake-ubuntu/
[6]: https://itsfoss.com/apt-search-command/
[7]: https://itsfoss.com/install-media-codecs-ubuntu/
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/apt-check-dependencies-ubuntu.png?resize=800%2C297&ssl=1
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/check-dpendencies-of-deb-package.png?resize=800%2C432&ssl=1

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,113 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (7 enlightening talks from All Things Open 2020)
[#]: via: (https://opensource.com/article/21/1/ato-2020)
[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja)
7 enlightening talks from All Things Open 2020
======
There are more than 250 videos available to watch from the All Things
Open conference; here are some ideas on where to begin.
![Tips and gears turning][1]
[All Things Open][2], a technology conference held in October every year, is always a wonderful learning experience. For 2020, the conference shifted to an online format, which had its ups and downs. The chance encounters with acquaintances in the hallways and having lunch with friends were noticeably absent, but the learning experience was as good as always. Honestly, in some ways, it was better because everyone got a front-row seat, and there were no standing-room-only talks.
One major advantage of the online format was that all of the talks were recorded, so people who missed the conference can watch the hundreds of talks available in an [All Things Open 2020 playlist][3] on YouTube.
Hundreds of talks is a lot, so to provide some suggestions of where to start, I'll briefly cover seven of the talks I attended. I also attended an excellent talk by Opensource.com's Jen Wike Huger about how to write an article, but I will let her explain her talk [in her own words][4].
The talks I attended made for an informative and jam-packed two-day conference experience but are only a tiny fraction of what All Things Open 2020 offered. I hope you will take the opportunity to watch some of the talks below and explore the conference's offerings for other talks that interest you.
If you watched another talk that really interested you, please share it in a comment so that others can benefit from your recommendation.
## [MySQL indexes, histograms, locking options, and other ways to speed up your queries][5]
This extended, 90-minute talk by Dave Stokes explores the "very dry" (his words) parts of working with [MySQL][6] databases. Everyone notices when the database runs too slow, but nobody complains when the database is too fast. Stokes explains how to use indexes, histograms, locking options, and other methods to improve the performance of queries in a MySQL database.
As Stokes notes in his introduction, this talk covers a lot of information, so being able to pause, rewind, and rewatch is very helpful. However, it is also worth noting that Stokes assumes that the person watching the talk has a good level of experience with MySQL and databases in general. As such, he did not cover basic optimizations like normalizing data nor lower-level system-configuration optimizations at the operating system level. Intentional limits aside, this talk is still very, very deep. If you are interested in database optimization, you will probably want to watch this talk a few times.
## [Containers in depth—understanding how containers work to better work with them][7]
If you work with Linux containers and know your way around [Docker][8] and similar tools but do not yet have a deep understanding of what is going on beneath the surface, Brent Laster's in-depth talk about how containers work is the talk for you. It covers what containers are and their benefits; how containers are constructed; the differences between layers, images, and containers; what immutability really means; the core Linux functionalities that containers are based on; and more. This talk covers a lot in only 43 minutes but provides a detailed, technical overview of each topic.
Separately, Laster presented a much longer, more detailed talk about containers that stretches over four sessions. This three-and-half hour extended session, [All things containers—Docker, Kubernetes, Helm, Istio, GitOps, and more][9], is worth watching if you want to explore containers by following a hands-on tutorial.
## [Why Postgres][10]
How does [PostgreSQL][11], a database project with a history dating to 1989, stack up to newer competitors? Craig Kerstiens provides an answer to that question in his talk covering the history and current features of PostgreSQL.
Kerstiens covers datatypes, indexing, extensions, foreign data wrappers, and more in his succinct yet thorough overview of what PostgresSQL has to offer. He explains how PostgreSQL added support for JSON and discusses several other supported datatypes, including "money," which dates back to when the "world was flat." It is fascinating and refreshing to see newer features described alongside honest critiques of legacy features. He also explains full-text search support, the PostGIS extension for providing geospatial database support, and other interesting advanced features.
I have used PostgreSQL a lot over the years, but I still learned many new things by watching this talk. Most of my database work with PostgreSQL has been very conservative, fairly basic SQL database kinds of things, so I really look forward to trying out some of the things I learned about in this talk.
## [Dungeons, dragons, and graph databases][12]
Using one niche thing to explain another niche thing can either go horribly wrong or be absolutely brilliant. If you have even a passing familiarity with [Dungeons &amp; Dragons][13] and want to learn about graph databases, specifically [RedisGraph][14], Guy Royse's talk is in the brilliant category. Royse's method of using a dungeon crawl to relay the advantages of a graph database is a great way to describe the key concepts.
Royse starts by explaining what a graph is in this context by using a 20-sided die as an example; a graph is made of vertices and edges, with the vertices being the points where the sides of the die meet and the edges being the lines connecting the points. The talk then uses the concepts of finding all the loot and slaying all the monsters in a dungeon as examples to explain a variety of features. To further explain the advantages of using graph databases, Royse provides examples of how a traditional SQL database might structure the same queries.
Although this talk is super-niche, it was extremely fun. It will not be for everyone, but it makes learning about graph databases easy if you are familiar with the subject matter used in the examples. Even if you are not into Dungeons &amp; Dragons (or similar role-playing games), the examples are clear enough but might not resonate with you as much as other examples might.
## [Understanding MySQL concepts][15]
This talk by Matthias Crauwels covers the features of [MySQL 8.0, Community Server Edition][16] and some of the differences between MySQL, [MariaDB][17], and the [Percona Distribution for MySQL][18]. Unfortunately, in the video, the 45-minute session is reduced to a 25-minute video and skips from Crauwels saying hello all the way to slide 21. The portions of the talk in the video cover MyISAM vs. InnoDB storage engines, other storage engines, replication, binary logs, and global transaction IDs.
Some of the differences between MySQL and MariaDB that are discussed are how MySQL does not support PL/SQL while MariaDB understands a subset of PL/SQL and how MySQL and MariaDB have different implementations for global transaction IDs.
## [Digitizing 125 years of images][19]
[The New York Times][20] has an archive of photographs that covers 125 years. To say its archival collection is huge would be an understatement. In this talk, Suman Roy and William P. Davis discuss the work involved in digitizing that collection to make it more accessible.
The physical photo archives at The New York Times are organized using traditional archival organizational methods, which are similar to, but not exactly like, the card catalogs that used to be found in libraries. This makes finding things in the archives a time-consuming experience. By moving the collection into the digital realm, the collection becomes easier and quicker to use.
Roy and Davis cover many of the technical issues involved in the digitization process. Most notably, they describe various scanning and optical character recognition (OCR) issues. While most people will never need to digitize a collection anywhere near the size of The New York Times' archive, the insights the speakers share apply to digitization projects of any size.
## [Building streaming data apps with Pac-Man][21]
Ricardo Ferreira brings some much-needed interactivity to this year's online All Things Open with his demonstration of [ksqlDB][22], a streaming database for [Apache Kafka][23], using an online [Pac-Man][24] game. During the talk, he had the audience play Pac-Man, showed how the information from our games was being tracked, and used that data to construct an online leaderboard for the game while we watched. Sadly, watching the video will not have the same effect, and the Pac-Man game linked in the talk is no longer online, but this talk is still a very interesting and informative way to explain streaming databases.
* * *
_All Things Open's next scheduled event is [Open Source 101][25], March 20, 2021, in Austin, Texas. Click the link to learn more about this one-day educational conference covering the processes and tools foundational to open source, open tech, and the open web._
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/1/ato-2020
作者:[Joshua Allen Holm][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/holmja
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/gears_devops_learn_troubleshooting_lightbulb_tips_520.png?itok=HcN38NOk (Tips and gears turning)
[2]: https://allthingsopen.org
[3]: https://www.youtube.com/playlist?list=PL6kQg8bP1Ji7xCxUtnto4e6vtFiB33bUq
[4]: https://opensource.com/article/20/11/how-write-article
[5]: https://www.youtube.com/watch?v=zhg1b8IKWzw
[6]: https://www.mysql.com/
[7]: https://www.youtube.com/watch?v=6yycoCmx9Hc
[8]: https://opensource.com/resources/what-docker
[9]: https://www.youtube.com/watch?v=_9ppmg9NF80
[10]: https://www.youtube.com/watch?v=C5hd8HyC0YI
[11]: https://www.postgresql.org/
[12]: https://www.youtube.com/watch?v=X59DEx-4i74
[13]: https://dnd.wizards.com/
[14]: https://github.com/RedisGraph/RedisGraph
[15]: https://www.youtube.com/watch?v=yZMP2sk8qKI
[16]: https://dev.mysql.com/downloads/mysql/
[17]: https://mariadb.org/
[18]: https://www.percona.com/software/mysql-database
[19]: https://www.youtube.com/watch?v=Qxv7ADhE4m0
[20]: https://www.nytimes.com/
[21]: https://www.youtube.com/watch?v=bYn0VLWpWJM
[22]: https://ksqldb.io/
[23]: https://kafka.apache.org/
[24]: https://en.wikipedia.org/wiki/Pac-Man
[25]: https://opensource101.com/

View File

@ -0,0 +1,93 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How open principles will impact the future of work)
[#]: via: (https://opensource.com/open-organization/21/1/open-is-future-of-work)
[#]: author: (Ron McFarland https://opensource.com/users/ron-mcfarland)
How open principles will impact the future of work
======
In many ways, the nature of our work defines us. So how do we prepare
for a future when the nature of work will change dramatically?
![Working on a team, busy worklife][1]
If we define "work" as any contribution that receives any kind of reward, then work is—and always has been—one of the major factors that define who we are. It is a major aspect of our lives. Throughout our work (whatever that may be for us), we meet friends, identify sources of intellectual stimulation and emotional fulfillment, grow, and feel at our most creative and innovative. To our families, friends, communities and societies, work is extremely important. We should not take work—or its role in our lives—lightly or for granted.
So if the [nature of work is going to change][2] in the future, it might mean that something key to our very sense of _self_ is going to change. And we should plan for those changes very seriously.
Consider the transformation of work throughout the Industrial Revolution (between the 1700s and 1800s). It drove many people from rural farm work into factories in the cities, fundamentally altering their lifestyles. It required new, more specialized skills (rather than the kind of artisanship common in rural economies). As we examine our own personal work environments in the decades to come, we'll see a potential reversal of the trends we saw during the Industrial era: from hierarchy and interchangeable general skills and activities to the reinstatement of horizontal collaboration and more specialized mastery (back to artisanship).
This time, though, these changes come on a global scale rather than a local one, and the speed of change is far more accelerated.
And in this new work environment, [open organization principles][3] will play a vital role.
In this series, I'll review [_The Shift_, a book by Professor Lynda Gratton][4]—a book that, while written in 2014 from data assembled in 2010, still rings true today (and will in the future, too). In this book, Gratton projects how work will change around 2025 and 2050. This is vital information, as it will help us make sound choices when preparing for and developing our careers moving forward.
Gratton explains predominant forces influencing the future of work in this timeframe. In this article series, I'll summarize them—and explain how open organization principles are involved in each.
### Five factors influencing the future of work
Driving the Industrial Revolution were inventions that used coal and steam power. Today, [Gratton][5] says, five subtle forces are causing a similar "shift":
1. increased global activities
2. rapid advances in technology
3. human longevity and demographics
4. societal and family structural changes
5. the need for a low-carbon economy
In short: Computers will become faster. Materials will become stronger. Medicines will cure more diseases allowing longer human life. To varying degrees, these will all impact on how we work in the future. Here are a few notes on each.
#### 1\. Globalization
In a previous article, "[Globalization: A history of openness][6]," I discussed multiple forces and factors related to globalization, one of them being trade. Between 1950 and 2010 the volume of global trade has increased by 60 times, while at the same time transportation costs have fallen. And at the same time, developing countries are seeing not only increased trade but new innovations. I also discussed globalization in early history as part of my article "[Open organizations through the ages][7]." And I explored the importance of global governance—both now and into the future—in my article ["What would a global open organization look like?"][8] According to Gratton, globalization will have an undeniable and unavoidable impact on the future work.
If the nature of work is going to change in the future, it might mean that something key to our very sense of self is going to change. And we should plan for those changes very seriously.
#### 2\. Technology
The cost of computing has been coming down at an alarming rate. And it will continue to decrease. This will help connect billions of people that have been mostly left out of the greater global economy until now. They will start to both enter the workforce and become more influential consumers. At the same time, computers and advanced automation [will replace jobs performed by humans][9] in the future. This all will influence work shifts in the future.
#### 3\. Demographics and longevity
Gratton also notes the impacts that various generations will have on the future of work, particularly in the United States. Younger generations will play a major role in the future, as their attitudes are different from earlier generations. Moreover, birth rates in various global regions will have an impact on prosperity. There will be more migration, as some regions' populations will decline while others increase. They will move to what Professor Gratton calls "creative clusters." And finally, Gratton argues, the life expectancy globally will change. By 2025, 10% of the world's population will be over the age of 65. These people will more than likely want to continue to work for sustained income, continued mental stimulation, physical activity, connection to others, and a source of meaning and purpose in their lives. Also, consider that many children today will more than likely live longer than 100 years. If they retired at 65 years old, they would have 35 years to do very little. With that thought in mind, having several career changes and being active in volunteer and community service programs in the future will expand greatly.
#### 4\. Society
In addition to the generational changes, Gratton notes several important social changes, too. There will be changing roles of women in the workplace, she says. People will have more choices to form the life they want than ever before. And with increased productivity per person, there will be more average free time available than ever before, she writes.
#### 5\. Energy resources
I've talked about the expansion of resource-saving industries in a presentation I've given on "[The Resource Industrial Revolution][10]." Gratton adds valuable points to this conversation. Climate change, she notes, will gradually become a major issue, which will reduce transportation and consumption. In particular, global water supply will not be able to keep pace with demand. Water desalination projects will expand greatly (possibly powered by [Generation IV][11] distributed small modular nuclear power plants (SMR's) now being developed). Environmental catastrophes will displace people and migration will create displaced communities throughout the globe. More energy-efficient ways of living will be discovered and introduced. This will influence future jobs.
### Preparing for the future
These five forces will prompt fundamental changes to the way we work in the future, Gratton argues. But we need to begin preparing for that future now. In the next article of this series, I'll explain Gratton's outlook and a few scenarios for grappling with a rapidly changing future. How could a person look at those changes as career opportunities? On the other hand, what would happen if a person simply _ignored_ those changes to come? I'll review Gratton's thoughts on those questions. Also, I'll also explain how open principles can form the heart of necessary changes.
--------------------------------------------------------------------------------
via: https://opensource.com/open-organization/21/1/open-is-future-of-work
作者:[Ron McFarland][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ron-mcfarland
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_dev_email_chat_video_work_wfm_desk_520.png?itok=6YtME4Hj (Working on a team, busy worklife)
[2]: https://opensource.com/open-organization/18/7/transformation-beyond-digital-2
[3]: https://theopenorganization.org/definition/
[4]: http://lyndagratton.com/books/the-shift/
[5]: https://en.wikipedia.org/wiki/Lynda_Gratton
[6]: https://opensource.com/open-organization/20/7/globalization-history-open
[7]: https://opensource.com/open-organization/20/8/global-history-collaboration
[8]: https://opensource.com/open-organization/20/9/global-open-organization
[9]: https://opensource.com/open-organization/19/9/claiming-human-age-of-AI
[10]: https://www.slideshare.net/RonMcFarland1/the-starting-of-the-third-industrial-revolution
[11]: https://en.wikipedia.org/wiki/Generation_IV_reactor

View File

@ -0,0 +1,189 @@
[#]: collector: (lujun9972)
[#]: translator: (FSSlc)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Check Dependencies of a Package in Ubuntu/Debian-based Linux Distributions)
[#]: via: (https://itsfoss.com/check-dependencies-package-ubuntu/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
如何在基于 Ubuntu 或 Debian 的 Linux 发行版中查看一个软件包的依赖
======
在 Ubuntu 或 Debian 中通过命令行来安装应用是一件很简单的事,你只需要执行 `apt install package_name` 就可以了。
但如果你想在安装一个软件包之前或之后知晓这个软件包的依赖,那该怎么办呢?
在本教程中,我将向你展示多种方法来在 Ubuntu 或其他使用 [APT 包管理器][1] 的 Debian 系 Linux 发行版中查看一个软件包的依赖。
### 在 Ubuntu 中什么是包依赖?
当你在 Linux 中安装一个软件包,有时这个软件包还需要其他的软件包来使它工作正常。这些额外的软件包就叫作这个包的依赖。假如这些软件包之前没有在系统中被安装,那么这些依赖在安装这个软件包的同时会被自动安装上。
举个例子,用来转换视频格式的 GUI 工具 [HandBrake][2] 需要 [FFmpeg][3]、[GStreamer][4] 软件包。所以对于 HandBrake 来说, FFmpeg 和 GStreamer 就是它的包依赖。
假如在你的系统上这些软件包没有被安装,则当你 [在 Ubuntu 上安装 HandBrake][5] 时,就会自动安装上它们。
### 在 Ubuntu 和基于 Debian 的发行版中查看一个软件包的依赖
正如在 Linux 上经常发生的那样,有多种方法来达到相同的目标。下面让我们一起瞧瞧查看一个软件包依赖的多种方法。
#### 使用 apt show 来查看依赖
你可以使用 [apt show 命令][6] 来展示一个包的详细信息。其中依赖信息就是其中一部分,你可以在以 Depends 打头的那些行中看到它们。
例如,下面展示的是使用 `apt show` 展示 [ubuntu-restricted-extras][7] 这个包的详细信息:
```
[email protected]:~$ apt show ubuntu-restricted-extras
Package: ubuntu-restricted-extras
Version: 67
Priority: optional
Section: multiverse/metapackages
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 14.3 kB
Depends: ubuntu-restricted-addons
Recommends: libavcodec-extra, ttf-mscorefonts-installer, unrar
Download-Size: 3,200 B
APT-Manual-Installed: yes
APT-Sources: http://us.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages
Description: Commonly used media codecs and fonts for Ubuntu
This collection of packages includes:
- MP3 and other audio codec software to play various audio formats
(GStreamer plugins)
- software to install the Microsoft Web fonts
- the Adobe Flash plugin
- LAME, software to create compressed audio files.
.
This software does not include libdvdcss2, and will not let you play
encrypted DVDs. For more information, see
https://help.ubuntu.com/community/RestrictedFormats/PlayingDVDs
.
These software packages are from the Multiverse channel, restricted by
copyright or legal issues in some countries. For more information, see
http://www.ubuntu.com/ubuntu/licensing
```
如你所见,`ubuntu-restricted-extras` 包依赖于 `ubuntu-restricted-addons` 这个软件包。
但你得小心的是依赖包还可能依赖于其他包,这样一直循环往复直到尽头。但幸好 APT 包管理器可以为你处理这些复杂的依赖关系,自动地安装所有的依赖(大多数情况下)。
> **什么是推荐包?**
>
> 你注意到了上面结果输出中以 Recommends 开头的那些行了吗?
>
> 推荐包不是软件包的直接依赖,但它们可以开启软件包的一些额外功能。
>
> 正如你上面看到的那样, `ubuntu-restricted-extras` 包有着 `ttf-mscorefonts-installer` 这个推荐包,用来在 Ubuntu 上安装 Microsoft 的字体。
>
> 这些推荐包也会默认被一同安装上,假如你想显式地禁止这些推荐包的安装,你可以像下面这样使用 `-no-install-recommends` 选项。
>
> `sudo apt install --no-install-recommends package_name`
#### 使用 apt-cache 来直接获取依赖信息
上面通过 `apt show` 的方式会获取到大量信息,假如你想在脚本中获取到依赖信息,那么 `apt-cache` 命令将会给你一个更好且更简洁的输出结果。
```
apt-cache depends package_name
```
下面的输出看起来更加干净,不是吗?
![][8]
#### 使用 dpkg 来查看一个 DEB 文件的依赖
`apt``apt-cache` 都作用于一个软件仓库中的软件包,但假如你下载了一个 DEB 文件,那么这两个命令就不起作用了。
在这种情形下,你可以使用 `dpkg` 命令的 `-I``--info` 选项。
```
dpkg -I path_to_deb_file
```
依赖信息就可以在以 Depends 开头的那些行中找到。
![][9]
#### 使用 apt-rdepends 来查看依赖及依赖的依赖
假如你想查看更多关于依赖的信息,那么你可以使用 `apt-rdepends` 工具。这个工具可以创建完整的依赖树。这样你就可以得到一个软件包的依赖以及这些依赖的依赖。
它不是一个常规的 apt 命令,所以你需要从 universe 软件仓库中安装上它:
```
sudo apt install apt-rdepends
```
这个命令的输出通常很多,取决于依赖树的大小。
```
Reading package lists... Done
Building dependency tree
Reading state information... Done
shutter
Depends: procps
Depends: xdg-utils
imagemagick
Depends: imagemagick-6.q16 (>= 8:6.9.2.10+dfsg-2~)
imagemagick-6.q16
Depends: hicolor-icon-theme
Depends: libc6 (>= 2.4)
Depends: libmagickcore-6.q16-6 (>= 8:6.9.10.2)
Depends: libmagickwand-6.q16-6 (>= 8:6.9.10.2)
hicolor-icon-theme
libc6
Depends: libcrypt1 (>= 1:4.4.10-10ubuntu4)
Depends: libgcc-s1
libcrypt1
Depends: libc6 (>= 2.25)
```
`apt-rdepends` 工具的功能非常多样,它还可以用来计算反向依赖。这意味着你可以查看某个特定的包被哪些软件包依赖。
```
apt-rdepends -r package_name
```
输出可能会非常多,因为它将打印出反向依赖树。
```
[email protected]:~$ apt-rdepends -r ffmpeg
Reading package lists... Done
Building dependency tree
Reading state information... Done
ffmpeg
Reverse Depends: ardour-video-timeline (>= 1:5.12.0-3ubuntu4)
Reverse Depends: deepin-screen-recorder (5.0.0-1build2)
Reverse Depends: devede (4.15.0-2)
Reverse Depends: dvd-slideshow (0.8.6.1-1)
Reverse Depends: green-recorder (>= 3.2.3)
```
我希望这个快速的教程可以帮助你提高一点儿你的命令行知识。为了知晓更多类似小知识点,请保持关注。
--------------------------------------------------------------------------------
via: https://itsfoss.com/check-dependencies-package-ubuntu/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[FSSlc](https://github.com/FSSlc)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://wiki.debian.org/Apt
[2]: https://itsfoss.com/handbrake/
[3]: https://ffmpeg.org/
[4]: https://gstreamer.freedesktop.org/
[5]: https://itsfoss.com/install-handbrake-ubuntu/
[6]: https://itsfoss.com/apt-search-command/
[7]: https://itsfoss.com/install-media-codecs-ubuntu/
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/apt-check-dependencies-ubuntu.png?resize=800%2C297&ssl=1
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/check-dpendencies-of-deb-package.png?resize=800%2C432&ssl=1

View File

@ -7,21 +7,20 @@
[#]: via: (https://opensource.com/article/20/12/tqdm-python)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
Show progress in your Python apps with tqdm
使用 tqdm 在 Python 应用中显示进度
======
If your program takes a while to show results, avoid frustrating users
by showing the progress it's making.
如果你的程序需要一段时间才能显示结果,可通过显示它的进度来避免让用户感到沮丧。
![arrows cycle symbol for failing faster][1]
The Semitic root _q-d-m_ in Aramaic, Hebrew, and Arabic is usually associated with moving forward or making progress. The Arabic word _taqaddum_ (تقدّم) means "progress." Progress is important. As every feel-good movie will tell you, the journey is as important as the destination.
阿拉米语,希伯来语和阿拉伯语中的闪米特语根 _q-d-m_ 通常与前进或进度有关。阿拉伯语 _taqaddum_ (تقدّم)的意思是“进度”。进度是很重要的。正如每部感觉良好的电影都会告诉你,旅程和目的地同样重要。
Most programs have a clear goal, a desired end state. Sometimes, calculating that end state can take a long time. While computers don't care, not having feelings, people do. Humans are not happy sitting around waiting without any visible sign of progress. Doubt creeps in. Has the program crashed? Is the disk thrashing? Did the operating system allocate all its computing resources to other tasks?
大多数程序都有一个明确的目标,一个期望的最终状态。有时,计算这个最终状态可能需要很长的时间。虽然计算机没有感情不在乎,但人却在乎。人类并不乐意坐在原地等待,而看不到任何明显的进展迹象。疑问不断蔓延。程序崩溃了吗?磁盘是否抖动?操作系统是否把所有的计算资源都分配给了其他任务?
Like justice, progress must be seen, not merely done. The [tqdm][2] Python library helps make progress explicit.
就像正义一样,进度必须被看到,而不仅仅是完成。[tqdm][2] Python 库有助于使进度变得明确。
The tqdm module works with the console, but it also has special support for one of my favorite environments: Jupyter. To use tqdm in Jupyter, you need to import the `notebook` submodule and have [ipywidgets][3] installed. The `notebook` submodule is interface-compatible with tqdm.
tqdm 模块与控制台一起工作,但它也对我最喜欢的环境之一 Jupyter 有特殊支持。要在 Jupyter 中使用 tqdm你需要导入 `notebook` 子模块并安装 [ipywidgets][3]。`notebook` 子模块与 tqdm 接口兼容。
This means you can do some import-time shenanigans to import the correct module while keeping tqdm usage the same. The trick is to check if the `__main__` module has the global variable `get_ipython`. While this is a heuristic, it is a reasonably accurate one:
这意味着你可以做一些导入时操作来导入正确的模块,同时保持 tqdm 的用法不变。诀窍是检查 `__main__` 模块是否有全局变量 `get_ipython`。虽然这只是一个启发式的方法,但却是一个相当准确的方法。
```
@ -32,7 +31,7 @@ else:
    import tqdm
```
The simplest case is when something needs to run for a certain number of iterations (known in advance), and each of those iterations takes about the same amount of time. For example, there is an algorithm to calculate the square root of any number by starting with 1 as a guess and then calculating an improved guess:
最简单的情况是,某件事情需要运行一定的迭代次数(事先已知),而每一次迭代的时间都差不多。例如,有一种算法,通过从 1 开始猜测,然后计算一个改进的猜测,来计算任何数字的平方根:
```
@ -40,7 +39,7 @@ def improve_guess(rt, n):
    return (rt + n/rt) / 2
```
A small number of improvements gets you pretty close. For example, you can calculate the square root of two:
少量改进就能让你很接近。例如,你可以计算 2 的平方根:
```
@ -54,14 +53,14 @@ for i in tqdm.trange(10):
(Moshe Zadke, [CC BY-SA 4.0][5])
It's correct to 10 decimal places!
精确到小数点后 10 位!
```
`round(2 - guess*guess, 10)`[/code] [code]`0.0`
```
A slightly more complicated example is when the number of elements is known, and processing each element takes a similar amount of time. As an example, you can calculate the product of some numbers. For that, you'll want some random numbers:
一个稍微复杂一点的例子是,当元素的数量是已知的,而处理每个元素需要类似的时间。例子是,你可以计算一些数字的乘积。为此,你需要一些随机数:
```
@ -78,7 +77,7 @@ numbers[:5]
0.45192978568125486]
```
Now that the numbers are in, it's time to multiply them. The easiest way to use tqdm is by wrapping a Python iterable. The values will be the same, but tqdm will also display a progress bar:
现在有了数字,可以将它们相乘了。使用 tqdm 最简单的方法是包装一个 Python 迭代函数。数值是一样的,但是 tqdm 会显示一个进度条:
```
@ -94,7 +93,7 @@ result
(Moshe Zadke, [CC BY-SA 4.0][5])
However, not all things are predictable. One of the least predictable things is network speed. When you download a big file, the only way to measure progress is to explicitly check how much has been downloaded:
然而,并不是所有的事情都可以预测。最不容易预测的事情之一就是网络速度。当你下载一个大文件时,衡量进度的唯一方法就是检查已经下载了多少:
```
@ -111,9 +110,9 @@ with httpx.stream("GET", url) as response:
(Moshe Zadke, [CC BY-SA 4.0][5])
Sometimes, it makes sense to "nest" progress bars. For example, if you are downloading a directory, you'll want a progress bar tracking the files and a progress bar per file.
有时,“嵌套”进度条是有意义的。例如,如果你要下载一个目录,你就需要一个进度条来跟踪文件,并为每个文件设置一个进度条。
Here is an example (but without actually downloading a directory):
下面是一个例子(但没有实际下载一个目录):
```
@ -134,7 +133,7 @@ for fname in tqdm.tqdm(files, desc="files"):
(Moshe Zadke, [CC BY-SA 4.0][5])
So, if your program takes a while to show final results, avoid frustrating your users: Show the progress it's making!
所以,如果你的程序需要一段时间才能显示最终结果,为避免让你的用户感到沮丧。请显示它的进度!
--------------------------------------------------------------------------------
@ -142,7 +141,7 @@ via: https://opensource.com/article/20/12/tqdm-python
作者:[Moshe Zadka][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出