From a6047a655be6b469c4adbd81c499be18bd164422 Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 28 Jan 2022 12:34:30 +0000 Subject: added buildpackage --- src/BuildPackage.pm | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/xib.pl | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100755 src/BuildPackage.pm (limited to 'src') diff --git a/src/BuildPackage.pm b/src/BuildPackage.pm new file mode 100755 index 0000000..afcb65a --- /dev/null +++ b/src/BuildPackage.pm @@ -0,0 +1,78 @@ +package BuildPackage; + +use strict; +use warnings; + +use File::Basename "basename"; +use Digest::MD5; + +sub md5_sum{ + my ($file) = @_; + + open(my $fh, "<", $file) or die "Cannot open $file: $!"; + binmode($fh); + + return Digest::MD5->new->addfile($fh)->hexdigest; +} + +sub extract_ver_hash{ + my $info_file = $_; + open (my $fh, "<", $info_file) or warn "Cannot open $info_file"; + while (my $line = <$fh>) { + if ($line =~ /^VER_HASH=(.+)$/) { + return $1; + } + } +} +sub extract_ver_hash{ + my $info_file = $_; + open (my $fh, "<", $info_file) or warn "Cannot open $info_file"; + while (my $line = <$fh>) { + if ($line =~ /^VER_HASH=(.+)$/) { + return $1; + } + } +} + +sub get_built_version{ + my ($build_file) = @_; + my @package_split = split(/\//, $build_file); + my $repo = $package_split[-2]; + my $name = basename($build_file, ".xibuild"); + my $dest = "$main::export/repo/$repo/$name"; + + my $pkg = "$dest.xipkg"; + my $info = "$dest.xipkg.info"; + my $used_build = "$dest.xibuild"; + + if (-e $pkg && -e $info) { + return md5_sum($used_build); + } +} + +sub clear_build_folder{ + rmtree("$main::chroot/build"); +} + +sub fetch_source{ + my $source_url = $_; + + mkdir("$main::chroot/build") + mkdir("$main::chroot/build/source") + + # download source to $chroot/build/mysource.tgz + # extract source to $chroot/build/source +} + +sub build_package{ + my ($build_file) = @_; + + $existing_version = get_built_version($build_file); + if (defined($existing_version) && $existing_version eq md5_sum($build_file)) { + # do not build + return + } + # build + + +} diff --git a/src/xib.pl b/src/xib.pl index 74ea8b7..ba3afc9 100755 --- a/src/xib.pl +++ b/src/xib.pl @@ -28,6 +28,7 @@ use Getopt::Long "HelpMessage"; use File::Basename; use lib dirname (__FILE__); use BuildOrder "determine_build_order"; +use BuildPackage; our $BUILDFILES_REPO = "https://xi.davidovski.xyz/git/buildfiles.git"; @@ -55,7 +56,6 @@ sub pull_buildfiles{ } } - unless (caller) { prepare_xib_environment(); my $file = "$chroot/buildorder"; -- cgit v1.2.1