You are not logged in.

#1 2010-04-10 17:48:04

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

How to reinstall pacman when pacman is broken

Some users had pain during the move of the openssl rebuilds to the main repos. Often this seems to be because they were upgrading against mirrors that hadn't fully synched. For whatever reason, some users found themselves with a broken pacman, and didn't know how to fix it. The solutions have been posted in several places. I'm making this new thread for easy reference. I don't know if anyone is still going to need it for the current round of upgrades. But the principles are simple and really should be known by the typical Arch user.

The basic idea is: get ahold of the necessary packages, either from your cache or by downloading it. Manually untar them onto your root. Then you should have a working pacman binary. Then use that to *reinstall* the packages to make sure your pacman db is in synch with what you actually have on your system.

Here's a script that would have worked to fix a broken pacman during the openssl upgrades:

#!/bin/bash

arch=x86_64
mirror=http://mirror.rit.edu/archlinux

# link to cache (or download) and extract: openssl,libarchive,libfetch,pacman
cd /tmp
for pkg in openssl-1.0.0-2 libarchive-2.8.3-3 libfetch-2.30-3 pacman-3.3.3-5; do
    pkgname=${pkg}-${arch}.pkg.tar.gz
    if [[ -e /var/cache/pacman/pkg/${pkgname} ]]; then
        ln -sf /var/cache/pacman/pkg/${pkgname} .
    else
        wget ${mirror}/core/os/${arch}/${pkgname} || exit 1
    fi
    sudo tar -xvpf ${pkgname} -C / --exclude .PKGINFO --exclude .INSTALL || exit 1
done

# now reinstall using pacman to update the local pacman db 
sudo pacman -Sf openssl libarchive libfetch pacman || exit 1

# now update your system
sudo pacman -Syu

Others should feel free to enhance/criticize/suggest changes.

Offline

#2 2010-04-10 22:32:36

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 178

Re: How to reinstall pacman when pacman is broken

Profjim wrote:

arch=x86_64

That will give you ELF errors if your system is i686 - which is kinda bad when you already have a broken pacman cool.

Also maybe instead of just untarring/replacing pacman.conf, the current pacman.conf could be backed up and replace the default one *after* untar; the ones relying to "Server =" lines in pacman.conf can't download anything with pacman without fixing pacman.conf manually. You might have other settings there that you want to preserve, too.

Last edited by algorythm (2010-04-10 22:43:39)


PC: ASUS Maximus VIII Hero, Intel i7-6700K (4.6 GHz OC), NZXT Kraken X61, 16GB G.Skill DDR4-3200, MSI GTX 1080 Gaming X, Samsung 850 Pro 512GB, WD Black 6TB, Corsair Graphite 780T (Full Tower), be quiet! Dark Power Pro 11 650W (Platinum)
OS: Arch 64-bit / Windows 10 Pro 64-bit
Other: Dell UltraSharp 2560x1440 27", KB: Logitech G910, M: Logitech G502, HS: HyperX Cloud II, I: 100/10M

Offline

#3 2010-04-10 22:47:52

tomd123
Developer
Registered: 2008-08-12
Posts: 565

Re: How to reinstall pacman when pacman is broken

add something like

arch=i686
[ `uname -m` = "x86_64" ] && arch=x86_64

Offline

#4 2010-04-10 22:51:41

Pierre
Developer
From: Bonn
Registered: 2004-07-05
Posts: 1,950
Website

Re: How to reinstall pacman when pacman is broken

or just arch=$(uname -m)

You could also wget the core.db.tar.gz, run bsdtar tf on it and grep the output to get the correct pacman, libfetch etc. versions.

Or in general: see if you manage to get pacman compiled statically.

Offline

#5 2010-04-10 23:19:07

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: How to reinstall pacman when pacman is broken

I think profjim placed that "arch=" in a variable so that users could enter there own as needed.

but this would do it too

arch=`uname -m`

Offline

