Skip to content

Instantly share code, notes, and snippets.

@vi

vi/simple_debianize

Created Jun 29, 2014
Embed
What would you like to do?
Simple one-step crude debianizator for my sole-executable-file Github projects
#!/bin/bash
if [ -z "$3" ]; then
echo "Usage: simple_debianize name initial_version executable_name"
exit 1
fi
set -e
NAME="$1"
VERS="$2"
EXENAME="$3"
DESC="$(head -n 1 < README*)"
AUTOURL=$(git remote -v show | perl -ne 'INIT{$user="unknown"; $proj="unknown"}; s!github.com:([^ ]*)/([^ ]*)!$user=$1; $proj=$2!e; END{print "https://github.com/$user/$proj\n";}')
mkdir -p deb/debian/source
echo "" > deb/debian/files
echo "" > deb/debian/test
echo "$EXENAME /usr/bin/" > deb/debian/install
cat > deb/debian/rules <<\EOF
#!/usr/bin/make -f
%:
dh $@
override_dh_auto_test:
true
EOF
chmod +x deb/debian/rules
echo "8" > deb/debian/compat
echo "3.0 (quilt)" > deb/debian/source/format
cat > deb/debian/changelog <<EOF
$NAME ($VERS-1) unstable; urgency=low
* Initial release (Closes: #...)
-- `git config user.name` <`git config user.email`> `date -R`
EOF
cat > deb/debian/control <<EOF
Source: $NAME
Section: utils
Priority: extra
Maintainer: `git config user.name` <`git config user.email`>
Standards-Version: 3.9.3
Homepage: $AUTOURL
Package: $NAME
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}, libc6
Description: $DESC
EOF
cat > deb/makedeb.sh <<EOF
#!/bin/bash
set -e
P=$NAME
V=$VERS
FILES="$(git ls-tree --name-only -z HEAD: | tr '\0' ' ')"
rm -Rf "\$P"-\$V
trap "rm -fR \"\$P\"-\$V" EXIT
mkdir "\$P"-\$V
for i in \$FILES; do cp -Rv ../"\$i" "\$P"-\$V/; done
tar -czf \${P}_\$V.orig.tar.gz "\$P"-\$V
cp -R debian "\$P"-\$V
(cd "\$P"-\$V && debuild)
EOF
chmod +x deb/makedeb.sh
echo '*' > deb/.gitignore
echo git add -f deb/.gitignore deb/makedeb.sh deb/debian/{changelog,compat,control,files,install,rules,source/format,test}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.