def shouldRebuildDB(pkgdbpath):
    receiptsdir = "/Library/Receipts"
    bomsdir = "/Library/Receipts/boms"
    sl_receiptsdir = "/private/var/db/receipts"
    installhistory = "/Library/Receipts/InstallHistory.plist"
    applepkgdb = "/Library/Receipts/db/a.receiptdb"

    if not os.path.exists(pkgdbpath):
        return True

    packagedb_modtime = os.stat(pkgdbpath).st_mtime

    if os.path.exists(receiptsdir):
        receiptsdir_modtime = os.stat(receiptsdir).st_mtime
        if packagedb_modtime < receiptsdir_modtime:
            return True
        receiptlist = munkicommon.listdir(receiptsdir)
        for item in receiptlist:
            if item.endswith(".pkg"):
                pkgpath = os.path.join(receiptsdir, item)
                pkg_modtime = os.stat(pkgpath).st_mtime
                if packagedb_modtime < pkg_modtime:
                    return True

    if os.path.exists(bomsdir):
        bomsdir_modtime = os.stat(bomsdir).st_mtime
        if packagedb_modtime < bomsdir_modtime:
            return True
        bomlist = munkicommon.listdir(bomsdir)
        for item in bomlist:
            if item.endswith(".bom"):
                bompath = os.path.join(bomsdir, item)
                bom_modtime = os.stat(bompath).st_mtime
                if packagedb_modtime < bom_modtime:
                    return True

    if os.path.exists(sl_receiptsdir):
        receiptsdir_modtime = os.stat(sl_receiptsdir).st_mtime
        if packagedb_modtime < receiptsdir_modtime:
            return True
        receiptlist = munkicommon.listdir(sl_receiptsdir)
        for item in receiptlist:
            if item.endswith(".bom") or item.endswith(".plist"):
                pkgpath = os.path.join(sl_receiptsdir, item)
                pkg_modtime = os.stat(pkgpath).st_mtime
                if packagedb_modtime < pkg_modtime:
                    return True

    if os.path.exists(installhistory):
        installhistory_modtime = os.stat(installhistory).st_mtime
        if packagedb_modtime < installhistory_modtime:
            return True

    if os.path.exists(applepkgdb):
        applepkgdb_modtime = os.stat(applepkgdb).st_mtime
        if packagedb_modtime < applepkgdb_modtime:
            return True

    # if we got this far, we don't need to update the db
    return False
Checks to see if our internal package DB should be rebuilt.
dataset/ETHPy150Open munki/munki/code/client/munkilib/removepackages.py/shouldRebuildDB