#6 2010-04-11 00:29:07

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: How to reinstall pacman when pacman is broken

tawan wrote:

I think profjim placed that "arch=" in a variable so that users could enter there own as needed.

but this would do it too

arch=`uname -m`

Exactly. I knew one could look the arch up, but I was too lazy to remember how.

Thanks for the improvements!

Offline

#7 2010-05-02 20:15:31

rockdragon
Member
Registered: 2010-05-02
Posts: 5

Re: How to reinstall pacman when pacman is broken

Hi (and sry for my english wink ) ,
i just ran into the same problem but my wget refused to work too (because of libssl.so.0.9.8...)

Download the newest source for wget on another computer and copy it to a usb flash drive.
(http://ftp.gnu.org/pub/gnu/wget/wget-1.12.tar.bz2)

Plug it to the computer that runs Arch and mount it to /mnt, then:

#cd /mnt
#tar xfj wget-1.12.tar.bz2
#cd wget-1.12
#./configure --without-ssl && make && make install

On my system it installed to /usr/local/bin/wget

Download Profjim's script (I hadn't X installed)

#/usr/local/bin/wget http://bbs.archlinux.org/viewtopic.php?id=95007
and get it with your bare hands wink
#vi viewtopic.php?id=95007 && mv viewtopic.php?id=95007 script.sh && chmod u+x script.sh

Then, I made some changes (#vi script.sh):

#!/bin/bash

arch=$(uname -m)
mirror=http://mirror.rit.edu/archlinux

# link to cache (or download) and extract: openssl,libarchive,libfetch,pacman
cd /tmp
for pkg in openssl-1.0.0-2 libarchive-2.8.3-3 libfetch-2.30-3 pacman-3.3.3-5; do
    pkgname=${pkg}-${arch}.pkg.tar.gz
    if [[ -e /var/cache/pacman/pkg/${pkgname} ]]; then
        ln -sf /var/cache/pacman/pkg/${pkgname} .
    else
        /usr/local/bin/wget ${mirror}/core/os/${arch}/${pkgname} || exit 1
    fi
    tar -xvpf ${pkgname} -C / --exclude .PKGINFO --exclude .INSTALL || exit 1
done

# now reinstall using pacman to update the local pacman db 
pacman -Sf openssl libarchive libfetch pacman || exit 1

# now update your system
pacman -Syu

Now just type
#./script.sh

Offline

#8 2010-05-03 15:47:57

wzff
Member
From: Nowhere
Registered: 2009-10-15
Posts: 9

Re: How to reinstall pacman when pacman is broken

I'd actually prefer if pacman.static would still build. (it didn't, last time I checked, and nobody of the pacman devs seems to give a shit)
I'd also like a freebsd-alike /stand with statically linked coreutils for emergency cases... maybe as an extra package and based on busybox or something. (although this might not be completely related to this thread)

Offline

#9 2010-05-14 08:17:58

justin.christensen
Member
Registered: 2010-05-14
Posts: 3

Re: How to reinstall pacman when pacman is broken

Hi, I have a VPS that offers Archlinux, but it is version 0.8. Very old, with pacman 2.9.3 or something like that. I have searched for hours to try to get everything updated, keep finding problems. This was actually working, but after running it, pacman stops working because of missing library dependencies. I have been able to figure out which packages I need to update to fix these broken deps, and installing them using this method, which worked up until GLIBC had to be updated. Now this maybe a stupid question, but I haven't been able to figure it out: How do I decompress .tar.xz files? I already installed xz-utils, and I assume that has something to do with it, but for the life of me I can't figure out how to use any of it, and when I type man xz-utils I get nothing. sad

Offline

#10 2010-05-14 08:20:34

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 6,856

Re: How to reinstall pacman when pacman is broken

The binary is named xz


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#11 2010-05-14 08:28:28

justin.christensen
Member
Registered: 2010-05-14
Posts: 3

