summaryrefslogtreecommitdiff
path: root/src/xib.pl
blob: 74ea8b76918e5de9ba30c6c0b21533069e3fe144 (plain)
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
#!/usr/bin/env perl

# TODO for building the whole system
# We first need to have a base system that we can build from
#   (up to chapter 6 in lfs book, done by make_tools.sh)
# packages need to be build in order of importance
# need to some how find out which packages are the most important and build and install them to the chroot first
# build a package, install it if necessary
# copy the generated package/info to a safe place
# sign the package
# put the package in the export folder

# TODO for building a single package:
# do all the preliminary checks (exists, deps are installed, etc)
# download source to $chroot/source
# download additional tools 
# copy xibuild to the chroot
# create a "build.sh" script in the chroot
# - run the 3 stages of package building
# - create the pacakage in $chroot/$name.xipkg
# - add some info to package info
# - if requested, install to the chroot

use strict;
use warnings;
use Getopt::Long "HelpMessage";

use File::Basename;
use lib dirname (__FILE__);
use BuildOrder "determine_build_order";

our $BUILDFILES_REPO = "https://xi.davidovski.xyz/git/buildfiles.git";

GetOptions(
        "chroot:s" => \(our $chroot = "/var/lib/xib/chroot"),
        "buildfiles" => \(our $buildfiles = "/var/lib/xib/buildfiles"),
        "export:s" => \(our $export = "/var/lib/xib/export"),
) or HelpMessage(1);

sub prepare_xib_environment{
    die "chroot environment at $chroot doesn't yet exist\n" unless ( -e $chroot);
    
    if (!-d $export) {
        mkdir($export);
    }

    pull_buildfiles();
}

sub pull_buildfiles{
    if (-d $buildfiles) {
        system("cd $buildfiles && git pull");
    } else {
        system("git clone $BUILDFILES_REPO $buildfiles");
    }
} 


unless (caller) {
    prepare_xib_environment();
    my $file = "$chroot/buildorder";
    BuildOrder::determine_build_order($file);
}