Tuesday, November 2, 2010

Lingo: Destructive Buy-in

Lingo: Destructive Buy-in

Definition: Enough buy-in from employees and/or management to approve an idea or project, but not enough buy-in to execute it successfully.

Origin: Corporate lore from a now-defunct biotech firm in MA, USA. First seen in an early Scott Adams interview in the form "destructive agreement".

Wednesday, July 14, 2010

How do I find which package contains a certain file?

What to do if you need to install or build a package on Linux and it wants a missing file/library/etc...

Have you ever tried to install package or some vendor software, only to find that the install fails due to a missing library? Here is a collection of methods for finding the package that contains the missing file.

Red Hat Enterprise Linux/CentOS

Using yum

yum whatprovides /full/path/to/missing/filename
Note: In all of these processes, fill in the actual filename and path for which you are looking.

Using rpmfind site

  1. Browse to http://rpm.pbone.net/index.php3/stat/2/simple/2
  2. Enter filename or /full/path/to/missing/filename in the search box (start with just the filename)
  3. Check boxes of rpm-based distributions in which you want to search
  4. Click search

Debian/Ubuntu

apt-file

sudo aptitude install apt-file
sudo apt-file update
apt-file search filename
or
apt-file search /full/path/to/missing/filename

Using Debian's website

  1. Browse to http://www.debian.org/distrib/packages
  2. Scroll to the bottom to the section called "Search the contents of packages"
  3. Enter a single argument into the search field, either filename or /full/path/to/missing/filename
  4. Select your distribution
  5. Select the machine architecture for which you need the missing file
  6. Click "Search"

Friday, June 18, 2010

How to build a basic Firefox package for Debian Lenny or Ubuntu 64-bit.

Do you run Debian 5 or 8.04+ Ubuntu on a 64-bit chip? Do you want a new Firefox as a 64-bit application? Here are some build instructions to create a basic package (no menu integration, etc.) from the Firefox source. If you want to add Flash, put the 64-bit beta plugin files into your home directory, e.g. ~/.mozilla, or the file tree specified by the option:
ac_add_options --with-default-mozilla-five-home=


Download source

Firefox source
I will use 3.5.9.

Unpack

Change to your workspace directory.
mkdir src
cd src
tar jxvf ../firefox-3.5.9.source.tar.bz2
cd ..

Prepare for building

sudo aptitude install build-essential libidl-dev autoconf2.13 xorg-dev gcc g++ libgtk2.0-dev libnotify-dev libnotify-dev-gtk2.10 libnotifymm-dev libiw-dev libcurl4-gnutls-dev

Prepare ~/.mozconfig

Put the following in ~/.mozconfig. Edit as needed. This file contains the build and configuration options used by Mozilla's Firefox build process. As documented here, this process will create a package that installs the new Firefox into /usr/local/apps/firefox-3.5.9-1. NOTE: update the version string in the prefix and default-mozilla-five-home to reflect the version you are building.
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@
ac_add_options --enable-application=browser
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_MAKE_FLAGS="-j4"
ac_add_options --disable-tests
ac_add_options --prefix=/usr/local/apps/firefox-3.5.9-1
ac_add_options --enable-optimize
ac_add_options --enable-official-branding
ac_add_options --enable-canvas
ac_add_options --enable-strip
ac_add_options --enable-xinerama
ac_add_options --with-default-mozilla-five-home=/usr/local/tmp/firefox-3.5.9-1/lib/firefox-3.5

Build it

mkdir -p package/firefox3.5_3.5.9-1_amd64
Note the package name, firefox3.5. This will keep it from stepping on system packages.
cd src
make -f client.mk clean && make -f client.mk build && make -f client.mk DESTDIR="`pwd`/../package/firefox3.5_3.5.9-1_amd64/" install
It takes ~15 minutes to build from scratch on an quad core Intel machine with 6GB of RAM.

Make the package

cd ../package/firefox3.5_3.5.9-1_amd64/
mkdir DEBIAN
cd DEBIAN
Create a file called "control" with the following contents. Edit the package name and version as needed. Use your own credentials for the maintainer field.
Package: firefox3.5
Version: 3.5.9-1
Architecture: amd64
Maintainer: First Last <name@somedomain>
Installed-Size: 90372
Depends: fontconfig, psmisc, procps, debianutils (>= 1.16), libc6 (>= 2.7-1), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.12.0), libnspr4-0d (>= 1.8.0.10), libstdc++6 (>= 4.1.1), xulrunner-1.9 (>= 1.9.0.3-1)
Suggests: xulrunner-1.9-gnome-support, latex-xft-fonts, xfonts-mathml, ttf-mathematica4.1, xprint, mozplugger, libkrb53
Conflicts:
Replaces:
Provides:
Section: web
Priority: optional
Description: lightweight web browser based on Mozilla
* Get size
cd ..
du -sk usr
cd DEBIAN
* Edit "control" file to fill the output of the above du command into the Installed-Size: field.
* Create the "md5sums" file
cd ..
DIRS=`/bin/ls -1 | grep -v DEBIAN` && find $DIRS -type f -exec md5sum {} \; > ./DEBIAN/md5sums
cd DEBIAN
* Create "postinst" file with following content
#!/bin/sh

if [ ! -d /usr/local/tmp ]
then
  mkdir -p /usr/local/tmp
fi

echo "################################################"
echo ""
echo "Run: /usr/local/apps/firefox-3.5.9-1/bin/firefox"
echo ""
echo "################################################"
Make the script executable
chmod a+xr postinst
Create the package file
cd ../..
dpkg -ba firefox3.5_3.5.9-1_amd64

Install firefox

