<commit_before>from inaugurator import partitiontable
from inaugurator import targetdevice
from inaugurator import mount
from inaugurator import sh
from inaugurator import network
from inaugurator import loadkernel
from inaugurator import fstab
from inaugurator import passwd
from inaugurator import osmosis
from inaugurator import checkinwithserver
from inaugurator import grub
from inaugurator import diskonkey
import argparse
import traceback
import pdb
import os
import time


def main(args):
    before = time.time()
    targetDevice = targetdevice.TargetDevice.device()
    partitionTable = partitiontable.PartitionTable(targetDevice)
    if args.inauguratorClearDisk:
        partitionTable.clear()
    partitionTable.verify()
    print "Partitions created"
    mountOp = mount.Mount(targetDevice)
    checkIn = None
    with mountOp.mountRoot() as destination:
        if args.inauguratorSource == 'network':
            network.Network(
                macAddress=args.inauguratorUseNICWithMAC, ipAddress=args.inauguratorIPAddress,
                netmask=args.inauguratorNetmask, gateway=args.inauguratorGateway)
            osmos = osmosis.Osmosis(
                destination, objectStores=args.inauguratorOsmosisObjectStores,
                withLocalObjectStore=args.inauguratorWithLocalObjectStore)
            if args.inauguratorServerHostname:
                checkIn = checkinwithserver.CheckInWithServer(hostname=args.inauguratorServerHostname)
                osmos.tellLabel(checkIn.label())
            else:
                osmos.tellLabel(args.inauguratorNetworkLabel)
            osmos.wait()
        elif args.inauguratorSource == 'DOK':
            dok = diskonkey.DiskOnKey()
            with dok.mount() as source:
                osmos = osmosis.Osmosis(
                    destination, objectStores=source + "/osmosisobjectstore",
                    withLocalObjectStore=args.inauguratorWithLocalObjectStore)
                with open("%s/inaugurate_label.txt" % source) as f:
                    label = f.read().strip()
                osmos.tellLabel(label)
                osmos.wait()
        else:
            assert False, "Unknown source %s" % args.inauguratorSource
        print "Osmosis complete"
        with mountOp.mountBoot() as bootDestination:
            sh.run("rsync -rlpgDS %s/boot/ %s/" % (destination, bootDestination))
        with mountOp.mountBootInsideRoot():
            print "Installing grub"
            grub.install(targetDevice, destination)
        print "Boot sync complete"
        fstab.createFSTab(
            rootPath=destination, root=mountOp.rootPartition(),
            boot=mountOp.bootPartition(), swap=mountOp.swapPartition())
        print "/etc/fstab created"
        if args.inauguratorChangeRootPassword:
            passwd.setRootPassword(destination, args.inauguratorChangeRootPassword)
            print "Changed root password"
        loadKernel = loadkernel.LoadKernel()
        loadKernel.fromBootPartitionGrubConfig(
            bootPath=os.path.join(destination, "boot"), rootPartition=mountOp.rootPartition(),
            append=args.inauguratorPassthrough)
        print "kernel loaded"
    print "sync..."
    sh.run(["busybox", "sync"])
    print "sync done"
    after = time.time()
    if checkIn is not None:
        checkIn.done()<commit_msg>Bugfix: /boot was not cleaned up, filled up eventually (thanks maor)<commit_after>from inaugurator import partitiontable
from inaugurator import targetdevice
from inaugurator import mount
from inaugurator import sh
from inaugurator import network
from inaugurator import loadkernel
from inaugurator import fstab
from inaugurator import passwd
from inaugurator import osmosis
from inaugurator import checkinwithserver
from inaugurator import grub
from inaugurator import diskonkey
import argparse
import traceback
import pdb
import os
import time


def main(args):
    before = time.time()
    targetDevice = targetdevice.TargetDevice.device()
    partitionTable = partitiontable.PartitionTable(targetDevice)
    if args.inauguratorClearDisk:
        partitionTable.clear()
    partitionTable.verify()
    print "Partitions created"
    mountOp = mount.Mount(targetDevice)
    checkIn = None
    with mountOp.mountRoot() as destination:
        if args.inauguratorSource == 'network':
            network.Network(
                macAddress=args.inauguratorUseNICWithMAC, ipAddress=args.inauguratorIPAddress,
                netmask=args.inauguratorNetmask, gateway=args.inauguratorGateway)
            osmos = osmosis.Osmosis(
                destination, objectStores=args.inauguratorOsmosisObjectStores,
                withLocalObjectStore=args.inauguratorWithLocalObjectStore)
            if args.inauguratorServerHostname:
                checkIn = checkinwithserver.CheckInWithServer(hostname=args.inauguratorServerHostname)
                osmos.tellLabel(checkIn.label())
            else:
                osmos.tellLabel(args.inauguratorNetworkLabel)
            osmos.wait()
        elif args.inauguratorSource == 'DOK':
            dok = diskonkey.DiskOnKey()
            with dok.mount() as source:
                osmos = osmosis.Osmosis(
                    destination, objectStores=source + "/osmosisobjectstore",
                    withLocalObjectStore=args.inauguratorWithLocalObjectStore)
                with open("%s/inaugurate_label.txt" % source) as f:
                    label = f.read().strip()
                osmos.tellLabel(label)
                osmos.wait()
        else:
            assert False, "Unknown source %s" % args.inauguratorSource
        print "Osmosis complete"
        with mountOp.mountBoot() as bootDestination:
            sh.run("rsync -rlpgDS --delete-before %s/boot/ %s/" % (destination, bootDestination))
        with mountOp.mountBootInsideRoot():
            print "Installing grub"
            grub.install(targetDevice, destination)
        print "Boot sync complete"
        fstab.createFSTab(
            rootPath=destination, root=mountOp.rootPartition(),
            boot=mountOp.bootPartition(), swap=mountOp.swapPartition())
        print "/etc/fstab created"
        if args.inauguratorChangeRootPassword:
            passwd.setRootPassword(destination, args.inauguratorChangeRootPassword)
            print "Changed root password"
        loadKernel = loadkernel.LoadKernel()
        loadKernel.fromBootPartitionGrubConfig(
            bootPath=os.path.join(destination, "boot"), rootPartition=mountOp.rootPartition(),
            append=args.inauguratorPassthrough)
        print "kernel loaded"
    print "sync..."
    sh.run(["busybox", "sync"])
    print "sync done"
    after = time.time()
    if checkIn is not None:
        checkIn.done()
{'fraction_non_alphanumeric': 0.07850688786846394, 'fraction_numerical': 0.0, 'mean_word_length': 2.713971397139714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1026735', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1812, 'n_words': 406}