gevent Quickstart Guide

This is a simple list of steps on how to get started with installing gevent on openSUSE (tested on openSUSE 13.1 with gevent 1.0.1). We’ll use virtualenv instead of a system-wide install.

You need to have a compiler (gcc) and Python development library.

[user@host ~] $ sudo zypper install gcc python-devel

Install Python 2.7 virtualenv, since gevent 1.0.1 doesn’t appear to support Python 3.

[user@host ~] $ sudo zypper install python-virtualenv

Create virtual environment in your home directory (or anywhere else you want).

[user@host ~] $ virtualenv ~/virt

Activate the virtualenv.

[user@host ~] $ source virt/bin/activate

Install gevent.

(virt) [user@host ~] $ pip install gevent

Check it all works.

(virt) [user@host ~] $ python

Python 2.7.6 (default, Nov 21 2013, 15:55:38) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gevent import sleep
>>> sleep(2)
>>> 

When you’re done deactivate the virtualenv.

(virt) [user@host ~] $ deactivate

Advertisements

zypper Cookbook: Autoremove Packages and Remove Orphaned Packages

As I learned how to autoremove unnecessary packages as you remove a package and also how to identify orphaned packages, I marveled at the beauty of zypper and the excellent work of all its contributors. Not only does zypper have the functionality to do just about anything related to repos and packages, it has sensible online help right at your fingertips.

Before I show how to perform these two tasks this post is primarily about, let me show you two easy ways to figure out whether zypper can do what you want to do.

The first thing is global help on what is available with zypper.

zypper help

  Usage:
	zypper [--global-options]  [--command-options] [arguments]

  Global Options:
	--help, -h		Help.
	--version, -V		Output the version number.
	--promptids		Output a list of zypper's user prompts.
	--config, -c 	Use specified config file instead of the default.
	--userdata 	User defined transaction id used in history and plugins.
	--quiet, -q		Suppress normal output, print only error
				messages.
	--verbose, -v		Increase verbosity.
	--no-abbrev, -A		Do not abbreviate text in tables.
	--table-style, -s	Table style (integer).
	--rug-compatible, -r	Turn on rug compatibility.
	--non-interactive, -n	Do not ask anything, use default answers
				automatically.
	--non-interactive-include-reboot-patches
				Do not treat patches as interactive, which have
				the rebootSuggested-flag set.
	--xmlout, -x		Switch to XML output.
	--ignore-unknown, -i	Ignore unknown packages.

	--reposd-dir, -D 	Use alternative repository definition file
				directory.
	--cache-dir, -C 	Use alternative directory for all caches.
	--raw-cache-dir 	Use alternative raw meta-data cache directory.
	--solv-cache-dir 	Use alternative solv file cache directory.
	--pkg-cache-dir 	Use alternative package cache directory.

     Repository Options:
	--no-gpg-checks		Ignore GPG check failures and continue.
	--gpg-auto-import-keys	Automatically trust and import new repository
				signing keys.
	--plus-repo, -p 	Use an additional repository.
	--disable-repositories	Do not read meta-data from repositories.
	--no-refresh		Do not refresh the repositories.
	--no-cd			Ignore CD/DVD repositories.
	--no-remote		Ignore remote repositories.

     Target Options:
	--root, -R 	Operate on a different root directory.
	--disable-system-resolvables
				Do not read installed packages.

  Commands:
	help, ?			Print help.
	shell, sh		Accept multiple commands at once.

     Repository Management:
	repos, lr		List all defined repositories.
	addrepo, ar		Add a new repository.
	removerepo, rr		Remove specified repository.
	renamerepo, nr		Rename specified repository.
	modifyrepo, mr		Modify specified repository.
	refresh, ref		Refresh all repositories.
	clean			Clean local caches.

     Service Management:
	services, ls		List all defined services.
	addservice, as		Add a new service.
	modifyservice, ms	Modify specified service.
	removeservice, rs	Remove specified service.
	refresh-services, refs	Refresh all services.

     Software Management:
	install, in		Install packages.
	remove, rm		Remove packages.
	verify, ve		Verify integrity of package dependencies.
	source-install, si	Install source packages and their build
				dependencies.
	install-new-recommends, inr
				Install newly added packages recommended
				by installed packages.

     Update Management:
	update, up		Update installed packages with newer versions.
	list-updates, lu	List available updates.
	patch			Install needed patches.
	list-patches, lp	List needed patches.
	dist-upgrade, dup	Perform a distribution upgrade.
	patch-check, pchk	Check for patches.

     Querying:
	search, se		Search for packages matching a pattern.
	info, if		Show full information for specified packages.
	patch-info		Show full information for specified patches.
	pattern-info		Show full information for specified patterns.
	product-info		Show full information for specified products.
	patches, pch		List all available patches.
	packages, pa		List all available packages.
	patterns, pt		List all available patterns.
	products, pd		List all available products.
	what-provides, wp	List packages providing specified capability.

     Package Locks:
	addlock, al		Add a package lock.
	removelock, rl		Remove a package lock.
	locks, ll		List current package locks.
	cleanlocks, cl		Remove unused locks.

     Other Commands:
	versioncmp, vcmp	Compare two version strings.
	targetos, tos		Print the target operating system ID string.
	licenses		Print report about licenses and EULAs of
				installed packages.
	download		Download rpms specified on the commandline to a local directory.
	source-download		Download source rpms for all installed packages
				to a local directory.

