gitup quarterly -c
and your ports tree is back and usable again. /
If using long path names it can cause larger damages if you hit the return button by accident before finished typing, especially on using something like rm -Rf
rm [ ] ./[ ]
Hi fmc000You basically ended up with a base FreeBSD system without ports. I think you should be able to rebuild your installation by re-creating /usr/local/etc/pkg/repos/FreeBSD.conf
and do a pkg upgrade -f .
Best option is, of course, restore from backup.
pkg bootstrap -f
, as /usr/local/sbin/pkg is gone. pkg upgrade -f
can fail, as old version to be deleted are already gone, thus, possibility to error out is not purely zero (hope lim0, though).Hi vmisevSorry, I only now remembered that 'prime-list' is an alias which resided in /usr/local/etc/pkg.conf so if there is nothing under /usr/local/ this will not work.
Instead of 'pkg prime-list' try with:
pkg query -e '%a = 0' '%n' > pkg-list.txt
pkg query -e '%a = 0' '%n' > pkg-list.txt
That one line, by itself, will only make file pkg-list.txt. But, T-Aoki is right, you need to bootstrap
pkg
again, I forgot about that “smal” detail as well su -
pkg bootstrap -f
pkg query -e '%a = 0' '%n' > pkg-list.txt
pkglist=$(cat pkg-list.txt)
pkg install $pkglist
Yeah, so did I.T-Aoki is right, you need to bootstrap pkg again, I forgot about that “small” detail as well
Hi vmisevThat one line, by itself, will only make file pkg-list.txt. But, T-Aoki is right, you need to bootstrap pkg again, I forgot about that “smal” detail as wellSo, try:
su -
pkg bootstrap -f
pkg query -e '%a = 0' '%n' > pkg-list.txt
pkglist=$(cat pkg-list.txt)
pkg install $pkglist
Hi MaturinThat's bad.
Like fmc000 said, you end up with a basic system, and killed (almost) everything else.
That's why you can still login, but have no GUI anymore, because also completely removed X11, its config, and all what belongs to it...and many things more...
/usr/local/ does not contain the ports tree - that was the least problem to reinstall that:
After you installed gitup just do agitup quarterly -c
and your ports tree is back and usable again.
Best was, as fmc000 also already said: restore from backups. Maybe there is a snapshot you can fall back on.
Besides /home/ where my production data lives, I additionally also backup regulary all the config stuff I spent time on: /etc/, of course, also /var/cron/tabs/ (if you're using cron), and as sidetone also mentioned /usr/local/etc/ because that's where not only but above all X11's config lives.
If you don't have any copy of that directory, you need to at least reinstall all packages again. Then it's unvoidable to do all the config you spent time on again all by scratch again. In many cases it will be done when your X11 runs again as you are used to.
To put something positive into it:
This is an important learning experience on unix[like] systems. I guess every BSDer/Unixer at least once killed a crucial directory by accident
The best part: You now learned to be really careful with your user root. Such will not happen again.
Tips:
- my user root's shell prompt is set to yellow text on red background, to see directly: "This is a root's shell!"
- as root change into the directories you're going to do work in. Many pathes start with/
If using long path names it can cause larger damages if you hit the return button by accident before finished typing, especially on using something likerm -Rf
As root always use rm asrm [ ] ./[ ]
-Backups! Backups! Backups! DO BACKUPS!
To reconsider, test, adapt, upgrade, and improve your backup plan is a continous escorting #1 top priority job on all computer systems - no matter how stable they are. #1 reason by far for the need of backups are neither hacker attacks, nor hardware failures, but stupid accidents like this one.
If things like this happen - and they happen! sooner, or later to everybody,
it's either no big deal, because there are backups you can fall back on, and restore all quickly and easy,
or - if not - your backup plan urgently needs to be revised, and adapted.
/usr/ports
rm -rf /usr/ports/*
does not work here as intended. Even rm -Rf
does no good to the situation as it seems!You are not telling us much.
pkg bootstrap -f
, what is a content of your pkg-list.txt made by pkg query -e '%a = 0' '%n' > pkg-list.txt
, and what was the output of pkg install $pkglist
?Hi vmisevYou are not telling us much.
What was the output of pkg bootstrap -f, what is a content of your pkg-list.txt made by pkg query -e '%a = 0' '%n' > pkg-list.txt, and what was the output of pkg install $pkglist?
locate pkg-list.txt
. su -
first.su -
whoami; pwd
root
/root
echo $SHELL
/bin/sh
pkg query -e '%a = 0' '%n'
pkg query -e '%a = 0' '%n' > pkg-list.txt
ls
cat pkg-list.txt
pkg query
without redirection.pkglist=$(cat pkg-list.txt)
echo $pkglist
pkg install -f $pkglist
It's not so much an "upgdate", as a complete deletion of the ports tree, and then a complete new installation of it.Wanted to update about the gitup command as mentioned in your post.
I crossed it out this of my post again, since ports don't live under /usr/local/, what as you was saying was the "only" directory you killed. So there was no need to reinstall the ports tree. But since you did a rm -Rf on it, now there is.rm -rf /usr/ports/*
does not work here as intended.
cd /usr/ports/
, check if it's empty ls -la
I bet you'll see some files left - those may the reason why it fails. Delete them all by hand, then repeat the gitup command I posted above (Of course gitup needs to be installed first, since it's not part of the basic system, which may the other cause why this fails if it's not.) dd
the according imagefile to (it's in the HB how this is done.)Hi vmisevOK, lets do it step by step.
First are you the root user and in the /root directory? You should be if you did su - first.
Do
su -
enter root password and check who and where you are with
whoami; pwd
If output is
root
/root
Then check that you are using sh shell
echo $SHELL
Output should be
/bin/sh
Then do
pkg query -e '%a = 0' '%n'
You should see bunch of packages listed in the console. If that works, do
pkg query -e '%a = 0' '%n' > pkg-list.txt
ls
Ifpkg-list.txt
is there, do
cat pkg-list.txt
Output should be same as just pkg query without redirection.
Then make variable with a contest of that file:
pkglist=$(cat pkg-list.txt)
check that variable has right content with
echo $pkglist
If you see number of packages printed in one long line, proceed with
pkg install -f $pkglist
You have to force install them. According to pkg(8) (database at /var/db/pkg/local.sqlite) those packages are already installed. Doesn't matter if the actual files are gone, the package is registered as being installed. You have to force in order to reinstall.pkg install $pkglist
-f, --force
Force the reinstallation of the package if already installed.
pkg upgrade -f
-f, --force
Force the reinstallation or upgrade of the whole set of
packages.
locate(1) is NOT a good tool here.Can’tlocate pkg-list.txt
.
You are absolutely right, but I already corrected myself in #16You have to force install them. According to pkg(8) (database at /var/db/pkg/local.sqlite) those packages are already installed. Doesn't matter if the actual files are gone, the package is registered as being installed. You have to force in order to reinstall.
pkg-install(8)Code:-f, --force Force the reinstallation of the package if already installed.
Probably the best and easiest way to restore everything is topkg upgrade -f
This will download and reinstall and/or upgrade everything you had installed.
pkg-upgrade(8)Code:-f, --force Force the reinstallation or upgrade of the whole set of packages.
If you see number of packages printed in one long line, proceed with
pkg install -f $pkglist
Hi SirDiceYou have to force install them. According to pkg(8) (database at /var/db/pkg/local.sqlite) those packages are already installed. Doesn't matter if the actual files are gone, the package is registered as being installed. You have to force in order to reinstall.
pkg-install(8)Code:-f, --force Force the reinstallation of the package if already installed.
Probably the best and easiest way to restore everything is topkg upgrade -f
This will download and reinstall and/or upgrade everything you had installed.
pkg-upgrade(8)Code:-f, --force Force the reinstallation or upgrade of the whole set of packages.
Not every records would be preserved, but all info about "what was installed at the moment you missingly deleted /usr/local" should be kept at least at the moment.Hi SirDice
In reference to your last post, may i assume that only the recently installed pkg list is available and all the pkg's install list since OS's install are lost.
Thanks
rraj