How does one reinstall an opam package/proj using the absolute path to the project without relying on opam pin? - opam

In the past I've used this command:
opam reinstall --yes --switch ocaml-variants.4.07.1+flambda_coq-serapi.8.11.0+0.11.1 --keep-build-dir lf
I think this command only worked because I also pinned the pkg e.g. (ran it from within python from unimportant reasons):
command = (['opam', 'pin', '-y']
+ root_option()
+ ['--switch', switch]
+ [coq_package, coq_package_pin])
How do I reinstall it using the path to the proj instead i.e. using coq_package_pin?
I think something like this should work:
command: list = ['opam'] + ['reinstall'] + root_option() + ['--yes'] + ['--switch', switch] + \
['--keep-build-dir', coq_project_path] + \
[coq_project_path]
Note pining the package is giving me issues so I'd like to avoid it if possible.
related:
Is an opam pin project needed when one wants to install an opam project with opam reinstall or 'make'?
https://discuss.ocaml.org/t/how-does-one-reinstall-an-opam-package-proj-using-the-absolute-path-to-the-project-without-relying-on-opam-pin/10944
https://discuss.ocaml.org/t/what-is-the-difference-between-opam-pin-and-opam-install-when-to-use-one-vs-the-other/10942/5

Related

libuuid not linking in ubuntu 16.04

The above problem is not resolved in ubuntu 16.04 .
I tried it but still not working . here are the results of steps I followed :
~$ apt-cache search libuuid
libuuid-perl - Perl extension for using UUID interfaces as defined in e2fsprogs libuuid1 - Universally Unique ID library uuid-dev - Universally Unique ID library - headers and static libraries uuid-runtime - runtime components for the Universally Unique ID library libdata-uuid-libuuid-perl - uuid.h based UUID generation module libuuid-tiny-perl - pure Perl module to generate v1, v3, v4, and v5 UUIDs libuuidm-ocaml-dev - Universally unique identifiers for OCaml php-uuid - PHP UUID extension
~$ sudo apt-get install uuid-runtime
Reading package lists... Done Building dependency tree
Reading state information... Done uuid-runtime is already the newest version (2.27.1-6ubuntu3.6). The following packages were automatically installed and are no longer required: linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic linux-headers-4.15.0-43 linux-headers-4.15.0-43-generic linux-image-4.15.0-29-generic linux-image-4.15.0-43-generic linux-modules-4.15.0-29-generic linux-modules-4.15.0-43-generic linux-modules-extra-4.15.0-29-generic linux-modules-extra-4.15.0-43-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 77 not upgraded.
~$ sudo apt-get install libuuid1
Reading package lists... Done Building dependency tree
Reading state information... Done libuuid1 is already the newest version (2.27.1-6ubuntu3.6). The following packages were automatically installed and are no longer required: linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic linux-headers-4.15.0-43 linux-headers-4.15.0-43-generic linux-image-4.15.0-29-generic linux-image-4.15.0-43-generic linux-modules-4.15.0-29-generic linux-modules-4.15.0-43-generic linux-modules-extra-4.15.0-29-generic linux-modules-extra-4.15.0-43-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 77 not upgraded.
~$ sudo apt-get install uuid-dev
Reading package lists... Done Building dependency tree
Reading state information... Done uuid-dev is already the newest version (2.27.1-6ubuntu3.6). The following packages were automatically installed and are no longer required: linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic linux-headers-4.15.0-43 linux-headers-4.15.0-43-generic linux-image-4.15.0-29-generic linux-image-4.15.0-43-generic linux-modules-4.15.0-29-generic linux-modules-4.15.0-43-generic linux-modules-extra-4.15.0-29-generic linux-modules-extra-4.15.0-43-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 77 not upgraded.
Following is the code in my test.c file
#include <stdio.h>
#include <uuid/uuid.h>
int get_uuid();
int main()
{
get_uuid();
return 1;
}
int get_uuid()
{
uuid_t uuid;
uuid_generate(uuid);
return 1;
}
Error: /tmp/cchyLkZt.o: In function get_uuid':
test5.c:(.text+0x34): undefined reference touuid_generate' collect2: error: ld returned 1 exit status
Compilation Command -
cc -luuid test.c

Custom u-boot environment variables using buildroot

How do you add a new set of custom environment variables to u-boot using buildroot as the os build system?
I attempted to patch the include/configs/rpi.h using an external tree patch to add a new variable but kconfig got grumpy (patch shown after complaining):
The following new ad-hoc CONFIG options were detected:
CONFIG_XXXXXX_ENV_SETTINGS
Please add these via Kconfig instead. Find a suitable Kconfig
file and add a 'config' or 'menuconfig' option.
Makefile:871: recipe for target 'all' failed
--- a/include/configs/rpi.h 2018-03-13 12:02:19.000000000 +0000
+++ b/include/configs/rpi.h 2018-11-19 12:32:15.728000000 +0000
## -140,0 +141,7 ##
+#define CONFIG_XXXXXX_ENV_SETTINGS \
+ "newboard=true" \
+ "hasFailedBoot=false" \
+ "hasFailedBootCount=0" \
+ "maximumFailedBootCount=3"
+
+
## -145 +152,2 ##
- BOOTENV
+ BOOTENV \
+ CONFIG_XXXXXX_ENV_SETTINGS
I can use uboot-menuconfig to set up u-boot specific stuff but am not sure how to create environment variables
You can set CONFIG_USE_DEFAULT_ENV_FILE in uboot-menuconfig and point that to a file that contains the complete default environment.
Since you use Buildroot, don't forget to save the modified U-Boot configuration by changing its location (Buildroot option BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE) and running make uboot-update-defconfig.

Installing multiples packages with chef

When I try to install multiples packages with a wildcard naming I got the following error:
* yum_package[mysql-server] action install (up to date)
* yum_package[mysql*] action install
* No candidate version available for mysql*
============================================================================ ====
Error executing action `install` on resource 'yum_package[mysql*]'
============================================================================ ====
Recipe code is:
package 'mysql-server' do
action :install
end
package 'mysql*' do
action :install
end
You have to use the exact package name. The chef package resource does no magic to find matching packages.
The name of the resource (the part just after package) is used as the package name and given to the underlying system (yum on RH like systems, apt on debian like systems)
If you have multiples packages to install and a common configuration you can loop over them in your recipe instead:
['mysql-server','mysql-common','mysql-client'].each do |p|
package p do
action :install
end
end
The array creation could be simplified with some ruby syntax as the words builder %w:
%w(mysql-server mysql-common mysql-client).each [...]
Since chef 12.1 the package resource accept an array of packages directly like this:
package %w(mysql-server mysql-common mysql-client)
This can be resolved using chef cases. Please see below
add the following to your attributes file:
packages = []
case node[:platform_family]
when 'rhel' #based on your OS
packages = [
"package1",
"package2",
"package3",
"package4",
"package5",
"package6",
"package7" ## Last line without comma
]
end
default[:cookbookname][:packages] = packages
Then, add the following to your recipe file (recipes/default.rb):
node[:cookbookname][:packages].each do |pkg|
package pkg do
action :install
retries 3
retry_delay 5
end
end

rpm and Yum don't believe a package is installed after Chef installs

Running chef-solo (Installing Chef Omnibus (12.3)) on centos6.6
My recipe has the following simple code:
package 'cloud-init' do
action :install
end
log 'rpm-qi' do
message `rpm -qi cloud-init`
level :warn
end
log 'yum list' do
message `yum list cloud-init`
level :warn
end
But it outputs the following:
- install version 0.7.5-10.el6.centos.2 of package cloud-init
* log[rpm-qi] action write[2015-07-16T16:46:35+00:00] WARN: package cloud-init is not installed
[2015-07-16T16:46:35+00:00] WARN: Loaded plugins: fastestmirror, presto
Available Packages
cloud-init.x86_64 0.7.5-10.el6.centos.2 extras
I am at a loss as to why rpm/yum and actually rpmquery don't see the package as installed.
EDIT: To clarify I am specifically looking for the following string post package install to then apply a change to the file (I understand this is not a very chef way to do something I am happy to accept suggestions):
rpmquery -l cloud-init | grep 'distros/__init__.py$'
I have found that by using the following:
install_report = shell_out('yum install -y cloud-init').stdout
cloudinit_source = shell_out("rpmquery -l cloud-init | grep 'distros/__init__.py$'").stdout
I can then get the file I am looking for and perform
Chef::Util::FileEdit.new(cloudinit_source.chomp(''))
The file moves based on the distribution but I need to edit that file specifically with in place changes.
Untested code, just to give the idea:
package 'cloud-init' do
action :install
notifies :run,"ruby_block[update_cloud_init]"
end
ruby_block 'update_cloud_init' do
block do
cloudinit_source = shell_out("rpmquery -l cloud-init | grep 'distros/__init__.py$'").stdout
rc = Chef::Util::FileEdit.new(cloudinit_source.chomp(''))
rc.search_file_replace_line(/^what to find$/,
"replacement datas for the line")
rc.write_file
end
end
ruby_block example taken and adapted from here
I would better go using a template to manage the whole file, what I don't understand is why you don't know where it will be at first...
Previous answer
I assume it's a compile vs converge problem. at the time the message is stored (and so your command is executed) the package is not already installed.
Chef run in two phase, compile then converge.
At compile time it build a collection of resources and at converge time it execute code for the resource to get them in the described state.
When your log resource is compiled, the ugly back-ticks are evaluated, at this time there's a package resource in the collection but the resource has not been executed, so the output is correct.
I don't understand what you want to achieve with those log resources at all.
If you want to test your node state after chef-run use a handler maybe calling ServerSpec as in Test-Kitchen.

