#!/bin/perl
use strict;
  
my %regexmap = {
  "^apache" => "apache",
  "^avahi" => "avahi",
  "^bacula" => "bacula",
  "^google-chrome" => "chromium",
  "^microsoft-edge" => "chromium",
  "^docker" => "container",
  "^docker" => "docker",
  "^cups" => "cups,lpd",
  "^weechat" => "irc",
  "^krb5" => "kerberos",
  "^mailman" => "mailman",
  "^libxine" => "mplayer",
  "ping$" => "netutils",
  "^hping" => "netutils",
  "^prelude-" => "prelude",
  "^qemu-" => "qemu,virt",
  "^samba" => "samba",
  "^shorewall" => "shorewall",
  "^xdg-" => "xdg",
  "^xen-" => "xen",
  "^xscreensaver" => "xscreensaver",
  "^xserver-xorg" => "xserver",
  "^zabbix-" => "zabbix",
};
  
# always :
# base backup games
  
# user roles:
my @user_roles = ( "auditadm", "dbadm", "guest", "logadm", "secadm", "staff", "unconfined", "unprivuser", "webadm", "xguest" };
  
# proprietary:
# vmware
  
my %packagemap = {
  accountsservice => "accountsd",
  acct => "acct",
  acpid => "acpi",
  openafs-client => "afs",
  openafs_fileserver => "afs",
  aide => "aide",
  amanda-client => "amanda",
  amanda-server => "amanda",
  amavis => "amavis",
  lighttpd => "apache",
  nginx => "apache",
  apcupsd => "apcupsd",
  apt-cacher => "aptcacher",
  apt-cacher-ng => "aptcacher",
  arpwatch => "arpwatch",
  asterisk => "asterisk",
  autofs => "automount",
  awstats => "awstats",
  bind9 => "bind",
  unbound => "bind",
  bird2 => "bird",
  bird3 => "bird",
  bitlbee => "bitlbee",
  bip => "bitlbee",
  blueman => "blueman,bluetooth",
  bluez => "bluetooth",
  boinc-client => "boinc",
  grub2-common => "bootloader",
  systemd => "bootloader",
  bridge-utils => "brctl",
  bubblewrap => "bubblewrap",
  cachefilesd => "cachefilesd",
  calamaris => "calamaris",
  canna => "canna",
  cdrecord => "cdrecord",
  cdrskin => "cdrecord",
  growisofs => "cdrecord",
  wodim => "cdrecord",
  certbot => "certbot",
  certmonger => "certmonger",
  cfengine3 => "cfengine",
  cgroup-tools => "cgroup",
  chromium => "chromium",
  chrony => "chronyd",
  clamav-base => "clamav",
  util-linux-extra => "clock",
  cockpit => "cockpit",
  collectd => "collectd",
  colord => "colord",
  mailutils-comsatd => "comsat",
  condor => "condor",
  crun => "container",
  runc => "container",
  lxc => "container",
  incus => "container",
  corosync => "corosync",
  courier-authdaemon => "courier",
  cpufreqd => "cpucontrol",
  linux-cpupower => "cpucontrol",
  powernowd => "cpucontrol",
  iucode-tool => "cpucontrol",
  gnome-applets => "cpufreqselector",
  cron => "cron",
  ctdb => "ctdb",
  cvs => "cvs",
  cyrus-imapd => "cyrus",
  daemontools => "daemontools",
  dante-server => "dante",
  dbskkd-cdb => "dbskk",
  ddclient => "ddclient",
  udisks2 => "devicekit",
  upower => "devicekit",
  udisks2 => "devicekit",
  kea-common => "dhcp",
  dictd => "dictd",
  dirmngr => "dirmngr",
  distcc => "distcc",
  axfrdns => "djbdns",
  dnscache => "djbdns",
  tinydns => "djbdns",
  opendkim => "dkim",
  dkimpy-milter => "dkim",
  dmidecode => "dmidecode",
  dnsmasq-base => "dnsmasq",
  xdg-desktop-portal => "docportal",
  dovecot-core => "dovecot",
  drbd-utils => "drbd",
  haveged => "entropyd",
  rng-tools-debian => "entropyd",
  haveged => "entropyd",
  jitterentropy-rngd => "entropyd",
  evolution-common => "evolution",
  exim4-base => "exim",
  fail2ban => "fail2ban",
  fcoe-utils => "fcoe",
  fetchmail => "fetchmail",
  cfingerd => "finger",
  efingerd => "finger",
  firewalld => "firewalld",
  fprintd => "fprintd",
  ftpd-ssl => "ftp",
  inetutils-ftpd => "ftp",
  proftpd-core => "ftp",
  vsftpd => "ftp",
  fwupd => "fwupd",
  gnustep-base-runtime => "gdomap",
  glance => "glance",
  glusterfs => "glusterfs",
  gnome-keyring => "gnome",
  gnome-settings-daemon => "gnomeclock",
  gpgsm => "gpg",
  gpg => "gpg",
  gpm => "gpm",
  gpsd => "gpsd",
  haproxy => "haproxy",
  hostapd => "hostapd",
  hostname => "hostname",
  hyperv-daemons => "hypervkvp",
  icecast2 => "icecast",
  inetd => "inetd",
  inetutils-inetd => "inetd",
  openbsd-inetd => "inetd",
  rlinetd => "inetd",
  xinetd => "inetd",
  inn => "inn",
  inn2 => "inn",
  iodine => "iodine",
  nftables => "iptables",
  ebtables => "iptables",
  ipset => "iptables",
  ipvsadm => "iptables",
  ircii => "irc",
  irssi => "irc",
  tinyirc => "irc",
  ircd => "ircd",
  inspircd => "ircd",
  ircd-hybrid => "ircd",
  ircd-irc2 => "ircd",
  ircd-ircu => "ircd",
  ngircd => "ircd",
  irqbalance => "irqbalance",
  iscsiuio => "iscsi",
  ejabberd => "jabber",
  prosody => "jabber",
  kdump-tools => "kdump",
  kexec-tools => "kdump",
  libpam-krb5 => "kerberos",
  keystone => "keystone",
  kubectl => "kubernetes",
  go-l2tp => "l2tp",
  xl2tpd => "l2tp",
  slapd => "ldap",
  lightsquid => "lightsquid",
  lircd => "lircd",
  lldpad => "lldpad",
  kbd => "loadkeys",
  logrotate => "logrotate",
  logwatch => "logwatch",
  low-memory-monitor => "lowmemorymonitor",
  lpr => "lpd",
  lprng => "lpd",
  lvm2 => "lvm",
  cryptsetup-bin => "lvm",
  man2html => "man2html",
  man-db => "mandb",
  matrix-eno-bot => "matrixbot",
  matrix-synapse => "matrixd",
  mediawiki => "mediawiki",
  memcached => "memcached",
  memlockd => "memlockd",
  milter-greylist => "milter",
  sqlgrey => "milter",
  spamass-milter => "milter",
  postfwd => "milter",
  minidlna => "minidlna",
  minissdpd => "minissdpd",
  modemmanager => "modemmanager",
  mon => "mon",
  monit => "monit",
  monopd => "monop",
  firefox => "mozilla",
  firefox-esr => "mozilla",
  epiphany => "mozilla",
  mpd => "mpd",
  mpv => "mplayer",
  mencoder => "mplayer",
  vlc => "mplayer",
  mrtg => "mrtg",
  munin => "munin",
  mariadb-common => "mysql",
  mysql-common => "mysql",
  nagios-nrpe-server => "nagios",
  nagios4  => "nagios",
  needrestart => "needrestart",
  netlabel-tools => "netlabel",
  nmap => "netutils",
  tcpdump => "netutils",
  traceroute => "netutils",
  network-manager => "networkmanager",
  wpasupplicant => "networkmanager",
  nis => "nis",
  nscd => "nscd",
  nsd => "nsd",
  nslcd => "nslcd",
  sntop => "ntop",
  ntop => "ntop",
  ntopng => "ntop",
  ntpsec => "ntp",
  ntpsec-ntpdate => "ntp",
  nut-server => "nut",
  nx-x11-common => "nx",
  nxagent => "nx",
  nxproxy => "nx",
  bluez-obexd => "obex,bluetooth",
  oidentd => "oident",
  openarc => "openarc",
  openhpid => "openhpi",
  opensnitch => "opensnitch",
  openvpn => "openvpn",
  openvswitch-common => "openvswitch",
  pacemaker => "pacemaker",
  passenger => "passenger",
  pcscd => "pcscd",
  perdition => "perdition",
  pipewire => "pipewire",
  opencryptoki => "pkcs",
  plymouth => "plymouthd",
  podman => "podman,container",
  polkitd => "policykit",
  postfix => "postfix,mta",
  postfix-policyd-spf-perl => "postfixpolicyd",
  postfix-policyd-spf-python => "postfixpolicyd",
  postgresql-client => "postgresql",
  postgresql => "postgresql",
  postgrey => "postgrey",
  power-profiles-daemon => "powerprofiles",
  ppp => "ppp",
  privoxy => "privoxy",
  procmail => "procmail",
  maildrop => "procmail",
  psad => "psad",
  publicfile => "publicfile",
  puppet-agent => "puppet",
  pwauth => "pwauth",
  pyzor => "pyzor",
  quota => "quota",
  rabbitmq => "rabbitmq-server",
  freeradius => "radius",
  radsecproxy => "radius",
  radvd => "radvd",
  mdadm => "raid",
  rasdaemon => "rasdaemon",
  rauc => "rauc",
  razor => "razor",
  realmd => "realmd",
  redis-server => "redis",
  rng-tools-debian => "rngd",
  nfs-common => "rpc",
  rpcbind => "rpcbind",
  rsync => "rsync",
  rtkit => "rtkit",
  rwhod => "rwho",
  samhain => "samhain",
  sanlock => "sanlock",
  sasl2-bin => "sasl",
  screen => "screen",
  tmux => "screen",
  sendmail => "sendmail,mta",
  mcstrans => "setrans",
  setroubleshoot => "setroubleshoot",
  shibboleth-sp-utils => "shibboleth",
  systemd-sysv => "shutdown",
  slrnpull => "slrnpull",
  smartmontools => "smartmon",
  smokeping => "smokeping",
  smstools => "smstools",
  snmp => "snmp",
  snmpd => "snmp",
  snmptrapd => "snmp",
  sos => "sosreport",
  spamc => "spamassassin",
  spamd => "spamassassin",
  rspamd => "spamassassin",
  squid => "squid",
  openssh-client => "ssh",
  openssh-server => "ssh",
  sssd => "sssd",
  stunnel => "stunnel",
  util-linux => "su",
  sudo => "sudo",
  subversion => "svnserve",
  switcheroo-control => "switcheroo",
  sxid => "sxid",
  sympa => "sympa",
  sysstat => "sysstat",
  systemtap-server => "systemtap",
  tcpd => "tcpd",
  trousers => "tcsd",
  telepathy-haze => "telepathy",
  telepathy-idle => "telepathy",
  telepathy-mission-control => "telepathy",
  telepathy-rakia => "telepathy",
  atftpd => "tftp",
  tftp-hpa => "tftp",
  tftp-proxy => "tftp",
  tgt => "tgtd",
  bolt => "thunderbolt",
  timidity => "timidity",
  tmpreaper => "tmpreaper",
  tor => "tor",
  tripwire => "tripwire",
  tuned => "tuned",
  tvtime => "tvtime",
  ucspi-tcp => "ucspitcp",
  ulogd2 => "ulogd",
  uml-utilities => "uml",
  uptimed => "uptime",
  usbguard => "usbguard",
  usbmuxd => "usbmuxd",
  usermode => "userhelper",
  uucp => "uucp",
  uuid-runtime => "uuid",
  varnish => "varnishd",
  vbetool => "vbetool",
  spice-vdagent => "vdagent",
  libvirt-daemon => "virt",
  libvirt-daemon-log => "virt",
  vlock => "vlock",
  vnstat => "vnstatd",
  vpnc => "vpn",
  openconnect => "vpn",
  watchdog => "watchdog",
  kwin-wayland => "wayland,wm",
  kwin-x11 => "wayland,wm",
  weston => "wayland,wm",
  xwayland => "wayland,wm",
  gnomoe-shell => "wayland,wm",
  openbox => "wayland,wm",
  metacity => "wayland,wm",
  mutter => "wayland,wm",
  phosh => "wayland,wm",
  twm => "wayland,wm",
  webalizer => "webalizer",
  awffull => "webalizer",
  wine-common => "wine",
  wireplumber => "wireplumber",
  wireshark => "wireshark",
  libkscreenlocker6 => "xscreensaver",
  gdm3 => "xserver",
  sdm => "xserver",
  lxdm => "xserver",
  lightdm-greeter => "xserver",
  xauth => "xserver",
  audispd-plugins => "zosremote"
};