Re: How to reinstall pacman when pacman is broken

Oh gee, some hard brain work prevailed and I answered my own question by typing 'xz' and hitting tab twice, which brought up a few programs, the most notable being xzdec, so I typed 'xzdec -h' to find that xzdec sends to std. output, so 'xzdec glibc*********.tar.xz > glibc***********.tar' was all it took to carry on. Will post whether or not it works in the end for anyone trying to upgrade from arch 0.8 to current.

Offline

#12 2010-05-14 08:42:03

justin.christensen
Member
Registered: 2010-05-14
Posts: 3

Re: How to reinstall pacman when pacman is broken

ngoonee wrote:

The binary is named xz

gee, that may have been easier. lol. well my way worked and i am currently upgrading my system. thanks though.

Offline

#13 2011-03-24 06:04:37

yochaigal
Member
From: Boston
Registered: 2011-02-06
Posts: 169

Re: How to reinstall pacman when pacman is broken

Unfortunately the link to that mirror was dead...
I had a broken pacman, but the dependencies were ok. So I just did:

wget ftp://mirror.aarnet.edu.au/pub/archlinux/core/os/i686/pacman-3.5.1-1-i686.pkg.tar.gz
sudo tar -xvpf pacman-3.5.1-1-i686.pkg.tar.gz -C / --exclude .PKGINFO --exclude .INSTALL

I got the mirror from /etc/pacman.d/mirrorlist

EDIT: code snippets.

Last edited by yochaigal (2011-03-24 06:11:54)

Offline

#14 2011-04-21 22:57:36

G0d's-servant
Member
From: Islamic Republic of Iran
Registered: 2011-03-18
Posts: 39

Re: How to reinstall pacman when pacman is broken

you tried solve it with this way: https://wiki.archlinux.org/index.php/Kernel_Panics
just their difference is that must replace "kernel" with "pacman". I think being solved.

Offline

#15 2011-06-01 12:58:47

civet
Member
Registered: 2011-05-29
Posts: 9

Re: How to reinstall pacman when pacman is broken

how about yaourt pacman to reinstall pacman?

Offline

#16 2011-06-01 13:04:05

karol
Archivist
Registered: 2009-05-06
Posts: 25,432

Re: How to reinstall pacman when pacman is broken

civet wrote:

how about yaourt pacman to reinstall pacman?

In what sense? yaourt is a pacman wrapper and it needs pacman to e.g. install packages.

Last edited by karol (2011-06-01 13:04:41)

Offline

#17 2011-07-30 10:38:13

mouni
Member
From: Azores
Registered: 2011-07-03
Posts: 15

Re: How to reinstall pacman when pacman is broken

Help alot. Thank you.


"See, you not only have to be a good coder to create a system like Linux, you have to be a sneaky bastard too." - Linus Torvalds

Offline

#18 2011-09-25 22:50:23

mitcoes
Member
Registered: 2007-09-29
Posts: 10

Re: How to reinstall pacman when pacman is broken

First of all I would like at installation script at least 2 multichoice option Gnome newbi, KDE newbi and K+G newbi, where with a click I would have a "normal installation" from where I can install further packages.

My installation had  no pacman, startx did not work, and kdm did, I can enter at KDE and Gnome, with no pacman, and no sudo but ...

I was able to use su. Then I had to reconfigure the script, and as package numbers where obsolete figure what are the actual numbers,

Today the script that worked for me was this - it is at the end -


But as I am not good at script language - enough to read and understand - it would be better if it would use * instead of numbers for packages, I did something like that in a pedestrian way, with * and 1 to one to retrieve the actual versions to finally rewrite the script. But anyone with script language knowledge would improve this method.

 #!/bin/bash

arch=x86_64
mirror=ftp://mirror.archlinux.no/


