Broken Pacman


Hello there! I broke my archbang recently. Let me tell you how it went. I was doing upgrade via pacman and suddenly electricity failure and it shut down immediately.

For those who don’t know what pacman is: Pacman is a package manager for Arch Linux (Linux distribution) as apt-get is for Ubuntu.

On next boot, many apps like chromium etc. stopped working.

Running chromium from console revealed:

/usr/lib/chromium/chromium: error while loading shared libraries: /usr/lib/libpulse.so.0: file too short

Firefox gave some security error something like “Your connection is not secure“.

The owner of http://www.google.co.in has configured their website improperly. To protect your information from being stolen, Firefox has not connected to this website.
http://www.google.co.in uses an invalid security certificate. The certificate is not trusted because the issuer certificate is unknown. The server might not be sending the appropriate intermediate certificates. An additional root certificate may need to be imported. (Error code: sec_error_unknown_issuer)

 

Then I thought of doing an update via pacman, but running any pacman command result into an exec error:

zsh: exec format error: pacman

On another reboot, I noticed a message (kernel messages): “failed to start intializes pacman keyring“. So at this point, I realized that there is something wrong with the keyring.

Then tried many things like:

pacman -Syyuu

pacman -S pacman

pacman -Scc

Removed /var/lib/pacman/db.lck

Removed /var/lib/pacman/sync

Then I got a link: https://wiki.archlinux.org/index.php/pacman#pacman_is_broken_beyond_repair

It contained a link to a post: https://bbs.archlinux.org/viewtopic.php?id=95007

It said to manually configure the packages: openssl, libarchive, libfetch, pacman

So I downloaded the .pkg.tar.xz files and fired the command below:

sudo tar -xvpf ${pkgname} -C / –exclude .PKGINFO –exclude .INSTALL

where ${pkgname} should be replaced by the package_name.pkg.tar.xz e.g. openssl, pacman etc.

So this overrode the existing binaries, I guess and pacman started working.

But while installing something via pacman like “pacman -S pacman“, then it gave error like:

:: Proceed with installation? [Y/n] Y
(1/1) checking keys in keyring
[######################] 100%
downloading required keys…
:: Import PGP key 20235p273o23o4-somekeyhere, “<Some-name> <some-email>”, created: 2011-06-06? [Y/n] Y

:: File /var/cache/pacman/pkg/pacman-5.0.1-2-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] Y
error: failed to commit transaction (invalid or corrupted package (PGP signature))
Errors occurred, no packages were upgraded.

So it was importing very old keys.

Tried: pacman-key –populate archlinux

Got: 

==> Appending keys from archlinux.gpg…
gpg: no valid OpenPGP data found.
==> Updating trust database…
gpg: no need for a trustdb check

Then tried:
sudo rm -rf /etc/pacman.d/gnupg
sudo pacman-key –init

These were working but attempting installing something still gave that PGP error thing.

 

What solved my problem?

sudo pacman-key –refresh-keys

Followed:
http://www.cupoflinux.com/SBB/index.php?topic=2959.0

Then pacman started installing things but it still gave some errors while doing that:

(1/1) upgrading gnome-terminal                     [######################] 100%
ldconfig: File /usr/lib/libssh.so is empty, not checked.
ldconfig: File /usr/lib/libass.so is empty, not checked.
ldconfig: File /usr/lib/liboslquery.so is empty, not checked.

and a long list of errors like above.
Those errors mean that you have a missing installation of certain packages. If you find and reinstall those packages by:

pacman -Syyf <PACKAGE_NAME_HERE>

you’ll reinstall and dismiss those errors. But -f option is no longer supported, one may use –force instead. https://bbs.archlinux.org/viewtopic.php?id=85480

 

Hence I used the following command:

sudo pacman -Qnq | pacman -S –force –

https://bbs.archlinux.org/viewtopic.php?id=209493

What it did was to find and reinstall all the installed packages (around 1GB of downloading).

Finally got everything working.

 

Installing git-cola (git GUI client) on ArchBang


git-cola is a git client having a GUI. Visit https://github.com/git-cola/git-cola to install for a different distribution or for further detail. There are many other GUI clients. You may see them on https://git-scm.com/download/gui/linux

Now it requires sphinx (for documentation) to be installed. So install it using:

sudo pip install Sphinx==1.3.3

It depends on python2-pyqt4 package. So install it using:

sudo pacman -S python2-pyqt4

Install tk (if not already installed):

sudo pacman -S tk

Note: If you don’t install tk and run git-cola it’ll give error like:

/usr/bin/gitk: line 3: exec: wish: not found

Now install git-cola using yaourt:

yaourt -S git-cola

 

There are two commands: git-cola and git-dag.

git-cola includes all the workflow like showing currently unstaged files (on right) and after clicking one of them, it shows in the left large pane. Also it uses gitk to visualize the branches.

git-dag includes the visual representation of the git log command and shows the diagram of the commits and all that.

Installing Yaourt on ArchBang


Yaourt (Yet AnOther User Repository Tool) is a wrapper for pacman which adds automated access to the AUR using the same syntax as pacman.

To put simply, there are some packages that you can’t install from the official repositories by the use of default package manager i.e. pacman. So to install packages from Archlinux User Repository (AUR), we need yaourt.

Following is the process of installing yaourt.

Check whether the dependencies (base-devel and yajl) are installed or not:

$ pacman -Ss base-devel  # check whether the package is installed
$ pacman -Ss yajl        # check whether the package is installed
$ sudo pacman -S base-devel yajl  # install if necessary

 

For a cleaner approach create a new directory and work there:

$ mkdir -p ~/temp/AUR/ && cd ~/temp/AUR/

 

Use the following commands to install package-query:

$ wget https://aur.archlinux.org/cgit/aur.git/snapshot/package-query.tar.gz  # download source tarball
$ tar xfz package-query.tar.gz  # unpack tarball
$ cd package-query  &&  makepkg  # cd and create package from source
$ sudo pacman -U package-query*.pkg.tar.xz  # install package - need root privileges

 

Now install yaourt in the same way:

$ wget https://aur.archlinux.org/cgit/aur.git/snapshot/yaourt.tar.gz
$ tar xzf yaourt.tar.gz
$ cd yaourt  &&  makepkg
$ sudo pacman -U yaourt*.pkg.tar.xz

 

Then I tried installing git-cola using yaourt by:

yaourt -S git-cola

 

Here is my workaround for installing yaourt using above commands. The following is snippet from my history commands (neglect the numbers in the left column):

 3873  pacman -Ss base-devel
 3874  pacman -Ss yajl
 3875  sudo pacman -S yajl
 3876  mkdir -p ~/temp/AUR/ && cd ~/temp/AUR
 3879  wget https://aur.archlinux.org/cgit/aur.git/snapshot/package-query.tar.gz
 3880  ls
 3881  tar xfz package-query.tar.gz
 3883  cd package-query
 3885  makepkg
 3886  ls
 3887  sudo pacman -U package-query*.pkg.tar.xz
 3888  cd ..
 3889  wget https://aur.archlinux.org/cgit/aur.git/snapshot/yaourt.tar.gz
 3892  ls
 3902  tar xzf yaourt.tar.gz
 3904  cd yaourt && makepkg
 3905  sudo pacman -U yaourt-1.7-1-any.pkg.tar.xz
 3907  yaourt
 3908  yaourt -S git-cola               #just to test if it works

Reference: https://astrofloyd.wordpress.com/2015/01/17/installing-yaourt-on-arch-linux/

Installing LAMP on ArchBang


First of all update and upgrade your system:

sudo pacman -Syu

APACHE

Install apache

sudo pacman -Syu apache

 

Configuring Apache:

Note: Always create a backup file before editing files critical files. You can copy the particular file before editing (use cp command).

 

Edit /etc/httpd/conf/extra/httpd-mpm.conf to have this:

<IfModule mpm_prefork_module>
StartServers        2
MinSpareServers     6
MaxSpareServers     12
MaxRequestWorkers   30
MaxRequestsPerChild 3000
</IfModule>

 

Edit /etc/httpd/conf/extra/httpd-default.conf:

KeepAlive Off

 

To make Apache auto-start at boot:

sudo systemctl enable httpd.service

 

Now type localhost in your browser. This should show Index / in browser because no file is currently there.

 

Now configuring virtual hosts.

Edit file: /etc/httpd/conf/httpd.conf and edit the line containing DocumentRoot and set it to:

DocumentRoot "/srv/http/default"

 

Now go to almost bottom of the file i.e. near line 500 (or 92% of file) and Uncomment the line:

Include conf/extra/httpd-vhosts.conf

 

Now open /etc/httpd/conf/extra/httpd-vhosts.conf and paste the following:

<VirtualHost *:80> 
     ServerAdmin root@localhost
     ServerName localhost
     ServerAlias localhost
     DocumentRoot /srv/http/localhost/public_html/
     ErrorLog /srv/http/localhost/logs/error.log 
     CustomLog /srv/http/localhost/logs/access.log combined
            <Directory />
               Order deny,allow
               Allow from all
            </Directory>
</VirtualHost>

You can replace localhost with your domain name.

 

Now create the directories according to the configuration done above:

sudo mkdir -p /srv/http/default
sudo mkdir -p /srv/http/localhost/public_html
sudo mkdir -p /srv/http/localhost/logs

 

Now restart Apache:

sudo systemctl restart httpd.service

It will still show you an Index / page when you type in ‘localhost’ in the browser. If you want a custom web page to appear while doing the same, then go and createa new file:

/srv/http/localhost/public_html/index.html 

And add some text that you want it to show. That’s it.

 

MySQL

In Arch, MariaDB can be used alternatively of MySQL.

So, installing the mariadb, mariadb-clients and libmariadbclient packages using the following command:

sudo pacman -Syu mariadb mariadb-clients libmariadbclient

Install MariaDB data directory:

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

All mysql command will work as usual with MariaDB.

Now to make it start on boot:

sudo systemctl start mysqld.service 
sudo systemctl enable mysqld.service  

At last, to have secure installation, run:

mysql_secure_installation

And set root password (Press Enter for current password) and then enter new password for root. Remove remote login, anonymous users, test database and reload privileges tables.

You can now test the installation by firing this command:

mysql -u root -p

It will prompt for your password that you have just set.
Then you can try creating database, tables as usual.

 

PHP

sudo pacman -Syu php php-apache

 

Edit /etc/php/php.ini and search for following lines and uncomment and modify them:

error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
log_errors = On 
error_log = /var/log/php/error.log
max_input_time = 30
extension=mysql.so

 

Create the log directory for PHP and give the Apache user ownership:

sudo mkdir /var/log/php
sudo chown http /var/log/php

Enable the PHP module in the /etc/httpd/conf/httpd.conf by adding these lines at the end:

#Dynamic Shared Object (DSO) Support
LoadModule php5_module modules/libphp5.so
# Supplemental configuration
# PHP 5
Include conf/extra/php5_module.conf

# Located in the <IfModule mime_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

In the same file, comment out the line LoadModule mpm_event_module modules/mod_mpm_event.so by adding a # in front, and add the line:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

And add the following line:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Restart Apache server:

sudo systemctl restart httpd.service

 

phpMyAdmin

Install phpMyAdmin using the following command:

sudo pacman -S phpmyadmin

Enable the mysqli and mcrypt by editing /etc/php/php.ini and uncommenting the following lines:

extension=mysqli.so
extension=mcrypt.so

You need to make sure that PHP can access /etc/webapps. Add it to open_basedir in /etc/php/php.ini if necessary:

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/

Edit /etc/httpd/conf/extra/phpmyadmin.conf file:

Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
    DirectoryIndex index.php
    AllowOverride All
    Options FollowSymlinks
    Require all granted
</Directory>

 

Edit /etc/httpd/conf/httpd.conf:

# phpMyAdmin configuration
Include conf/extra/phpmyadmin.conf

 

Restart Apache again:

sudo systemctl restart httpd.service

 

Now click on http://localhost/phpmyadmin/ and see phpMyAdmin opening in the new tab.

 

Sources:

https://www.linode.com/docs/websites/lamp/lamp-server-on-arch-linux

https://wiki.archlinux.org/index.php/PhpMyAdmin