Undo a `raco pkg update --clone` or `raco pkg install --clone` - racket

I frequently like to use raco pkg install --clone (or raco pkg --update clone if the library is already installed), when I want to work on a library and submit patches.
However, I accidentally ran raco pkg update --clone in the wrong folder, and now I can't seem to get it to move to the correct directory.
I tried simply moving the directory, but racket (understandably) didn't know how to handle that, and I tried just deleting the directory, but that didn't work either.
I could theoretically uninstall the package and reinstall it. But I have a lot of packages that already depend on it installed, and it would be very annoying to have to uninstall all of them, and reinstall them all again.
Do I have any other options, or am I just doomed to manually uninstalling and reinstalling a lot of packages (or just reinstalling the whole Racket distribution)?

Yes, you can convert a --cloneed package back into a regular package. The flag you are looking for is --lookup. What you should do is:
raco pkg update --lookup <my-package>
cd to/the/desired/dir
raco pkg update --clone <my-package>
Note that all --lookup does is tell Racket to use the downloaded copy it has, rather than the cloned repo you had it point to. It does NOT delete the old cloned repo. So if you no longer want it on your system, you have to remove it yourself.
Additionally, note the use of raco pkg update here. Even if you got into the problem by running raco pkg install --clone ... in the wrong directory, you still should run raco pkg update ... here, because you are only moving where Racket looks to find the package
Finally, you can use --lookup and --clone at the same time:
cd to/the/desired/dir
raco pkg update --lookup --clone <my-package>
I should also note that this answer is based on a similar question from the Racket mailing list

Related

How to update a racket package installation and restore raco pkg subcommand?