How to list packages and dependencies that will be installed in Macports?

Is there a way to just list all new packages and their dependencies that port will install for a given command?
For instance, consider installing the SciPy stack with the suggested:
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose
That installs a ton of packages and dependencies not listed in the above command.
Also, some of them I already have.
I'm already aware of the -y switch but that gives a verbose output of everything, including packages I had already installed.
I'm interested to have port tell me which new packages (be it dependencies or not) will be installed.
Is there a known way or do people just parse the -y output of the command, comparing each reported package against the existing installed packages?
Cheers
p.s. I'm fairly new to Macports and MacOSX (in Linux, apt-get always tells you which new packages will be installed)
You can use a port expression to print what will be installed:
port echo rdepof:$yourport and not installed
or for multiple ports
port echo \( rdepof:$yourport rdepof:$yourport2 ... \) and not installed
Due to the number of Portfiles involved in this and how the set operations are implemented, this will be rather slow. That being said, we're also working on improving this and providing feedback prior to installation like apt-get in a future MacPorts version.
neverpanic already gave a answer, but it seems unable to handle variants (like +notebook) and command-line options (like configure.compiler=macports-clang-3.7). I had a separate solution. The following Python script can display the new dependencies recursively:
#!/usr/bin/env python
#coding: utf-8
import re
import sys
import subprocess
# Gets command output as a list of lines
def popen_readlines(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p.wait()
if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode, cmd)
else:
return map(lambda line: line.rstrip('\n'), p.stdout.readlines())
# Gets the port name from a line like " gcc6 #6.1.0_0 (active)"
def get_port_name(port_line):
return re.sub(r'^ (\S+).*', r'\1', port_line)
# Gets installed ports as a set
def get_installed():
installed_ports_lines = popen_readlines(['port', 'installed'])[1:]
installed_ports = set(map(get_port_name, installed_ports_lines))
return installed_ports
# Gets port names from items that may contain version specifications,
# variants, or options
def get_ports(ports_and_specs):
requested_ports = set()
for item in ports_and_specs:
if not (re.search(r'^[-+#]', item) or re.search(r'=', item)):
requested_ports.add(item)
return requested_ports
# Gets dependencies for the given port list (which may contain options
# etc.), as a list of tuples (combining with level), excluding items in
# ignored_ports
def get_deps(ports, ignored_ports, level):
if ports == []:
return []
deps_raw = popen_readlines(['port', 'deps'] + ports)
uninstalled_ports = []
for line in deps_raw:
if re.search(r'Dependencies:', line):
deps = re.sub(r'.*Dependencies:\s*', '', line).split(', ')
uninstalled_ports += [x for x in deps if x not in ignored_ports]
ignored_ports |= set(deps)
port_level_pairs = []
for port in uninstalled_ports:
port_level_pairs += [(port, level)]
port_level_pairs += get_deps([port], ignored_ports, level + 1)
return port_level_pairs
def main():
if sys.argv[1:]:
ports_and_specs = sys.argv[1:]
ignored_ports = get_installed() | get_ports(ports_and_specs)
uninstalled_ports = get_deps(ports_and_specs, ignored_ports, 0)
for (port, level) in uninstalled_ports:
print ' ' * (level * 2) + port
if __name__ == '__main__':
main()
It can be invoked like port_rdeps.py libomp configure.compiler=macports-clang-3.7. As a bonus, it can show the uninstalled dependencies as a tree.

Resources