Submitted scripts and programs
Forum rules
Your own work only.
-
Alad
- should take a shower
- Posts: 447
- Joined: Wed May 21, 2014 12:52 am
Unread post
by Alad » Tue Jun 24, 2014 1:59 pm
Automatically patch, build debs and remove the dependencies. Example adds bottom stack to dwm; change variables accordingly. This is more meant for casual use, use
cowbuilder if you plan on doing this often. Thanks to rust_collector and wuxmedia for fixing some bugs.
TODO: Fix grep/sed abomination
Code: Select all
#!/bin/bash
# nurse - Automatically patch Debian packages
### BEGIN PKG INFO
pkg=dwm
ver=6.0
rel=6
dist=unstable
pool=$(echo $pkg | cut -c 1)
source="http://ftp.de.debian.org/debian/pool/main/$pool/$pkg/${pkg}_$ver-$rel.dsc"
patch="http://dwm.suckless.org/patches/dwm-6.0-bstack.diff"
### END PKG INFO
if (( $UID == 0 )); then
echo "Don't build as root, handsome."
exit 1
fi
devel="quilt debian-keyring devscripts curl fakeroot libdistro-info-perl"
sudo apt-get install "$devel"
depends() {
sudo apt-get build-dep $pkg
# Born and raised in Chernobyl
deplist=("$(tac /var/log/apt/history.log | grep -m1 Install \
| sed "s|\(([^)]*)\)||g;s|,\s||g;s|Install:||")")
}
prepare() {
gpg -k # Initialize GPG config
dget $source
cd "$pkg-$ver"
test -d debian/patches || mkdir -p debian/patches
# https://bugs.debian.org/752624 debian/patches;
curl -Lo /tmp/099_meds.patch "$patch"
quilt import /tmp/099_meds.patch
}
build() {
dch --local +bbq --distribution $dist "Just what the doctor ordered."
dpkg-buildpackage -us -uc
}
# ================
depends && prepare
# ================
case "$?" in
0)
build
;;
2)
build
;;
*)
echo "I couldn't cure you."
exit 69
;;
esac
read -rp "Remove build dependencies? [y/n]" OPTION
case $OPTION in
[yY])
apt-get purge ${deplist[@]}
;;
[nN])
exit
;;
esac
Last edited by
Alad on Wed Jun 25, 2014 4:34 pm, edited 3 times in total.
It's funny how we used to be able to do real stuff with rudimentary computers, but now we can't. -- ratcheer
-
wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
-
Contact:
Unread post
by wuxmedia » Tue Jun 24, 2014 4:13 pm
eh?
oh yeah, the curl needs quotes to get a cgi-bin script bit, think you found that out in the end 8)
well nice scriptage!
-
Alad
- should take a shower
- Posts: 447
- Joined: Wed May 21, 2014 12:52 am
Unread post
by Alad » Wed Jun 25, 2014 12:28 am
Cheers wux.
PS: I've changed the example to dwm. I don't want people to think one patch solves all of GTK3's problems.
It's funny how we used to be able to do real stuff with rudimentary computers, but now we can't. -- ratcheer
-
pidsley
- Hermit
- Posts: 2539
- Joined: Wed Oct 17, 2012 12:31 pm
Unread post
by pidsley » Wed Jun 25, 2014 12:49 am
Regarding the "tac" line -- you want just the first "Install" line, and just the package? Try awk:
Code: Select all
tac /var/log/apt/history.log | awk '/^Install/ {print $2; exit}'
-
Alad
- should take a shower
- Posts: 447
- Joined: Wed May 21, 2014 12:52 am
Unread post
by Alad » Wed Jun 25, 2014 1:49 pm
Thanks pidsley, with the above line it seems only the first package is printed (where I want all installed dependencies removed), but I'll look into it and post back. :)
It's funny how we used to be able to do real stuff with rudimentary computers, but now we can't. -- ratcheer
-
pidsley
- Hermit
- Posts: 2539
- Joined: Wed Oct 17, 2012 12:31 pm
Unread post
by pidsley » Wed Jun 25, 2014 2:05 pm
Sorry, the test case I used only had one dependent package. ;) I will look at this a little more later when I have more time.
-
Alad
- should take a shower
- Posts: 447
- Joined: Wed May 21, 2014 12:52 am
Unread post
by Alad » Fri Jul 11, 2014 11:56 am
Removed the need for grep/awk (and a problematic case where the "last" install doesn't match) by making a metapackage.
Still far from happy on this, the specified patches are remote-only and patching debian/* itself doesn't work with quilt. Also you may have to type the sudo password again (saw a trick to prevent this, don't remember it).
Code: Select all
#!/bin/bash
# nurse - Automatically patch Debian packages
### BEGIN PKG INFO
pkg=dwm
ver=6.0
rel=6
dist=unstable
pool=$(echo $pkg | cut -c 1)
source="http://ftp.de.debian.org/debian/pool/main/$pool/$pkg/${pkg}_$ver-$rel.dsc"
patch="http://dwm.suckless.org/patches/dwm-6.0-bstack.diff"
### END PKG INFO
if (( $UID == 0 )); then
echo "Don't build as root, handsome."
exit 1
fi
devel="quilt debian-keyring devscripts curl fakeroot libdistro-info-perl equivs"
sudo apt-get install "$devel"
prepare() {
gpg -k # Initialize GPG config
dget $source
cd "$pkg-$ver"
test -d debian/patches || mkdir -p debian/patches
# https://bugs.debian.org/752624
curl -Lo /tmp/099_meds.patch "$patch"
quilt import /tmp/099_meds.patch
}
depends() {
mk-build-deps
sudo dpkg -i $pkg-build-deps*.deb
sudo apt-get install -fy
}
build() {
dch --local +nurse --distribution $dist "Just what the doctor ordered."
dpkg-buildpackage -us -uc
}
# =====
prepare
# =====
case "$?" in
0)
depends && build
;;
2)
depends && build
;;
*)
echo "I couldn't cure you."
exit 69
;;
esac
read -rp "Remove build dependencies? [y/n]" OPTION
case $OPTION in
[yY])
sudo apt-get autoremove --purge $pkg-build-deps
;;
[nN])
exit
;;
esac
It's funny how we used to be able to do real stuff with rudimentary computers, but now we can't. -- ratcheer