I am trying to update an old racket package I had written ages ago to run on the new racket. I found the documentation extremely confusing and seemingly broke everything. Can you please suggest how things can be resolved?
While trying to run raco pkg install {path/to/package} I got an error saying my package was trying to find the old Racket 6.4 installation and since I have updated my operating system since then it didn't find it. I searched in that directory and could only find such references in the compiled/ folder. I skimmed the raco documentation and saw that raco setup --clean would remove that compiled folder. However, I thought it would be context specific: working on just the package who's directory I was in. That appears to not be the case. Now raco pkg doesn't even exist as a sub-command of raco!
How can I restore it and get back to trying to update my package so that it can be installed on the latest racket?
When you run raco, it works on the installation that it's a part of. So, for instance, if you have two copies of racket installed at /Users/clements/racket1/racket and /Users/clements/racket2/racket, then if I run the raco that's a part of the racket1 installation, I'll be updating the packages that are associated with the racket1 installation.
Sounds sensible, but I've messed this up myself, many times: depending on how your path is set up, the command raco may refer to either the racket1 or the racket2 installation. The problem here isn't really with racket, it's with the idea of paths, and how easy it is to mess things up when you have two installations containing the same binaries.
(And, of course, apologies if I'm misunderstanding your problem!)

How to manually install a package in racket?

How can I manually install a package in racket (that is without relying on raco)? Is that possible?
I installed the minimal racket distribution and want to manually add the packages in question (such as xrepl which doesn't seem to come by default).
I'm on CentOS and I have no root privileges (the installation is in a private directory).
Although I'm not sure I understand the permissions issue you're having, you could try raco pkg install --scope user.
Anyway, you can use raco pkg install --link <dir> to install locally. (Just like what people do when they're developing a package locally.)
So for example:
cd ~/src
git clone path/to/foo
(Or get the package source into ~/src/foo some other way. By "package source" I mean there should be an info.rkt in ~/src/foo.)
raco pkg install --link foo
If the foo package has any dependencies, than raco pkg install will offer to get and install them, too. Normally this would be handy. But since you're having connection or permission problems, I imagine you'll want to answer No. Instead, do this manual install for each of the deps, then retry this one. (Obviously if there are many deps, this is inconvenient, which is one of the benefits of using a package manager when you are able to.)

Download RPMs for all dependencies for package using yum

I'm attempting to create a local yum repo on my system containing various packages from, chiefly, the CentOS base repos. The server which is hosting the yum repo will not necessarily have the same base packages installed by default as the servers which will be using the yum repo. For this reason, I need to ensure that my repos contain the packages that I want and every single one of their dependencies.
I'm creating my repos using the yumdownloader tool provided in the yum-utils package to try to download an RPM file for a package using yum from the standard CentOS mirrors. Helpfully it provides a command line option, --resolve, which also downloads dependencies. However, because it's built on yum itself, yumdownloader will only download dependencies for the package that are not already present on the system.
For example, I wish to download package A, which depends on Packages B, C and D. If package D is already installed on the system, yumdownloader --resolve A will only download A, B and C, but not D.
Is there a way to download the RPMs for all dependencies on a package from a yum repo?
There's this bash script, which the maintainer of rpm has kindly shared with me, and I put on github. Hope you find it useful!
You can also read the original SO question, where the issue was discussed.
The script works on Fedora 23+ as it uses dnf's download plugin. It's probably very easy to make it work on Fedora 22-, as yum surely has got a similar plugin.
Additionaly, it's valuable since repotrack does not work on fedora 23 (at least it doesn't work for me).
After a lot of frustration looking around for a solution I have written a simple script that uses repotrace and wget. I've found that yumdownloader (even with the resolve flag) does not resolve all dependencies.
if you have a long list of packages you are bound to run into duplicates, downloading just the urls first with the "repotrack -u flag" and then getting unique records resolves having to download the same rpm multiple times.
#!/bin/bash
while read i; do
repotrack -u $i >> dep_rpm_urls_02.txt
done < list_of_packages_01.txt
awk '!seen[$0]++' dep_rpm_urls_02.txt > dep_rpm_urls_clean_03.txt
while read j; do
wget $j
echo dowloaded $j
done < dep_rpm_urls_clean_03.txt
happy rpming

How to build gstreamer ugly plugins from source

I would like to change some code in one element X in gstreamer ugly plugin and rebuild and use it.
How I can do it?
I have gstreamer-0.10 and installed gstreamer-ugly plugin.
I would like to download only gstreamer0-10 ugly plugin code and change it and would like to use the new lib file. How I can do it?
unfortunately gstreamer-ugly depends on a lot of stuff in at least libgstreamer and plugins-base (if you're using linux and your distro provides *-dev packages as debian/ubuntu does).
If you're on debian you could use dpkg-buildpackage after checking out the source using apt-source. The big advantage here is that all the build dependencies can be easily installed.
The manual way will probably need you to first build all the other gstreamer packages have a close look on what ./configure tells you
I'm workin on debian and have already built gstreamer+plugins to backport the recent ones to ubuntu (although I'm not sure if I did it in a best-practice way ;) )
/edit: I'll try to cover the basic steps for ubuntu here:
add the source repositories to apt (check the "source code" checkbox in the ubuntu software center's "software sources" tool
sudo apt-get install dpkg-dev devscripts
sudo apt-get build-dep gst-plugins-ugly0.10
apt-get source gst-plugins-ugly0.10
change to the newly created gst-plugins-base* folder
dpkg-buildpackage (and make sure it works)
change the source to your needs
you can rebuild it any time using dpkg-buildpackage (to simply see if it compiles make might be faster though). This creates a .deb file in the parent folder that you can simply install using dpkg -i
If it's a useful change you might want to get in touch with the gstreamer-devs ;)
On a debian system, run apt-get build-dep gstreamer0.10-plugins-ugly to get all the build dependencies for that package. After that you can build the package from git, source tarball or even rebuild the debian package (using dkgp-buildpackage).

How can I trigger a 'yum clean all' from within a yum plugin?

I'm writing a yum plugin that updates the URLs of local repos. When the repo URL changes, I'd like to have yum run a yum clean all to make sure no out-of-date information is cached. I know yum has a hook for running code when yum clean [plugins|all] is requested but is it possible to trigger a clean all from within one of the plugin's other hook functions?
You can do this easily. Yum exposes a library which is consumed by command line program. Here is an example code for yum clean all:
import sys
sys.path.append("/usr/share/yum-cli")
import cli
ybc = cli.YumBaseCli()
ybc.cleanCli(["all"])
In case you want to do more then "clean all" using function check all the APIs exposed by CLI library methods exposed at /user/share/yum-cli folder :)
Regards,