From 453ebd84a6d80bdbfd34e0427b68b8e89a43500d Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 13 Dec 2007 11:36:06 +0100 Subject: [PATCH 1/1] Initial checkin --- Makefile | 23 +++++++++++++++++ debian/changelog | 6 +++++ debian/compat | 1 + debian/control | 16 ++++++++++++ debian/copyright | 30 +++++++++++++++++++++++ debian/rules | 58 +++++++++++++++++++++++++++++++++++++++++++ grml-paste | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ grml-paste.1.txt | 42 +++++++++++++++++++++++++++++++ 8 files changed, 251 insertions(+) create mode 100644 Makefile create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100755 grml-paste create mode 100644 grml-paste.1.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..33e6fe9 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +%.html : %.txt ; + asciidoc -b xhtml11 $^ + +%.gz : %.txt ; + asciidoc -d manpage -b docbook $^ + #sed -i 's///g' `echo $^ |sed -e 's/.txt/.xml/'` + xsltproc -nonet /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl `echo $^ |sed -e 's/.txt/.xml/'` &>/dev/null + # ugly hack to avoid '.sp' at the end of a sentence or paragraph: + sed -i 's/\.sp//' `echo $^ |sed -e 's/.txt//'` + gzip -f --best `echo $^ |sed -e 's/.txt//'` + +MANPAGES = grml-paste.1 + +all: doc + +doc: doc_man doc_html +doc_html: $(addsuffix .html, $(MANPAGES)) +doc_man: $(addsuffix .gz, $(MANPAGES)) + +clean: + @for i in $(MANPAGES); do \ + rm -f $$i.html $$i.xml $$i.gz; done + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..2ade598 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +grml-paste (0.1) unstable; urgency=low + + * Initial release. + + -- Michael Prokop Thu, 13 Dec 2007 11:17:35 +0100 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..48488d3 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: grml-paste +Section: utils +Priority: extra +Maintainer: Michael Prokop +Build-Depends: debhelper (>= 5) +Standards-Version: 3.7.2 +Homepage: http://hg.grml.org/grml-paste/ +XS-Vcs-hg: http://hg.grml.org/grml-paste/ +XS-Vcs-Browser: http://hg.grml.org/grml-paste/ + +Package: grml-paste +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, ruby +Description: command line interface for paste.grml.org + grml-paste is a command line interface for uploading + plain text to http://paste.grml.org/ diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..641fc01 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,30 @@ +This package was debianized by Michael Prokop on +Thu, 13 Dec 2007 11:17:35 +0100. + +It was downloaded from http://grml.org/ + +Upstream Author: Nico Golde + +Copyright: grml-team (grml.org), (c) 2007 Nico Golde + +License: + + This package 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 2 of the License, or + (at your option) any later version. + + This package 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 package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2007, Michael Prokop and +is licensed under the GPL, see above. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..1344198 --- /dev/null +++ b/debian/rules @@ -0,0 +1,58 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp + +build-stamp: + dh_testdir + $(MAKE) + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + -$(MAKE) clean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs usr/bin + + install -m 755 grml-paste debian/grml-paste/usr/bin/grml-paste + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_installman grml-paste.1.gz + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/grml-paste b/grml-paste new file mode 100755 index 0000000..d4b7fb6 --- /dev/null +++ b/grml-paste @@ -0,0 +1,75 @@ +#!/usr/bin/env ruby +# Filename: grml-paste +# Purpose: paste files to the online grml paste bot +# Authors: grml-team (grml.org), (c) 2007 Nico Golde +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2 +########################################################################## + +require 'uri' +require 'net/http' + +url = URI.parse('http://paste.grml.org/paste') + +def usage + $stderr.puts "usage: #{$0} [-n nick] [-s summary] [-f source] [-h|--help]\n" + $stderr.puts "\t -n \tset your nickname (defaults to Anonymuos)" + $stderr.puts "\t -s \tspecify a summary of your paste (defaults to none)" + $stderr.puts "\t -f \tsets the file to read from, you don't need this for reading from stdin" + $stderr.puts "\t --help\t\tprint this help" + Kernel.exit(1) +end + +file = nil +summary = "none" +nick = "Anonymous" +channel = "#grml" +text = "" + +ARGV.each_index do |i| + if ARGV[i] == '-h' or ARGV[i] == '--help' then + usage + elsif ARGV[i] == '-n' and ARGV[i+1] != nil then + nick = ARGV[i+1] + elsif ARGV[i] == '-s' and ARGV[i+1] != nil then + summary = ARGV[i+1] + elsif ARGV[i] == '-f' and ARGV[i+1] != nil then + file = ARGV[i+1] + end +end + +if file == nil or file == "-" + f = STDIN +else + begin + f = File.open(file) + rescue + $stderr.puts "Error: couldn't open file: #{file}" + Kernel.exit(1) + end +end + +f.each_line do |line| + text << line +end + +begin + res = Net::HTTP.post_form(url,{'Paste it' => 'Paste it', 'paste' => text, 'channel' => channel, 'summary' => summary, 'nick' => nick}) +rescue + $stderr.puts "Unable to post HTTP request" + Kernel.exit(1) +end + +results = res.body.scan(/ 0 then + result = results[0].sub(/ -- 2.1.4