postinst is in lirc 0.9.0-0ubuntu6.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | #!/bin/sh
set -e
check_hardware_conf ()
{
#Make sure that all variables are there, and also create the file if
#it is not there
#local VAR
for VAR in REMOTE REMOTE_MODULES REMOTE_DRIVER REMOTE_DEVICE REMOTE_SOCKET REMOTE_LIRCD_CONF REMOTE_LIRCD_ARGS TRANSMITTER TRANSMITTER_MODULES TRANSMITTER_DRIVER TRANSMITTER_DEVICE TRANSMITTER_SOCKET TRANSMITTER_LIRCD_CONF TRANSMITTER_LIRCD_ARGS START_LIRCD START_LIRCMD LOAD_MODULES LIRCMD_CONF FORCE_NONINTERACTIVE_RECONFIGURATION
do
# Patch provided by Robert Bihlmeyer <robbe@orcus.priv.at>
# See http://bugs.debian.org/303078
if ! grep -q "^[ ]*$VAR\>" /etc/lirc/hardware.conf; then
echo "$VAR=\"\"" >> /etc/lirc/hardware.conf
fi
done
}
Save ()
{
if [ -f $1 ]; then
cp $1 $1.old
fi
sed -i -e "
s|^\(REMOTE\)=.*|\1=\"$REMOTE\"|;
s|^\(REMOTE_DRIVER\)=.*|\1=\"$REMOTE_DRIVER\"|;
s|^\(REMOTE_MODULES\)=.*|\1=\"$REMOTE_MODULES\"|;
s|^\(REMOTE_DEVICE\)=.*|\1=\"$REMOTE_DEVICE\"|;
s|^\(REMOTE_LIRCD_CONF\)=.*|\1=\"$REMOTE_LIRCD_CONF\"|;
s|^\(TRANSMITTER\)=.*|\1=\"$TRANSMITTER\"|;
s|^\(TRANSMITTER_DRIVER\)=.*|\1=\"$TRANSMITTER_DRIVER\"|;
s|^\(TRANSMITTER_MODULES\)=.*|\1=\"$TRANSMITTER_MODULES\"|;
s|^\(TRANSMITTER_DEVICE\)=.*|\1=\"$TRANSMITTER_DEVICE\"|;
s|^\(TRANSMITTER_LIRCD_CONF\)=.*|\1=\"$TRANSMITTER_LIRCD_CONF\"|;
s|^\(START_LIRCD\)=.*|\1=\"$START_LIRCD\"|;
s|^\(LIRCMD_CONF\)=.*|\1=\"$LIRCMD_CONF\"|;
s|^\(FORCE_NONINTERACTIVE_RECONFIGURATION\)=.*|\1=\"$FORCE_NONINTERACTIVE_RECONFIGURATION\"|;
" $1
}
ChooseRemote()
{
OLDREMOTE="${REMOTE:-None}"
OLDTRANSMITTER="${TRANSMITTER:-None}"
#force reconfiguration. can be set by external applications
#to true if they want to bypass the normal methods presented
#to users and instead just parse the file.
FORCE_NONINTERACTIVE_RECONFIGURATION=`grep "^FORCE_NONINTERACTIVE_RECONFIGURATION=" /etc/lirc/hardware.conf | sed s/\"//g | awk -F "=" '{print $2}'`
#Present the user with some choices
#To later explain what this is actually doing without man pages:
#First, only grab lines with a ;
#Now, remove all commas from streams
#Now, Remove all remaining comments or ['s
#Now, Print the remote name
#Next, sort the list and remove duplicates
#Now, Affix a comma and space to all starts of lines
#Lastly, change the newline to a null character
REMOTES=`cat /usr/share/lirc/lirc.hwdb /usr/share/lirc/extras/more_remotes.hwdb 2>/dev/null | grep ";" | sed 's/,//g' | awk -F ";" '$0!~/^#|^\[/{print $1}' | sort -u | sed 's/^/,\ /' | tr '\n' '\0'`
db_subst lirc/remote REMOTES $REMOTES
TRANSMITTERS=`grep ";" /usr/share/lirc/extras/transmitter.hwdb | sort | sed 's/,//g' | awk -F ";" '$0!~/^#|^\[/{print $1}' | sed 's/^/,\ /' | tr '\n' '\0'`
db_subst lirc/transmitter TRANSMITTERS $TRANSMITTERS
db_set lirc/remote "$REMOTE"
db_set lirc/transmitter "$TRANSMITTER"
#If we are forcing a reconfigure, then our old remote and new ones are the same
if [ "$FORCE_NONINTERACTIVE_RECONFIGURATION" != "true" ]; then
db_input high lirc/remote || true
db_input high lirc/transmitter || true
db_go
fi
#Populate remote information (remote is our primary device at all times)
db_get lirc/remote
REMOTE="${RET}"
db_get lirc/transmitter
TRANSMITTER="${RET}"
SUPPORTED_DRIVERS=`lircd -H help 2>&1 | awk '$0!~/^S|^D/{print $1}' | tr '\n' '\ '`
if [ "$REMOTE" != "None" ] && [ "$REMOTE" != "Custom" ] && ([ "$OLDREMOTE" != "$REMOTE" ] || [ "$FORCE_NONINTERACTIVE_RECONFIGURATION" = "true" ])
then
#To later explain what this is actually doing without man pages:
#First, only grab lines with a ;
#Now, remove all commas from streams
#Lastly, take the last matching entry found (so remotes.hwdb overrides lirc.hwdb)
REMOTE_LINE=`cat /usr/share/lirc/lirc.hwdb /usr/share/lirc/extras/more_remotes.hwdb 2>/dev/null | sed -n '/;/ { s/,//g; p }' | grep "${REMOTE}" | tail -1`
#Remove all remaining comments or ['s
#then print the remote name
REMOTE_MODULES=`echo $REMOTE_LINE | awk -F ";" '$0!~/^#|^\[/{print $3}'`
REMOTE_DRIVER=`echo $REMOTE_LINE | awk -F ";" '$0!~/^#|^\[/{print $2}'`
REMOTE_LIRCD_CONF=`echo $REMOTE_LINE | awk -F ";" '$0!~/^#|^\[/{print $5}'`
#/dev/input/eventX is a weird case: filter it
if [ "$REMOTE_LIRCD_CONF" = "<A HREF=\"http://linux.bytesex.org/v4l2/faq.html#lircd\">generic config file for Linux input layer</A>" ]; then
REMOTE_LIRCD_CONF=""
fi
#For atilibusb, we need to blacklist the kernel module
if [ "$REMOTE_DRIVER" = "atilibusb" ]; then
BLACKLIST="lirc_atiusb ati_remote"
elif [ "$REMOTE_DRIVER" = "atiusb" ]; then
BLACKLIST="ati_remote"
else
BLACKLIST=""
fi
#lirc.hwdb puts none rather than ;;
if [ "$REMOTE_MODULES" != "none" ]; then
#if we have a module in use, don't use a driver too
REMOTE_DRIVER=""
else
REMOTE_MODULES=""
fi
#lirc.hwdb puts none rather than ;;
if [ "$REMOTE_DRIVER" = "none" ]; then
REMOTE_DRIVER=""
fi
#only need to put driver for non kernel module devices
if ! echo "$SUPPORTED_DRIVERS" | grep "$REMOTE_DRIVER" > /dev/null; then
REMOTE_DRIVER=""
fi
#reset our REMOTE_DEVICE whenever remotes
#are changed. Calculated later.
REMOTE_DEVICE=""
CONFIG_CHANGED=:
elif [ "$OLDREMOTE" != "$REMOTE" ] && [ "$REMOTE" = "None" ]; then
CONFIG_CHANGED=:
REMOTE_DEVICE=""
REMOTE_MODULES=""
REMOTE_DRIVER=""
REMOTE_LIRCD_CONF=""
fi
#If we have a devinput driver, we need
#to present the user with a way to figure out
#what device is it
#This should be ran even if they haven't changed remotes
if [ "$REMOTE_DRIVER" = "devinput" ]; then
#present question
EVENTS=`find /dev/input/* -type d -exec find {} -not -type d -printf ", %p" \;`
db_subst lirc/dev_input_device EVENTS $EVENTS
db_input high lirc/dev_input_device || true
db_go
#get our answer
db_get lirc/dev_input_device
if [ "$RET" != "$REMOTE_DEVICE" ]; then
REMOTE_DEVICE="$RET"
CONFIG_CHANGED=:
fi
elif [ "$REMOTE_DRIVER" = "dvico" ];then
#present question
EVENTS=`ls /dev/usb | sed 's/^/,\ \/dev\/usb\//' | tr '\n' '\0'`
db_subst lirc/dev_input_device EVENTS $EVENTS
db_input high lirc/dev_input_device || true
db_go
#get our answer
db_get lirc/dev_input_device
if [ "$RET" != "$REMOTE_DEVICE" ]; then
REMOTE_DEVICE="$RET"
CONFIG_CHANGED=:
fi
#otherwise, set our old device in debconf again
else
db_set lirc/dev_input_device /dev/lirc0
db_fset lirc/dev_input_device seen false
fi
if [ "$TRANSMITTER" != "None" ] && [ "$TRANSMITTER" != "Custom" ] && ([ "$OLDTRANSMITTER" != "$TRANSMITTER" ] || [ "$FORCE_NONINTERACTIVE_RECONFIGURATION" = "true" ])
then
TRANSMITTER_LINE=`sed -n '/;/ { s/,//g; p }' /usr/share/lirc/extras/transmitter.hwdb | grep "${TRANSMITTER}" | tail -1`
TRANSMITTER_MODULES=`echo $TRANSMITTER_LINE | awk -F ";" '$0!~/^#|^\[/{print $3}'`
TRANSMITTER_DRIVER=`echo $TRANSMITTER_LINE | awk -F ";" '$0!~/^#|^\[/{print $2}'`
TRANSMITTER_LIRCD_CONF=`echo $TRANSMITTER_LINE | awk -F ";" '$0!~/^#|^\[/{print $5}'`
#transmitter.hwdb puts none rather than ;;
if [ "$TRANSMITTER_MODULES" != "none" ]; then
#if we have a module in use, don't use a driver too
TRANSMITTER_DRIVER=""
else
TRANSMITTER_MODULES=""
fi
#transmitter.hwdb puts none rather than ;;
if [ "$TRANSMITTER_DRIVER" = "none" ]; then
TRANSMITTER_DRIVER=""
fi
#only need to put driver for non kernel module devices
if ! echo "$SUPPORTED_DRIVERS" | grep "$TRANSMITTER_DRIVER" > /dev/null; then
TRANSMITTER_DRIVER=""
fi
CONFIG_CHANGED=:
elif [ "$OLDTRANSMITTER" != "$TRANSMITTER" ] && [ "$TRANSMITTER" = "None" ]
then
CONFIG_CHANGED=:
TRANSMITTER_DEVICE=""
TRANSMITTER_DRIVER=""
TRANSMITTER_MODULES=""
TRANSMITTER_LIRCD_CONF=""
fi
#Choose a serial port if we are using serial
if [ "$REMOTE_MODULES" = "lirc_dev lirc_serial" ] || [ "$TRANSMITTER_MODULES" = "lirc_dev lirc_serial" ]
then
db_input high lirc/serialport || true
db_go
#if we aren't using serial, then go back to default
else
db_set lirc/serialport "/dev/ttyS0"
db_fset lirc/serialport seen false
fi
#Plan to have lircd enabled
START_LIRCD=true
#If we have a remote and a transmitter, figure out devices
if [ "$TRANSMITTER" != "None" ] && [ "$REMOTE" != "None" ]; then
#Make sure that at least one of these has changed before we make changes
if [ "$OLDREMOTE" != "$REMOTE" ] || [ "$OLDTRANSMITTER" != "$TRANSMITTER" ]; then
#if no remote device is defined already
#and we do use a kernel module
if [ -z "$REMOTE_DEVICE" ] && [ -n "$REMOTE_MODULES" ]
then
REMOTE_DEVICE="/dev/lirc0"
fi
#set up our transmitter.
#if we use the same kernel modules, we use the same device
#and we should disable transmitter stuff further
if ([ -n "$TRANSMITTER_MODULES" ] && [ "$TRANSMITTER_MODULES" = "$REMOTE_MODULES" ]) \
|| ([ -n "$TRANSMITTER_DRIVER" ] && [ "$TRANSMITTER_DRIVER" = "$REMOTE_DRIVER" ])
then
TRANSMITTER_DEVICE=""
TRANSMITTER_DRIVER=""
#if they aren't the same driver/device, we needed a remote module and we need a transmitter kernel module
elif [ "$REMOTE_DEVICE" = "/dev/lirc0" ] && [ -n "$TRANSMITTER_MODULES" ]
then
TRANSMITTER_DEVICE="/dev/lirc1"
#if they aren't the same driver/device, but we didn't need a remote module, but need a transmitter kernel module
elif [ -n "$TRANSMITTER_MODULES" ]; then
TRANSMITTER_DEVICE="/dev/lirc0"
fi
fi
#if we have just a transmitter, figure out device
elif [ "$TRANSMITTER" != "None" ]; then
#if we need kernel transmitter modules
if [ -n "$TRANSMITTER_MODULES" ]; then
TRANSMITTER_DEVICE="/dev/lirc0"
fi
#we have just chosen a remote
elif [ "$REMOTE" != "None" ]; then
#no remote device is defined already
#and we need kernel remote modules
if [ -z "$REMOTE_DEVICE" ] && [ -n "$REMOTE_MODULES" ] ; then
REMOTE_DEVICE="/dev/lirc0"
fi
#if both remote and transmitter are set to none
else
#disable lircd
START_LIRCD=false
fi
}
Setup_Blacklist()
{
if [ -n "$BLACKLIST" ]; then
cat > /etc/modprobe.d/lirc-blacklist.conf <<EOF
#File automatically generated upon lirc install
#Because a module had to be blacklisted. Don't
#Modify by hand, but rather via
#dpkg-reconfigure lirc
EOF
for item in $BLACKLIST
do
echo "blacklist $item" >> /etc/modprobe.d/lirc-blacklist.conf
if egrep -q '^'"$item"'\ ' /proc/modules; then
rmmod $item
fi
done
else
rm -f /etc/modprobe.d/lirc-blacklist.conf
fi
}
Setup_Serial()
{
#Move out old config
if [ -f /etc/serial.conf ]; then
mv /etc/serial.conf /etc/serial.conf.old
fi
#figure out if we have serial modules at all
if [ "$REMOTE_MODULES" = "lirc_dev lirc_serial" ] || [ "$TRANSMITTER_MODULES" = "lirc_dev lirc_serial" ]; then
#if we chose ttyS0 or ttyS1, add it to modprobe.d
db_get lirc/serialport
SERIAL=$RET
if [ "$SERIAL" = "/dev/ttyS0" ]; then
cat > /etc/modprobe.d/lirc-serial.conf <<EOF
#COM1 equivalent, /dev/ttyS0
options lirc_serial irq=4 io=0x3f8
#COM2 equivalent, /dev/ttyS1
#options lirc_serial irq=3 io=0x2f8
EOF
elif [ "$SERIAL" = "/dev/ttyS1" ]; then
cat > /etc/modprobe.d/lirc-serial.conf <<EOF
#COM1 equivalent, /dev/ttyS0
#options lirc_serial irq=4 io=0x3f8
#COM2 equivalent, /dev/ttyS1
options lirc_serial irq=3 io=0x2f8
EOF
fi
cat > /etc/serial.conf << EOF
$SERIAL uart none
EOF
#reload setserial to turn off serial port
invoke-rc.d etc-setserial restart
else
rm -f /etc/modprobe.d/lirc-serial.conf
fi
}
setup_lircd_conf()
{
#if we have an existing file, back it up
if [ -f "/etc/lirc/lircd.conf" ]; then
mv /etc/lirc/lircd.conf /etc/lirc/lircd.conf.dpkg-old
fi
#Add a header to the lircd.conf
cat >> /etc/lirc/lircd.conf << EOF
#This configuration has been automatically generated via
#the Ubuntu LIRC package maintainer scripts.
#
#It includes the default configuration for the remote and/or
#transmitter that you have selected during package installation.
#
#Feel free to add any custom remotes to the configuration
#via additional include directives or below the existing
#Ubuntu include directives from your selected remote and/or
#transmitter.
EOF
#if we have a remote, include its config
if [ -f "/usr/share/lirc/extras/more_remotes/$REMOTE_LIRCD_CONF" ]
then
cat >> /etc/lirc/lircd.conf <<EOF
#Configuration for the $REMOTE remote:
include "/usr/share/lirc/extras/more_remotes/$REMOTE_LIRCD_CONF"
EOF
elif [ -f "/usr/share/lirc/remotes/$REMOTE_LIRCD_CONF" ]
then
cat >> /etc/lirc/lircd.conf <<EOF
#Configuration for the $REMOTE remote:
include "/usr/share/lirc/remotes/$REMOTE_LIRCD_CONF"
EOF
elif [ -f "$REMOTE_LIRCD_CONF" ]; then
cat >> /etc/lirc/lircd.conf <<EOF
#Configuration for the $REMOTE remote:
include "$REMOTE_LIRCD_CONF"
EOF
elif [ "$REMOTE" != "None" ]; then
cat >> /etc/lirc/lircd.conf <<EOF
#No default remote configuration was included for $REMOTE
#You will need to include your own custom configuration for
#this remote, and file a bug at https://bugs.launchpad.net/ubuntu/+source/lirc/+filebug
EOF
fi
#if we have a transmitter, include its config
if [ -f "/usr/share/lirc/extras/transmitters/$TRANSMITTER_LIRCD_CONF" ]
then
cat >> /etc/lirc/lircd.conf <<EOF
#Configuration for the $TRANSMITTER transmitter:
include "/usr/share/lirc/extras/transmitters/$TRANSMITTER_LIRCD_CONF"
EOF
elif [ -f "$TRANSMITTER_LIRCD_CONF" ]; then
cat >> /etc/lirc/lircd.conf <<EOF
#Configuration for the $TRANSMITTER transmitter:
include "$TRANSMITTER_LIRCD_CONF"
EOF
elif [ "$TRANSMITTER" != "None" ]; then
cat >> /etc/lirc/lircd.conf <<EOF
#No default remote configuration was included for $TRANSMITTER
#You will need to include your own custom configuration for
#this transmitter, and file a bug at https://bugs.launchpad.net/ubuntu/+source/lirc/+filebug
EOF
fi
}
unload_modules()
{
KERNEL=`uname -r`
#unload all modules (but lirc_dev last)
for item in `ls /lib/modules/$KERNEL/kernel/drivers/staging/media/lirc` lirc_dev
do
if egrep -q '^'"$item"'\ ' /proc/modules; then
rmmod $item 2>/dev/null || true
fi
done
}
. /usr/share/debconf/confmodule
if [ "$1" = "configure" ]; then
CONFIG_CHANGED=false
if dpkg --compare-versions "$2" lt-nl "0.9.0-0ubuntu5"; then
rm -f /etc/modprobe.d/lirc-blacklist
fi
[ -x /sbin/udevd ] && invoke-rc.d udev reload >&2
#unload any old modules before starting
unload_modules
check_hardware_conf
. /etc/lirc/hardware.conf
#parse the lirc.hwdb to find our remote
ChooseRemote
Save /etc/lirc/hardware.conf
#Prepare the blacklisting for necessary modules
Setup_Blacklist
#Setup serial module
Setup_Serial
# If we don't have a valid lircd.conf try to get one
if [ ! -f /etc/lirc/lircd.conf ] \
|| grep -q "^#UNCONFIGURED" /etc/lirc/lircd.conf \
|| $CONFIG_CHANGED ;then
setup_lircd_conf
fi
# If we don't have a valid lircmd.conf try to get one
if [ ! -f /etc/lirc/lircmd.conf ] \
|| grep -q "^#UNCONFIGURED" /etc/lirc/lircmd.conf ;then
# if there is a misplaced config file it is ok to move it to
# the right place
if [ -f /etc/lircmd.conf ];then
echo moving /etc/lircmd.conf to /etc/lirc/
mv /etc/lircmd.conf /etc/lirc/
# we don't restore the file unless the user is (re)configuring
elif $CONFIG_CHANGED \
&& [ -f "/usr/share/lirc/extras/more_remotes/$RET" ];then
echo trying default lircmd.conf
cp /usr/share/lirc/extras/more_remotes/$RET \
/etc/lirc/lircmd.conf
elif $CONFIG_CHANGED \
&& [ -f "/usr/share/lirc/remotes/$RET" ];then
echo trying default lircmd.conf
cp /usr/share/lirc/remotes/$RET \
/etc/lirc/lircmd.conf
fi
fi
fi
db_stop
# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
if [ -x "/etc/init.d/lirc" ]; then
update-rc.d lirc defaults 19 >/dev/null
fi
if [ -x "/etc/init.d/lirc" ] || [ -e "/etc/init/lirc.conf" ]; then
invoke-rc.d lirc start || exit $?
fi
fi
# End automatically added section
# Automatically added by dh_installudev
if [ "$1" = configure ]; then
if [ -e "/etc/udev/rules.d/85_lirc.rules" ]; then
echo "Preserving user changes to /etc/udev/rules.d/85-lirc.rules ..."
if [ -e "/etc/udev/rules.d/85-lirc.rules" ]; then
mv -f "/etc/udev/rules.d/85-lirc.rules" "/etc/udev/rules.d/85-lirc.rules.dpkg-new"
fi
mv -f "/etc/udev/rules.d/85_lirc.rules" "/etc/udev/rules.d/85-lirc.rules"
fi
fi
# End automatically added section
|