Type 'zypper help ' to get command-specific help.

The second thing is the last line in the output of zypper help: how to get help on the commands available with zypper. For example, let’s lookup help for packages command.

zypper help packages

packages (pa) [options] [repository] ...

List all packages available in specified repositories.

  Command options:

-r, --repo   Just another means to specify repository.
-i, --installed-only      Show only installed packages.
-u, --uninstalled-only    Show only packages which are not installed.
    --orphaned            Show packages which are orphaned (without repository).
    --suggested           Show packages which are suggested.
    --recommended         Show packages which are recommended.
    --unneeded            Show packages which are unneeded.
-N, --sort-by-name        Sort the list by package name.
-R, --sort-by-repo        Sort the list by repository.

Lookie here now, we found a way to identify orphaned packages.

zypper packages --orphaned

Loading repository data...
Reading installed packages...
S | Repository | Name                          | Version   | Arch  
--+------------+-------------------------------+-----------+-------
i | @System    | openSUSE-release-livecd-gnome | 13.1-1.10 | x86_64

Go right ahead and remove the orphaned packages that offend you so.

We can go one step further and make sure any packages that only depend on the package you’re removing are also removed.

zypper help remove

remove (rm) [options]  ...

Remove packages with specified capabilities.
A capability is NAME[.ARCH][OP], where OP is one
of <, =, >.

  Command options:
-r, --repo     Load only the specified repository.
-t, --type            Type of package (package, patch, pattern, product).
                            Default: package.
-n, --name                  Select packages by plain name, not by capability.
-C, --capability            Select packages by capability.
    --debug-solver          Create solver test case for debugging.
-R, --no-force-resolution   Do not force the solver to find solution,
                            let it ask.
    --force-resolution      Force the solver to find a solution (even
                            an aggressive one).
-u, --clean-deps            Automatically remove unneeded dependencies.
-U, --no-clean-deps         No automatic removal of unneeded dependencies.
-D, --dry-run               Test the removal, do not actually remove.

We can remove, for example nodejs, and all its dependencies (that are not dependencies for any other package) this way:

sudo zypper remove --clean-deps nodejs

I hope by now you are as convinced as I am that zypper is not only functional but (gasp!) beautiful as well.

Transform GNOME Shell to behave like Unity

You can make GNOME Shell 3.10 look and behave sort of like Unity (Ubuntu 14.04). It’s not difficult but requires you to gather things from a lot of places. This in turn means you have yo trust a lot of individuals or teams to have done their part well for the whole to function well.

Here’s a checklist of modifications you may need to make and how to do them in openSUSE 13.1.

GNOME Shell Extensions

You’ll want to install these GNOME Shell extensions.

AppKeys – Use Super+number to activate applications.

Alt Tab Workspace – Configure Alt+Tab to work only on the windows in the current desktop.

Dash to Dock – Show the dock you see in the overview screen (when you hit the Super key) on your desktop.

Font

To get fonts working better than they do out of the box in openSUSE you need to install Infinality. You’ll need to log out and log back in for it to start working for you.

You may also want to install the Ubuntu Fonts. I prefer it over other Monospace fonts, although DejaVu Sans Mono is a close second for me.

Terminal

You need to do two things: (1) use Ubuntu Mono font at size 13; (2) use #3D0029 as your background color (it’s dark aubergine).

I use this for my PS1.

PS1='\n\n\u @ \[33[01;32m\]\h\[33[00m\] \[33[01;34m\][\w]\[33[00m\] $ '

Tweak Tool

