Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial OpenWrt setup #934

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Initial OpenWrt setup #934

wants to merge 6 commits into from

Conversation

ndren
Copy link

@ndren ndren commented May 17, 2023

This is an attempt to get set up for OpenWrt builds for GSoC 2023.

The code and comments are mostly unnecessary (noop) at the moment and the plan is to work on them to get a clean setup working. Currently I'd like to know if the code design is accurate. For example, is running make download a reasonable approach to getting build dependencies installed? (It is the official way to do this under OpenWrt, and does not compile anything, only downloads files.)

@ndren
Copy link
Author

ndren commented May 17, 2023

More details on this issue: openSUSE/open-build-service#10228

@ndren ndren marked this pull request as ready for review May 26, 2023 16:49
@ndren
Copy link
Author

ndren commented May 26, 2023

This PR is ready for review, let me know what you think. Thanks!

Comment on lines +28 to +81
my $yamlxs = eval { require YAML::XS; $YAML::XS::LoadBlessed = 0; return 1 };
my $yamlpp = eval { require YAML::PP; return YAML::PP->new };

sub _have_yaml_parser {
return $yamlpp || $yamlxs ? 1 : undef;
}

sub _load_yaml {
my ($yaml) = @_;
my $data;
if ($yamlpp) {
$data = eval { $yamlpp->load_string($yaml) };
return $data;
}
if ($yamlxs) {
eval { $data = YAML::XS::Load($yaml) };
return $data;
}
die "Neither YAML::PP nor YAML::XS available\n";
}

sub _load_yaml_file {
my ($fn) = @_;
my $data;
if ($yamlpp) {
$data = eval { $yamlpp->load_file($fn) };
return $data;
}
if ($yamlxs) {
eval { $data = YAML::XS::LoadFile($fn) };
return $data;
}
die "Neither YAML::PP nor YAML::XS available\n";
}

sub _read_manifest {
my ($fn) = @_;
my $data;
if ($fn =~ m/\.ya?ml\z/) {
$data = _load_yaml_file($fn);
return { error => "Failed to parse YAML file '$fn'" } unless defined $data;
} elsif ($fn =~ m/\.json\z/) {
# We don't have JSON::PP, but YAML is a superset of JSON anyway
$data = _load_yaml_file($fn);
return { error => "Failed to parse JSON file '$fn'" } unless defined $data;
} elsif (ref($fn) eq 'SCALAR') {
$data = _load_yaml($$fn); # used in the unit test
return { error => "Failed to parse '$fn'" } unless defined $data;
} else {
$data = _load_yaml_file($fn);
return { error => "Failed to parse file '$fn'" } unless defined $data;
}
return $data;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty certain you don't need this part, or at least not all of it. You should be fine with a json parser.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I wasn't sure whether a JSON parser was present inside the build system. I saw https://github.com/openSUSE/obs-build/blob/master/Build/SimpleJSON.pm but wasn't sure if that would work, and couldn't verify whether https://metacpan.org/dist/JSON was preinstalled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nice part about this method is that it keeps yaml parsing available if someone (or something, e.g. a buildsystem) prefers YAML.

Comment on lines 5 to 7
# Adapted from Flatpak specific functions, see details below.
#
# Author: Tina Müller <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to change this part, at least the author is incorrect ;-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let me know if this works.



# Download the dependencies
chroot "$BUILD_ROOT" /bin/bash -c "cd sdk && make download V=s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail on OBS where networking is disabled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I will remove this (it turns out to be unnecessary). This also means that I cannot do git clones, but this basically means I will need to do a fake git clone from directory (git clone SOURCEDIR TARGETDIR style)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still wondering what I need to do about build-time dependencies (make package/$NAME/download), do I assume those are passed in as build inputs somehow?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently thinking of maybe having a list of git repos that are copied in that are comitted in the source build tree, though I'm not sure how that interacts with package/$NAME/download.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question -- do you know if I'm able to use https://github.com/openSUSE/obs-build/blob/master/PBuild/RemoteAssets.pm before building?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depends, pbuild is executing it always.

For OBS scenarios the "download_asset" service would need to get enabled for that package or project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding dependencies, you may define a default as build-packages:openwrt in Build.pm in %subst_defaults.

This would require these packages by default (but can be overwritten by the user).

You may also define an openwrt config file where you define default repository/ies via RepoURL: tag

@@ -0,0 +1,150 @@
################################################################
#
# Copyright (c) 2017 SUSE Linux Products GmbH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are of course allowed to use/add your name here ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants