Answers:
编辑:我没有看到您先前关于知道可以使用wget的声明,所以这有点尴尬...我会将其留给任何想知道如何执行此操作的人。另外,我的答案的先前版本不起作用,但是此版本(以更长一些为代价)可以:
TEMP_DEB="$(mktemp)" &&
wget -O "$TEMP_DEB" 'http://path.to/my.deb' &&
sudo dpkg -i "$TEMP_DEB"
rm -f "$TEMP_DEB"
您只需要在开始时更改URL。这可以作为别名或写为bash函数。
我意识到与此相关的技术和安全性问题(您无法获得自动更新,可以信任源等),但是在完全可以做的基础上,这可能会起作用。
不创建临时文件是不可能的。通常您会这样做
### Does not work
wget --quiet --output-document=- http://example.com/path/to/package.deb | dpkg --install -
或者可能
### Does not work
dpkg --install <(wget --quiet --output-document=- http://example.com/path/to/package.deb)
但是dpkg使用mmap来访问文件,因此两者都不起作用。有关于此的错误报告:#367297
最快的方法就是这样。单击以开始安装百叶窗 。
用于单击名称的URL:
http://packages.ubuntu.com/shutter
...,然后单击图标:
http://apt.ubuntu.com/p/shutter
是的,您需要Ubuntu软件中心来完成.DEB的安装。否则,您将必须从Nautilus或命令行执行安装。
完整的文本仅用于Ask Ubuntu,因此您需要将其重新格式化为锚点:
[shutter](http://packages.ubuntu.com/shutter) [![Install shutter]
(https://i.stack.imgur.com/HjNGK.png)](http://apt.ubuntu.com/p/shutter)
可以在apturl Wiki页面上找到更多信息:
1个包装:
a href="apt:package"
捆绑几个软件包:
a href="apt:package1,package2,package3"
启用存储库:
apturl apt:freevial?section=universe
因此,如果该软件不在默认启用的存储库中,则应在其中添加“ section =”。否则,您将无法使用此方法,而需要用户下载并自行安装。
您可以尝试使用curl
。
要将文件下载到当前文件夹并从本地文件安装:
curl -sLO https://apt.puppetlabs.com/puppetlabs-release-precise.deb && sudo dpkg -i puppetlabs-release-precise.deb
或/var/cache/apt/archives/
从此处下载并安装:
curl -sL -o/var/cache/apt/archives/puppetlabs-release-precise.deb https://apt.puppetlabs.com/puppetlabs-release-precise.deb && sudo dpkg -i /var/cache/apt/archives/puppetlabs-release-precise.deb
--install needs at least one package archive file argument
dpkg-deb: error:
的/ dev / FD / 63'不是一个Debian格式archive`
dpkg: error processing archive puppetlabs-release-precise.deb (--install):
我实际上有一个执行类似操作的脚本:
只需将以下脚本复制并粘贴到~/bin
(如果不存在,请创建此文件夹):
#!/bin/bash
# ~/bin/dpkg
COUNT=0
for i in $@; do
echo $i | grep http 2>&1 > /dev/null
if [ $? == 0 ]; then
URL="$URL $i"
continue
fi
PASSTODPKG="$PASSTODPKG $i"
done
#Remove beginning and trailing space
URL=$(echo $URL | sed -e 's/^ //g' -e 's/ $//g')
if [ ! -z $URL ]; then
mkdir /tmp/debs
cd /tmp/debs
for i in $URL; do
wget "$i"
done
dpkg $PASSTODPKG /tmp/debs/*.deb
else
dpkg $PASSTODPKG
fi
然后将其添加到中的最后一行 ~/.bashrc
PATH="~/bin:$PATH"
该脚本只是的包装dpkg
。~/.bashrc
文件中的这一行告诉bash
您,只要您键入dpkg
,它就会~/bin/dpkg
(而不是)运行(脚本)/usr/bin/dpkg
。
dpkg
如果没有提供URL ,脚本将仅将参数传递给。该脚本还支持多个URL。以下是一些有效的示例:
sudo dpkg -i http://www.example.com/file1.deb
sudo dpkg -i http://www.example.com/file1.deb http://www.example.com/file2.deb
sudo dpkg -i http://www.example.com/file1.deb existing.deb http://www.example.com/file2.deb
sudo dpkg -i existing.deb
lynx
可以致电dpkg
(或在软件中心,如果有显示的话),并愿意为您安装下载的软件包。例如,使用:
lynx http://archive.ubuntu.com/ubuntu/pool/main/z/zsh/
然后下载其中一个.deb
文件,将显示以下提示:
Info for debian package '/tmp/user/1000/L11127-6774TMP.udeb':
new debian package, version 2.0.
size 2545218 bytes: control archive=5830 bytes.
857 bytes, 21 lines control
14682 bytes, 169 lines md5sums
225 bytes, 20 lines * postinst #!/bin/sh
Package: zsh-doc
Source: zsh
Version: 5.1.1-1ubuntu1
Architecture: all
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Installed-Size: 5291
Depends: zsh-common (= 5.1.1-1ubuntu1)
Section: doc
Priority: optional
Homepage: http://www.zsh.org/
Description: zsh documentation - info/HTML format
Zsh is a UNIX command interpreter (shell) usable as an
interactive login shell and as a shell script command
processor. Of the standard shells, zsh most closely resembles
ksh but includes many enhancements. Zsh has command-line editing,
built-in spelling correction, programmable command completion,
shell functions (with autoloading), a history mechanism, and a
host of other features.
.
This contains the documentation in GNU info and HTML formats.
Original-Maintainer: Debian Zsh Maintainers <pkg-zsh-devel@lists.alioth.debian.org>
Do you wish to:
- I)nstall the package now,
- S)ave it to a file, or
- Q)uit now
Your choice (I/S/Q)? I
Installation of Debian packages needs to be done as root.
Enter command used to become root (default=sudo):
Installing package...
[sudo] password for bro3886:
(Reading database ... 756955 files and directories currently installed.)
Preparing to unpack .../user/1000/L11127-6774TMP.udeb ...
Unpacking zsh-doc (5.1.1-1ubuntu1) over (5.0.5-4ubuntu1~ubuntu14.04.1) ...
dpkg: dependency problems prevent configuration of zsh-doc:
zsh-doc depends on zsh-common (= 5.1.1-1ubuntu1); however:
Version of zsh-common on system is 5.0.5-4ubuntu1~ubuntu14.04.1.
dpkg: error processing package zsh-doc (--install):
dependency problems - leaving unconfigured
Processing triggers for doc-base (0.10.5) ...
Processing 1 changed doc-base file...
Processing triggers for install-info (5.2.0.dfsg.1-2) ...
Errors were encountered while processing:
zsh-doc
Done. Press <return> to continue:
(也许我不应该尝试从互联网上随机安装软件包。)
我知道距回答/发布问题已有一段时间了,但这是我的不起眼的贡献:
#!/bin/bash
dir="/tmp/dpkg-get"
url="$1"
file="${url##*/}"
if [ "$EUID" -ne 0 ]
then
echo "Please run as root"
exit
fi
[ -d $dir ] || mkdir $dir
wget -q --show-progress -O "$dir/$file" $url && \
dpkg -i "$dir/$file"
如何dpkg-get
使用单个命令从Pastebin 安装:
sudo bash -c "wget http://pastebin.com/raw/GWu7qLwK -O- | tr -d '\r' > /usr/local/bin/dpkg-get && \
chmod a+x /usr/local/bin/dpkg-get"
如何使用它(例如安装PowerShell 6 alpha):
sudo dpkg-get https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.10/powershell_6.0.0-alpha.10-1ubuntu1.16.04.1_amd64.deb
就这样。
我知道这并不完美,但它很简单并且可以正常工作。
请记住要小心安装和从哪里下载。
这个基于SO答案的单行代码在Ubuntu 15.04上为我工作,可以为我的环境(64位Ubuntu)确定github上的最新原子发行版,然后安装它:
sudo dpkg -i $(curl -w "%{filename_effective}" -LO $(curl -s https://api.github.com/repos/atom/atom/releases | grep browser_download_url | grep '64[.]deb' | head -n 1 | cut -d '"' -f 4))
如果您在tmp目录中执行此操作,则每次清空tmp文件夹时都会清理deb文件。否则,如果需要磁盘空间,则可以手动删除deb软件包。
您可以将其追加到/etc/bash.bashrc
以下内容(这是Chen脚本的升级):
'dpkg-url'() {
COUNT=0
for package in "${urls[@]}"; do
if [[ $package = *http* ]]; then
urls+=("$package")
fi
dpkg_url="$dpkg_url "$package""
done
# Remove beginning and trailing spaces #
url=$(echo "$url" | sed -e 's/^ //g' -e 's/ $//g')
if [[ ! -z "$url" ]]; then
directory=$(mktemp -d);
trap 'rm -rf "$directory"' EXIT
cd "$directory" || exit
for package in "$url"; do
wget ""$package""
done
dpkg $dpkg_url "$directory"/*.deb
else
dpkg $dpkg_url
fi
}
虽然我不明白为什么在调用它时会出现以下错误:
dpkg-url -i http://downloads.sourceforge.net/ldview/ldview-4.2-beta1.x64.deb
dpkg: error: need an action option
Type dpkg --help for help about installing and deinstalling packages [*];
Use `dselect' or `aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Options marked [*] produce a lot of output - pipe it through `less' or `more' !
dpkg --skip-same-version -i $FILE
如果要从脚本运行它,我也建议使用。此处的更多信息-manpages.debian.org/unstable/dpkg/dpkg.1.en.html