You should install Tweak Tool. It’ll help you to configure many things in GNOME Shell that you otherwise won’t be able to. I have used it to configure the system-wide fonts thusly.

  • Window Titles – Ubuntu Medium 11
  • Interface – Ubuntu Light 11
  • Documents – Ubuntu Light 11
  • Monospace – Ubuntu Mono 11
  • Hinting – None
  • Antialiasing – Grayscale
  • Scaling Factor – 1.0

Thanks, too, to these resources: Dark Aubergine, Comment on reddit by zman0900, How to quickly configure superb subpixel hinted smooth fonts for openSUSE 12.3.

Install Atom Editor in openSUSE

You’re better served if you read the official documentation: Linux build instructions. Then you should proceed with this post to get an idea of my experience installing Atom in openSUSE 13.1.

Install Prerequisites

Build stuff: sudo zypper install make gcc gcc-c++ glibc-devel libgnome-keyring-devel

node.js from Tumbleweed (to keep up with updates):

sudo zypper addrepo http://download.opensuse.org/repositories/devel:languages:nodejs/openSUSE_Tumbleweed/devel:languages:nodejs.repo

sudo zypper refresh

sudo zypper install nodejs

Configure npm to use Python 2: sudo npm config set python /usr/bin/python2 -g

Install git: sudo zypper install git

Get Source, Build, Install

mkdir ~/src && cd ~/src

Get the source: git clone https://github.com/atom/atom

cd ~/src/atom

For some reason you need to re-configure npm to use Python 2. Don’t ask why; it just worked for me and failed if I didn’t: sudo npm config set python /usr/bin/python2 -g

Build: script/build

Install: sudo script/grunt install

Create an atom.desktop file with the following contents: vim ~/.local/share/applications/atom.desktop

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Atom
Comment=Atom editor by GitHub
Exec=/usr/local/bin/atom
Icon=/home/cg/.atom/atom.png
Terminal=false

Copy the icon image file to be used in the atom.desktop file: cp ~/src/atom/resources/atom.png ~/.atom

Now you are ready to start using Atom.

Install Sublime Text in openSUSE

I’ve been trying out the Sublime Text 3 Beta on openSUSE and Mac OS X and I like it so far. There are a few bugs, as expected, but it’s a great editor.

Head over to Sublime Text 3 Beta and download the 64-bit tarball (or 32-bit if that’s your environment).

Untar the file: tar xvjf sublime_text_3_*.tar.bz2

Since I’m the only user on the machine and a local install was fine for me I didn’t install it to /opt. Instead, I installed it to ~/bin. This meant I had to customize the install steps a little bit.

mv sublime_text_3/ ~/bin/

You also want to be able to run Sublime using your desktop environment’s menus and such. Copy the .desktop file to your local directory, changing paths as needed.

sed -e 's!Exec=/opt/sublime_text/sublime_text!Exec=$HOME/bin/sublime_text_3/sublime_text!g' -e 's!Icon=sublime-text!Icon=$HOME/bin/sublime_text_3/Icon/256x256/sublime-text.png!g' sublime_text.desktop > ~/.local/share/applications/sublime_text.desktop

I tried this successfully with Sublime Text 3 build 3059 on openSUSE 13.1.

Run Wireshark in openSUSE as non-root user

There are two aspects of using Wireshark in openSUSE: capturing packets and displaying packets. To display packets or view pcap files you don’t need to run Wireshark as root. You also don’t need to do anything extra other than installing it. However, to capture packets you need root privileges. If you don’t have root privileges or want to capture packets as your regular user then you need a few extra steps.

Install Wireshark: sudo zypper install wireshark

Run Wireshark as non-root user to view captures

There is one caveat to running Wireshark in openSUSE as non-root user: when you run Wireshark from the GUI (say GNOME Shell) you are prompted to enter the root password. There’s a simple workaround to this by creating a local wireshark.desktop file, copied from /usr/share/applications/wireshark.desktop, with a slight modification.

cat /usr/share/applications/wireshark.desktop | sed -e 's!Exec=/usr/bin/xdg-su -c /usr/bin/wireshark %f!Exec=/usr/bin/wireshark %f!g' > /home/cguser/.local/share/applications/wireshark.desktop

In the command above we are creating a copy of /usr/share/applications/wireshark.desktop and saving it to /home/cguser/.local/share/applications/wireshark.desktop. The one change we make is to execute Wireshark as a regular user and not as root. You’ll have to do this for all non-root users who need to run Wireshark.

Now when you start Wireshark as a regular (non-root) user you’ll be able to display packets without providing root credentials.

