Skip to content

Instantly share code, notes, and snippets.

@fcwu
Created October 25, 2013 10:19
Show Gist options
  • Save fcwu/7152543 to your computer and use it in GitHub Desktop.
Save fcwu/7152543 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Before script...
# $ mkdir src
# $ amd-driver-installer-<version>-x86.x86_64.run --extract src
# $ cd src
# $ ./packages/Ubuntu/ati-packager.sh --buildpkg source
# change this script modalias 6600 to your graphic card
#
# run this script
#
# After script...
# cd ubuntu/build/
# bzr init
# bzr add .
# change debian/control
# dch -r
# bzr push ???
# bzr bd -S
# dput ppa:oem-archive/somerville *.changes
set -e
VER=13.201
DSC=fglrx-installer_13.201-0ubuntu1.dsc
function replace_once() {
# $1: search
# $2: replace
# $3: file
sed -i "1,/$1/ {/$1/c\
$2
}" $3
}
function append_once() {
# $1: search
# $2: append string
# $3: file
sed -i "1,/$1/ {/$1/a\
$2
}" $3
}
mkdir -p ubuntu/
dpkg-source -x $DSC ubuntu/build
cd ubuntu/build
# debian/control
append_once "^Uploaders:" "Vcs-Bzr: lp:~oem-solutions-engineers/dell/fglrx-installer-$VER" debian/control
replace_once "^Package: fglrx\$" "Package: fglrx-$VER" debian/control
replace_once "^Recommends: fglrx-amdcccle\$" "Recommends: fglrx-amdcccle-$VER" debian/control
replace_once "^Package: fglrx-dev\$" "Package: fglrx-$VER-dev" debian/control
replace_once "^Depends: fglrx" "Depends: fglrx-$VER" debian/control
replace_once "^Package: fglrx-amdcccle\$" "Package: fglrx-amdcccle-$VER" debian/control
replace_once "^Depends: fglrx, \${shlibs:Depends}" "Depends: fglrx-$VER, \${shlibs:Depends}" debian/control
# debian/rules
replace_once "^PKG_driver[[:space:]]*:=" "PKG_driver := fglrx-$VER" debian/rules
replace_once "^PKG_driver_dev[[:space:]]*:=" "PKG_driver_dev := fglrx-$VER-dev" debian/rules
replace_once "^PKG_control[[:space:]]*:=" "PKG_control := fglrx-amdcccle-$VER" debian/rules
replace_once "^alt_priority[[:space:]]*:=" "alt_priority := 1001" debian/rules
replace_once "^PX_alt_priority[[:space:]]*:=" "PX_alt_priority := 901" debian/rules
replace_once "^PKG_dirname[[:space:]]*:=" "PKG_dirname := fglrx" debian/rules
sed -i 's#dh_shlibdeps.*lib32#dh_shlibdeps -l$(CURDIR)/debian/$(PKG_driver)/$(PKG_libdir):$(CURDIR)/debian/$(PKG_driver)/$(PKG_libdir)/bin:$(CURDIR)/debian/$(PKG_driver)/$(PKG_libdir)/sbin:$(CURDIR)/debian/$(PKG_driver)/$(PKG_libdir32) -Xlib32#g' debian/rules
sed -i 's#dh_shlibdeps.*sbin$#dh_shlibdeps -l$(CURDIR)/debian/$(PKG_driver)/$(PKG_libdir):$(CURDIR)/debian/$(PKG_driver)/$(PKG_libdir)/bin:$(CURDIR)/debian/$(PKG_driver)/$(PKG_libdir)/sbin#g' debian/rules
sed -i 's#debian/fglrx.modaliases#debian/$(PKG_driver).modaliases#g' debian/rules
# rename
for f in debian/fglrx-amdcccle.*; do
mv "$f" "${f%%.*}-${VER}.${f#*.}"
done
mv debian/overrides/fglrx-amdcccle debian/overrides/fglrx-amdcccle-$VER
for f in debian/fglrx.*; do
mv "$f" "${f%%.*}-${VER}.${f#*.}"
done
mv debian/overrides/fglrx.in debian/overrides/fglrx-$VER.in
for f in debian/fglrx-dev.*; do
mv "$f" "${f%%-dev.*}-${VER}-dev.${f#*.}"
done
mv debian/overrides/fglrx-dev debian/overrides/fglrx-$VER-dev
# rename patch
sed -i "s%debian/overrides/fglrx-dev%debian/overrides/fglrx-$VER-dev%g" debian/fglrx-$VER-dev.install.in
sed -i "s%debian/overrides/fglrx-amdcccle%debian/overrides/fglrx-amdcccle-$VER%g" debian/fglrx-amdcccle-$VER.install.in
sed -i "s%fglrx.grub-gfxpayload%fglrx-$VER.grub-gfxpayload%g" debian/fglrx-$VER.install.in
sed -i "s%fglrx.grub-gfxpayload%fglrx-$VER.grub-gfxpayload%g" debian/fglrx-$VER.postinst.in
# modalias
sed -i 's%grep "0x" "$filename" |%grep "0x" "$filename" | grep "6600" |%g' debian/modaliases/fglrx_supported
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment