From 8d32dd487c602ab29e4e9d2f38c6ec34afa39397 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 2 Apr 2012 23:28:20 +0100 Subject: Remove obsolete stuff --- scripts/asd | 58 --------------------- scripts/list-nonauto-packages | 30 ----------- scripts/listen-check | 37 -------------- scripts/liw-vm-create | 19 ------- scripts/sd-all | 18 ------- scripts/sd-publish-all | 12 ----- scripts/ssh-add-from-usbkey | 5 -- scripts/sync-repos | 2 - scripts/unreleased-projects | 98 ----------------------------------- sync-music-to-n900 | 116 ------------------------------------------ 10 files changed, 395 deletions(-) delete mode 100755 scripts/asd delete mode 100755 scripts/list-nonauto-packages delete mode 100755 scripts/listen-check delete mode 100755 scripts/liw-vm-create delete mode 100755 scripts/sd-all delete mode 100755 scripts/sd-publish-all delete mode 100755 scripts/ssh-add-from-usbkey delete mode 100755 scripts/unreleased-projects delete mode 100755 sync-music-to-n900 diff --git a/scripts/asd b/scripts/asd deleted file mode 100755 index b9c01d2..0000000 --- a/scripts/asd +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# asd -- wrapper around sd -# Copyright 2010, 2011 Lars Wirzenius -# -# 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, either version 3 of the License, or -# (at your option) any later version. -# -# 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 - - -die() -{ - echo "$@" 1>&2 - exit 1 -} - - -find_root() -{ - if bzr root > /dev/null 2>&1 - then - bzr root - elif git rev-parse --show-toplevel > /dev/null 2>&1 - then - git rev-parse --show-toplevel - else - die "Cannot find version control system root! Not bzr or git." - fi -} - - -if [ "x$SD_REPO" = "x" ] -then - root=$(find_root) - if [ -d "$root/../bugs" ] - then - export SD_REPO="$root/../bugs" - fi - - if [ "x$SD_REPO" = "x" ] - then - die "Cannot find bug database for SD." - fi -fi - - -sd "$@" diff --git a/scripts/list-nonauto-packages b/scripts/list-nonauto-packages deleted file mode 100755 index 522f05c..0000000 --- a/scripts/list-nonauto-packages +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -# Copyright 2011 Lars Wirzenius -# -# 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, either version 3 of the License, or -# (at your option) any later version. -# -# 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 - -comm -23 \ - <(dpkg --get-selections | awk '$2 == "install" { print $1 }' | sort) \ - <(apt-mark showauto | sort) | -while read pkg -do - pri="$(dpkg --status $pkg | awk '/^Priority:/ { print $2 }')" - case "$pri" in - optional|extra) echo "$pkg" ;; - esac -done - diff --git a/scripts/listen-check b/scripts/listen-check deleted file mode 100755 index 45fe716..0000000 --- a/scripts/listen-check +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# -# Check that the host only listens on ports that are acceptable. - -set -e - -ports() -{ - netstat -nlap | - awk ' - $6 == "LISTEN" { - n = split($7, a, /\//) - printf "%-10s %-20s %-20s %s\n", $1, $4, $5, a[2] - }' -} - - -case "$1" in - list) - ports - ;; - report) - temp="$(mktemp)" - ports > "$temp" - if diff -u /etc/listen-check.ok "$temp" - then - rm -f "$temp" - else - rm -f "$temp" - exit 1 - fi - ;; - *) - echo "EEeek. Usage, man!" 1>&2 - exit 1 - ;; -esac diff --git a/scripts/liw-vm-create b/scripts/liw-vm-create deleted file mode 100755 index c5c86af..0000000 --- a/scripts/liw-vm-create +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -e - -if [ $# != 3 ] -then - echo "Usage: $0 vm-name size-in-gigabytes path-to-install-iso" 1>&2 - exit 1 -fi - -name="$1" -size="$2" -iso="$3" -ram=512 # This is hardcoded to be good for install. Fix afterwards. - -sudo -p "Password (to run virt-install): " \ - virt-install -n "$name" -r "$ram" \ - --disk path="/srv/vm/$name.img",size="$size",bus=virtio \ - --cdrom "$iso" --vnc --noautoconsole diff --git a/scripts/sd-all b/scripts/sd-all deleted file mode 100755 index 36c4514..0000000 --- a/scripts/sd-all +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e - -cd $HOME - -awk ' - NF == 0 { next } - $1 ~ /#/ { next } - { print $1 } -' "$HOME/.sd-publish-all.conf" | -while read repo -do - export SD_REPO="$repo" - echo "SD repo: $repo" - sd "$@" || exit 1 - echo -done diff --git a/scripts/sd-publish-all b/scripts/sd-publish-all deleted file mode 100755 index 5fd0f22..0000000 --- a/scripts/sd-publish-all +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -cd $HOME -while read dirname remote -do - echo "$dirname" - SD_REPO="$dirname" sd publish --html --to "$remote" - echo -done < $HOME/.sd-publish-all.conf - diff --git a/scripts/ssh-add-from-usbkey b/scripts/ssh-add-from-usbkey deleted file mode 100755 index 913ca9f..0000000 --- a/scripts/ssh-add-from-usbkey +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -e - -ssh-add /media/Mr.?Brown/ssh/id_rsa -#devkit-disks --unmount /dev/disk/by-uuid/3f59e969-03d6-47d9-8498-a59977166332 -#gnome-mount --unmount -d /dev/disk/by-uuid/3f59e969-03d6-47d9-8498-a59977166332 diff --git a/scripts/sync-repos b/scripts/sync-repos index 4250441..a3e8184 100755 --- a/scripts/sync-repos +++ b/scripts/sync-repos @@ -2,5 +2,3 @@ cd $HOME mr -q update && mr -q push -sd-publish-all - diff --git a/scripts/unreleased-projects b/scripts/unreleased-projects deleted file mode 100755 index 7639780..0000000 --- a/scripts/unreleased-projects +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -# Copyright 2011 Lars Wirzenius -# -# 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, either version 3 of the License, or -# (at your option) any later version. -# -# 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 . - - -import cliapp -import logging -import os -import re - - -class UnreleasedProjects(cliapp.Application): - - conf_file = os.path.expanduser('~/.sd-publish-all.conf') - - def add_settings(self): - self.settings.boolean(['verbose'], 'be verbose') - - def process_args(self, args): - for project_dir in self.project_dirs(): - logging.debug('examining project dir %s' % project_dir) - project_name = os.path.basename(os.path.dirname(project_dir)) - logging.debug('project name is %s' % project_name) - if self.is_released(project_name, project_dir): - if self.settings['verbose']: - self.output.write('released: %s\n' % project_dir) - else: - self.output.write('UNRELEASED: %s\n' % project_dir) - - def is_released(self, project_name, project_dir): - logging.debug('is_released: project_name=%s project_dir=%s' % - (project_name, project_dir)) - - revno = self.bzr_revno(project_dir) - logging.debug('revno = %s' % repr(revno)) - if revno is None: - logging.debug('no revno, so not released') - return False - - tags = self.bzr_tags(project_dir) - logging.debug('found tags: %s' % repr(tags)) - - pat = r'^%s-\d+(\.\d+)*(_debian-[0-9.-]+)?$' % project_name - logging.debug('tag pattern = %s' % repr(pat)) - - for tag_revno, tag in tags: - logging.debug('tag_revno=%s' % repr(tag_revno)) - logging.debug('tag=%s' % repr(tag)) - if re.match(pat, tag): - release_tag_is_current = tag_revno == [revno] - logging.debug('return: %s' % release_tag_is_current) - return release_tag_is_current - logging.debug('returning default result of False') - return False - - def bzr_revno(self, project_dir): - return int(self.runcmd(['bzr', 'revno'], cwd=project_dir).strip()) - - def bzr_tags(self, project_dir): - out = self.runcmd(['bzr', 'tags'], cwd=project_dir) - pairs = [line.split() for line in out.splitlines()] - pairs2 = [(self.revno_key(revno), tag) for tag, revno in pairs] - return list(reversed(sorted(pairs2))) - - def revno_key(self, revno_string): - return [int(x) for x in revno_string.split('.')] - - def project_dirs(self): - homedir = os.path.expanduser('~') - return [os.path.join(homedir, os.path.dirname(x), 'trunk') - for x in self.bug_dirs()] - - def bug_dirs(self): - return [line.split()[0] - for line in self.cat(self.conf_file).splitlines() - if line.strip()] - - def cat(self, filename): - with open(filename) as f: - return f.read() - - - - -if __name__ == '__main__': - UnreleasedProjects().run() diff --git a/sync-music-to-n900 b/sync-music-to-n900 deleted file mode 100755 index 9ca85bb..0000000 --- a/sync-music-to-n900 +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/python -# Copyright 2010 Lars Wirzenius -# -# 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, either version 3 of the License, or -# (at your option) any later version. -# -# 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 . - - -import os -import re -import shutil -import sys -import ttystatus - - -def parse_playlist(filename): - pat = re.compile(r'^File\d+=(?P.*)$') - f = open(filename) - for line in f: - m = pat.match(line) - if m: - yield m.group('filename') - f.close() - - -class Playlist(object): - - def __init__(self, filename): - self.media_filenames = list(parse_playlist(filename)) - prefix = os.path.commonprefix(self.media_filenames) - i = prefix.rfind('/') - if i >= 0: - self.dirname = prefix[:i] - self.media_filenames = [x[i+1:] for x in self.media_filenames] - else: - self.dirname = '.' - self.dirname = os.path.join(os.path.dirname(filename), self.dirname) - - -def identical(source, target): - source_st = os.lstat(source) - - try: - target_st = os.lstat(target) - except OSError: - return False - - return source_st.st_size == target_st.st_size - - -def cleanup(pathname): - badchars = ':?*[]' - for c in badchars: - pathname = '_'.join(pathname.split(c)) - return pathname - - -def main(): - ts = ttystatus.TerminalStatus() - - target_dir = '/media/Nokia N900/music' - - playlists = [] - ts['done'] = 0 - ts['total'] = 0 - for filename in sys.argv[1:]: - playlist = Playlist(filename) - playlists.append(playlist) - for x in playlist.media_filenames: - xx = os.path.join(playlist.dirname, x) - ts['total'] += os.path.getsize(xx) - - ts.add(ttystatus.ElapsedTime()) - ts.add(ttystatus.Literal(' ')) - ts.add(ttystatus.RemainingTime('done', 'total')) - ts.add(ttystatus.Literal(' ')) - ts.add(ttystatus.ByteSize('done')) - ts.add(ttystatus.Literal('/')) - ts.add(ttystatus.ByteSize('total')) - ts.add(ttystatus.Literal(' ')) - ts.add(ttystatus.ProgressBar('done', 'total')) - - for playlist in playlists: - for relative_name in playlist.media_filenames: - source = os.path.join(playlist.dirname, relative_name) - target = os.path.join(target_dir, cleanup(relative_name)) - if not identical(source, target): - x = os.path.dirname(target) - if not os.path.exists(x): - os.makedirs(x) - source_f = open(source) - target_f = file(target, 'wb') - while True: - data = source_f.read(4096) - if not data: - break - target_f.write(data) - ts['done'] += len(data) - source_f.close() - target_f.close() - else: - ts['done'] += os.path.getsize(source) - - ts.finish() - -if __name__ == '__main__': - main() -- cgit v1.2.1