Run Wireshark as non-root user to capture packets

This portion was taken from Sniffing with Wireshark as a Non-Root User. Read that page first before proceeding.

Install setcap to set the capabilities of /usr/bin/dumpcap: sudo zypper install libcap-progs

Create a new group wireshark to restrict users who can use Wireshark to capture packets: sudo groupadd wireshark

Add your user to the wireshark group to be able to capture packets: sudo usermod -a -G wireshark cguser

Change the group of dumpcap to wireshark: sudo chgrp wireshark /usr/bin/dumpcap

Change the permissions of dumpcap to only allow users in wireshark group to be able to run it: sudo chmod o-rwx /usr/bin/dumpcap

Set the capabilities required by dumpcap to run since its group is no longer root: sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap

View the capabilities of dumpcap to confirm they were set correctly: getcap /usr/bin/dumpcap

/usr/bin/dumpcap = cap_net_admin,cap_net_raw+eip

Logout and login again to finalize the addition of your user to the wireshark group.

Now when you start Wireshark as a regular (non-root) user you’ll be able to capture packets without providing root credentials.

Note: This was tested working in openSUSE 13.1.

zypper: The following package updates will not be installed

I was trying to update my openSUSE 13.1 install and got this:

sudo zypper update

Loading repository data...
Reading installed packages...

The following 8 package updates will NOT be installed:
  libeXosip2-6 libgsm1 libortp9 libosip2 libspandsp2 libspeex1 libspeexdsp1 linphone 

Nothing to do.

I had linphone installed already but why would it not update? So I tried a distribution update (bad idea if you’re not actually upgrading your distribution to a newer release!):

sudo zypper dup

Warning: You are about to do a distribution upgrade with all enabled repositories. Make sure these repositories are compatible before you continue. See 'man zypper' for more information about this command.
Loading repository data...
Reading installed packages...
Computing distribution upgrade...

The following 42 NEW packages are going to be installed:
  bash-doc dconf desktop-translations exim gsettings-backend-dconf libdconf1 libproxy1-config-gnome3 libtidyp-1_04-0 openssh-askpass perl-Data-Dump perl-Encode-Locale perl-File-Listing perl-HTML-Parser 
  perl-HTML-Tagset perl-HTML-Tidy perl-HTTP-Cookies perl-HTTP-Daemon perl-HTTP-Date perl-HTTP-Message perl-HTTP-Negotiate perl-IO-HTML perl-IO-Socket-SSL perl-LWP-MediaTypes perl-LWP-Protocol-https 
  perl-Net-DBus perl-Net-HTTP perl-Net-LibIDN perl-Net-SSLeay perl-Text-Wrapper perl-Tie-IxHash perl-TimeDate perl-URI perl-WWW-RobotRules perl-X11-Protocol perl-XML-Twig perl-XML-XPathEngine 
  perl-libwww-perl readline-doc ucode-intel vim-data xdg-utils zypper-log 

The following 8 packages are going to be upgraded:
  libeXosip2-6 libgsm1 libortp9 libosip2 libspandsp2 libspeex1 libspeexdsp1 linphone 

The following 8 packages are going to change vendor:
  libeXosip2-6  openSUSE -> obs://build.opensuse.org/network:telephony
  libgsm1       openSUSE -> obs://build.opensuse.org/network:telephony
  libortp9      openSUSE -> obs://build.opensuse.org/network:telephony
  libosip2      openSUSE -> obs://build.opensuse.org/network:telephony
  libspandsp2   openSUSE -> obs://build.opensuse.org/network:telephony
  libspeex1     openSUSE -> obs://build.opensuse.org/network:telephony
  libspeexdsp1  openSUSE -> obs://build.opensuse.org/network:telephony
  linphone      openSUSE -> obs://build.opensuse.org/network:telephony


8 packages to upgrade, 42 new, 8  to change vendor.
Overall download size: 18.5 MiB. After the operation, additional 62.2 MiB will be used.
Continue? [y/n/? shows all options] (y): 

I did not proceed with a dist-upgrade. As you can see, the vendor was being changed from openSUSE to an OBS repository.

That’s when I realized(*) that not only was linphone provided by the openSUSE repos but also this OBS repo I was using for SIPp. So what’s the solution? I need this OBS repo but I don’t want to keep seeing this message (for semi-OCD reasons). I haven’t found a solution yet but at least I can rest easy knowing why I was seeing this message.

(*) OK, I found a pointer to the actual cause. Hat tip to Zypper: The following package updates will NOT be installed