sudo dpkg -i firefox3.5_3.5.9-1_amd64.deb

Make a Launcher icon

Gnome:

  1. Right click on "Applications" menu
  2. Choose "Edit Menu"
  3. Click on "Internet"
  4. Click on "New Item"
  5. Name: Firefox3.5
  6. Command: /usr/local/apps/firefox-3.5.9-1/bin/firefox
  7. Comment: Firefox Browser, version 3.5.9
  8. Click on OK
  9. Click OK

KDE:

  1. Right click on desktop and choose "Create New"
  2. Choose "Link to Application..."
  3. Name the link "Firefox3.5"
  4. Click the Application tab
  5. Click the icon
  6. Chose a good web browser icon
  7. Description: Firefox Browser, version 3.5.9
  8. Command: /usr/local/apps/firefox-3.5.9-1/bin/firefox
  9. Click OK
  10. Open a terminal window
  11. Run: sudo cp ~/Desktop/Firefox3.5.desktop /usr/share/applications/

References

[1] http://markshroyer.com/blog/2009/07/firefox-35-debian-amd64.html

Friday, May 21, 2010

Methods to Generate a Random digit from 0 to 9 in bash

echo "${RANDOM}" | cut -c 3 | grep .

Note that sometimes you will get nothing...

A more sophisticated way to do this is to use modular arithmatic:

digit="${RANDOM}" && let "digit %= 10" && echo $digit

This will always return a value. Note that the first version is essentially 100-999 mod 100.

Thursday, May 20, 2010

Rough Sed and Awk Code to Convert a CSV file to a sortable Mediawiki table

echo -e "3,4,5,5\n4,5,6,8" | sed "s/$/\n-/" | sed -e "s/,/\n/g" | sed -e "s/^/|/" | awk 'BEGIN {
    print "{|class=\"wikitable sortable\" style=\"vertical-align:top; background:lightblue;\"\n!key value!!col 1!!col 2!!col 3\n|-"
    }
    {
    print
    }
    END {
    print "|}"
    }
  '


Tuesday, April 20, 2010

Local-link Address (LLA, 169.254.0.0/16) networking on Debian/Ubuntu Linux How To

Instructions for connecting external IP devices to the second NIC on a Debian/Ubuntu box using Local-link Address networking (169.254.0.0/16)

e.g. connecting a Axis 206M camera.

Install on the Debian/Ubuntu PC:

  • dhcp3-server
  • avahi-autoipd
To configure dhcpd, add the following lines to /etc/dhcp3/dhcpd.conf:

subnet 169.254.0.0 netmask 255.255.0.0 {
  range 169.254.8.2 169.254.8.20;
}
Add a route to 255.255.255.255 to the second NIC in order to send UDP broadcast traffic to it. This is accomplished by the last two lines below in /etc/network/interfaces:

% cat /etc/network/interfaces
auto lo eth0 eth1
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0
iface eth0 inet dhcp
iface eth1 inet dhcp
post-up route add -net 255.255.255.255 netmask 255.255.255.255  metric 99 dev eth1
post-down route del -net 255.255.255.255 netmask 255.255.255.255  metric 99 dev eth1 

Sunday, April 11, 2010

Error Building ffmpeg: 32-bit absolute addressing is not supported for x86-64

A quick note...


If you are getting the following error on Mac OS X 10.6 with XCode 3.2.1, while compiling ffmpeg with software scaling (libswscale):

32-bit absolute addressing is not supported for x86-64
then you need to pass
--arch=x86_64 
to "configure"

Cheers,

-Adam

Tuesday, March 9, 2010

Idea: Relatively Reliable Ram Drive Server

Idea:Relatively Reliable Ram Disk Server (specs updated 2012-Q2)


Two commodity servers

Parts (for each)
  • MB with 8 or 16 DIMM slots
  • Two 10G ethernet cards for storage
  • SATA RAID
  • Four smallish enterprise drives:
    • Two drives in a mirrored pair for OS
    • Two drives for backing store
  • 32GB DIMMs of ECC Registered RAM
Parts for file server node
  • Bonded pair of 1G or 10G cards
    Building
    • Make a large RAM disk on each (leave 2GB for OS)
    • On one machine:
      • Share the RAM disk with the other machine via one crossover network (one of the 10G cards on each machine) via iSCSI
      • Share pair of backing drives via iSCSI
    • On other machine (file server)
      • Using md, on each, mirror the iSCSI RAM disk to the local RAM disk.
      • Make a filesystem on mirrored RAM disk
      • Share RAM filesystem via NFS and SAMBA.
      • Combine iSCSI drives and local drives into RAID 0+1 backing store. 
      • Make journaled filesytem on backing store disk.
      • Mount backing store
    • Put each server on a sizable independent UPS with a serial/USB monitor to smooth out uptime (5h-10h)
    • Configure serial trigger from UPS such that if the AC cuts on either of them the file server will stop sharing and then run an rsnapshot backup to the backing store.
    • Run rsnapshot to flush the RAM filesystems every 30 minutes.
    • Configure RAM disk startup and shutdown
      • On shutdown have file server to rsnapshot RAM disk to backing store before coming down.
      • On start up check uptime on other server to see if it went down as well.
        • If so, have file server rsnapshot to RAM disk before starting file sharing services.
        • If not, have file server recover RAM disk from mirror.
    Note: If you have the file server on a 10G network with three 10G cards, you could share the RAM disk itself as an iSCSI target and use dd to back it off to the backing store.


    • You can use these RAM LUNs in combination with flachcache or bcache to speed up access to existing physical LUNs.  Not necessarily safe ;-), but if you need cheap speed, these will work.