home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / update-notifier / apt-cdrom-check next >
Encoding:
Text File  |  2006-08-30  |  1.2 KB  |  58 lines

  1. #!/bin/sh
  2.  
  3.  
  4. mount_point="$1"
  5.  
  6. # sanity checks
  7. if [ -z "$mount_point" ]; then
  8.     exit 0
  9. fi
  10.  
  11. if [ ! -d "$mount_point/ubuntu" ]; then
  12.     exit 0
  13. fi
  14.  
  15. # check if there are "Packages" files on the cd (and ignore the 
  16. # debian-installer dir)
  17. find "$mount_point/dists/"  -name Packages|grep -q -v debian-installer
  18.  
  19. # 1 means "no lines where selected" in grep (no Packages file but the 
  20. # debian-installer ones)
  21. if [ $? -eq 1 ]; then
  22.     exit 0
  23. fi
  24.  
  25. # get some apt-config vars
  26. label_start=0
  27. cdrom_id=""
  28.  
  29. apt_dir="/"
  30. apt_state_dir="var/lib/apt/"
  31. apt_cdrom_list="cdrom.list"
  32. eval $(apt-config shell apt_dir Dir \
  33.                         apt_state_dir Dir::State \
  34.                         apt_cdrom_list Dir::State::cdroms)
  35.  
  36.  
  37.  
  38. # identifying ... [afkdsjaf] line
  39. line=$(apt-cdrom -d="$1" -m ident|grep "\[.*\]")
  40.  
  41. # remove the stuff before "Identifiyng... [dasjflkd]" -> "dasjflkd"
  42. line=${line%]*}
  43. cdrom_id=${line#*[}
  44.  
  45. if [ -z "$cdrom_id" ]; then
  46.     # something bad happend here, we return "not yet scanned" as 
  47.     # fallback (because we are cheap)
  48.     return 1
  49. fi
  50.  
  51. # [cdrom-id] -> cdrom-id  
  52. if grep -s -q "$cdrom_id"  $apt_dir$apt_state_dir$apt_cdrom_list; then
  53.     # already in sources.list, ignore
  54.     exit 0
  55. fi
  56.  
  57. # not found, return true
  58. exit 1