#!/bin/sh # # manifest - import/export a list of packages # Copyright (C) 2016 Dustin Kirkland # # Authors: Dustin Kirkland # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -e if ! command -v pastebinit >/dev/null 2>&1; then echo "ERROR: pastebinit not found. Hint:" 1>&2 echo " sudo apt install pastebinit" 1>&2 exit 1 fi export_packages() { if [ "$OBJECT" = "-" ]; then dpkg -l elif echo "$OBJECT" | grep -qs ".*://.*"; then dpkg -l | gzip -9 | base64 | pastebinit -b "${OBJECT##*/}" else dpkg -l > "$OBJECT" fi } import_packages() { if [ "$OBJECT" = "-" ]; then sudo apt install $(cat /dev/stdin | grep "^ii\s" | col2) elif echo "$OBJECT" | grep -qs ".*://.*"; then sudo apt install $(wget -q -O- "$OBJECT" | grep -A 999999999 '
' | grep -B 999999999 "^
" | sed -e "s/.*
//" -e "s/^<\/pre>.*//" | base64 -d | gunzip | grep "^ii\s" | col2)
	else
		sudo apt install $(cat "$OBJECT" | grep "^ii\s" | col2)
	fi
}

usage() {
	cat <