-
Notifications
You must be signed in to change notification settings - Fork 187
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
base: master
Are you sure you want to change the base?
Conversation
More details on this issue: openSUSE/open-build-service#10228 |
This PR is ready for review, let me know what you think. Thanks! |
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; | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
build-recipe-openwrt
Outdated
# Adapted from Flatpak specific functions, see details below. | ||
# | ||
# Author: Tina Müller <[email protected]> |
There was a problem hiding this comment.
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 ;-)
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ;)
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.)