# link to cache (or download) and extract: openssl,libarchive,libfetch,pacman
cd /tmp
for pkg in openssl-1.0.0.e-1 libarchive-2.8.5-1 libfetch-2.33-3 pacman-3.5.4-4; do
    pkgname=${pkg}-${arch}.pkg.tar.gz
    if [[ -e /var/cache/pacman/pkg/${pkgname} ]]; then
        ln -sf /var/cache/pacman/pkg/${pkgname} .
    else
        wget ${mirror}/core/os/${arch}/${pkgname} || exit 1
    fi
    tar -xvpf ${pkgname} -C / --exclude .PKGINFO --exclude .INSTALL || exit 1
done

# now reinstall using pacman to update the local pacman db 
pacman -Sf openssl libarchive libfetch pacman || exit 1

# now update your system
pacman -Syu

Last edited by mitcoes (2011-09-26 08:22:42)

Offline

#19 2011-10-15 00:27:09

manning
Member
Registered: 2011-09-07
Posts: 2

Re: How to reinstall pacman when pacman is broken

I do not understand how to run this as a script.  I am comfortable with the command line.

So how do I run this as a script?

Thanks!

Offline

#20 2011-10-15 00:34:43

karol
Archivist
Registered: 2009-05-06
Posts: 25,432

Re: How to reinstall pacman when pacman is broken

manning wrote:

I do not understand how to run this as a script.  I am comfortable with the command line.

So how do I run this as a script?

Thanks!

You save a script to a file, make i executable and run it. Let's say you named the file 'foo':

[karol@black ~]$ chmod +x foo
[karol@black ~]$ ./foo

Offline

#21 2011-11-01 17:12:02

kdy2206
Member
Registered: 2011-10-31
Posts: 7

Re: How to reinstall pacman when pacman is broken

i have the same problem ;(

Offline

#22 2011-11-01 18:04:23

fsckd
Forum Moderator
Registered: 2009-06-15
Posts: 3,575

Re: How to reinstall pacman when pacman is broken

kdy2206 wrote:

i have the same problem ;(

And what problem is that?


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#23 2011-12-09 06:23:13

WoC
Member
Registered: 2011-12-09
Posts: 1

Re: How to reinstall pacman when pacman is broken

Seems to be fetching all files, but then i get;

pacman: error while loading shared libraries: libbz2.so.1.0: cannot open shared object file: No such file or directory


#!/bin/bash

arch=`uname -m`

mirror=ftp://mirror.archlinux.no/


# link to cache (or download) and extract: openssl,libarchive,libfetch,pacman
cd /tmp
for pkg in openssl-1.0.0.e-1 libarchive-2.8.5-2 libfetch-2.33-3 pacman-3.5.4-4; do
    pkgname=${pkg}-${arch}.pkg.tar.gz
    if [[ -e /var/cache/pacman/pkg/${pkgname} ]]; then
        ln -sf /var/cache/pacman/pkg/${pkgname} .
    else
        wget -c ${mirror}/core/os/${arch}/${pkgname} || exit 1
    fi
    tar -xvpzf ${pkgname} -C / --exclude .PKGINFO --exclude .INSTALL || exit 1
done

# now reinstall using pacman to update the local pacman db 
pacman -Sf openssl libarchive libfetch pacman || exit 1

# now update your system
pacman -Syu

Last edited by WoC (2011-12-09 06:39:26)

Offline

#24 2011-12-09 06:26:38

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,176
Website

Re: How to reinstall pacman when pacman is broken

Edit: my response was to a post that was later edited beyond recognition, so disregard.

Last edited by /dev/zero (2011-12-09 06:43:20)


Linux is NOT Windows | The Rootless Root
Toshiba Satellite i5-3230M 2.6GHz CPUs, 4Gb RAM, ArchLinux, wmii, nVidia GeForce GT 740M.

Offline

#25 2011-12-09 06:27:20

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 6,856

Re: How to reinstall pacman when pacman is broken

Check www.archlinux.org to find out what the latest version number is.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

Board footer

Powered by FluxBB