Skip to content

Instantly share code, notes, and snippets.

@hackerb9
Created December 10, 2017 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackerb9/020484442f5d4335225a39099965b7e4 to your computer and use it in GitHub Desktop.
Save hackerb9/020484442f5d4335225a39099965b7e4 to your computer and use it in GitHub Desktop.
Find unofficial packages installed on a Raspberry Pi running Raspbian
#!/bin/sh
# nonraspbian -
#
# Find packages installed on my Pi which aren't from the official
# Raspberry Pi repositories.
aptitude search '?narrow(?installed,!?or(?origin("Raspberry Pi Foundation"),?origin("Raspbian")))'
# NOTES
# This one-liner was handy on a Raspberry Pi Zero W (which has an ARM 6
# processor) when I used the SD card from my Pi 3B (which is ARM 7)
# and many programs were segfaulting or printing "Illegal instruction".
# It turned out the problem was that I had installed some newer
# packages directly from Debian and Debian Backports, but Debian
# presumes an ARM 7 at minimum.
# I needed to downgrade all the ARM 7 packages with their ARM 6
# equivalents. But how could I find out which ones those were?
# Turns out, the oft overlooked aptitude program can do that fairly
# easily. Just find all the packages that aren't from the official
# repositories.
####
# SOME IDEAS THAT WOULDN'T HAVE WORKED:
# * Searching by architecture
#
# Since both Debian and the Raspberry Pi foundation label their
# architecture the same, one can't simply search on ?architecture(armhf).
# (I think the RPi foundation should have used "arm6hf".)
# * Using file(1) to check the ABI version using magic numbers.
#
# Both ARM7 (gphoto2) and ARM6 (gpg) return the same thing:
#
# $ file /usr/bin/gphoto2
# /usr/bin/gphoto2:
# ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV),
# dynamically linked, interpreter /lib/ld-linux-armhf.so.3,
# for GNU/Linux 2.6.32,
# BuildID[sha1]=870c02a0c42d47af0a3917ee1f79f4187dcddc66,
# stripped
#
# $ file /usr/bin/gpg
# /usr/bin/gpg: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV),
# dynamically linked, interpreter /lib/ld-linux-armhf.so.3,
# for GNU/Linux 2.6.32,
# BuildID[sha1]=09978c06faef2b023ac5cc94acb04cb03cdb2f3f,
# stripped
# * Likewise, using file(1) on shared libraries (found using ldd(1)) fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment