Commit graph

224 commits

Author SHA1 Message Date
G Derber
f7761fd635
Add ability to differentiate group ownership from user ownership. 2024-08-06 09:38:25 -04:00
Jools Wills
d6775d40fe packages - fix install of modules with nonet flag when not connected
This allows updating/reinstalling of modules with the nonet flag set (retropiemenu and runcommand) when no internet connection is available.

Incorrect variable was used in comparison ($id instead of $md_id), so the has_net wasn't forced to 1.
2024-07-16 23:28:49 +01:00
Jools Wills
781618e6cc packages - allow enabling/disabling a module with comparison flags
rp_module_flags can now contain a variable comparison to enable or disable a scriptmodule.
The comparison should be in the format :\$var:cmp:val or !:\$var:cmp:val

eg. :\$__gcc_version:-lt:7 would be evaluated as [[ $__gcc_version -lt 7 ]]

This would enable a module if the comparison was true or disable if !:\$__gcc_version:-lt:7 was used.
Only global variables set before modules are loaded (eg via system.sh) are supported.

$ is escaped so variables are not evaluated when the module is sourced.
It works without, but provides less useful information in the setup menus as the variable name will not be visible.
2024-05-21 21:20:22 +01:00
Jools Wills
cf0e098106 Set distcc variables at the scriptmodule function calling stage
Only configure distcc variables if a module does not have the "nodistcc" flag.

Skip builder/setup modules to avoid having distcc changes propagate to modules built from them.

This allows easily disabling distcc for certain modules that are not compatible.
2024-04-17 00:54:32 +01:00
s1eve-mcdichae1
4fa61189a8 packages.sh function rp_hasNewerModule() - allows variable-length repo_commit sha for comparison. Enforce a minimum of four characters. 2023-02-24 16:04:09 -08:00
cmitu
191485ae99 packages: amend update detection for untracked modules
Added a fallback for getting the `modified_date` of a module if the module's file is not tracked by `git`.
If the module is just copied in the `scriptmodules` folder or under `ext`, but not part of a `git` repo, use the modification date of the file.
This avoids re-building the module when a mass update is run.

Noticed this in [this forum topic](https://retropie.org.uk/forum/topic/33922/need-help-with-openbor-retropie-extra-exarkuniv/15), seems like [RetroPie-Extra](https://github.com/Exarkuniv/RetroPie-Extra) copies selected module files under `ext`, while the main repository folder is kept separately.
2023-02-22 17:13:58 +00:00
Jools Wills
1eedc5ad2c packages - fix update check due to security warning with git 2.34.1
As with e041a0c5 we need to use the same user for running git as the owner of the repository files.

This is also needed for an update check in rp_hasNewerModule as we check the last commit date of scriptmodules in RetroPie-Setup.
2022-05-13 16:17:40 +01:00
Jools Wills
01f7980c28 packages - follow redirects for curl remote package checks
This fixes setting package date for redream and not updating unless needed.

The download function already had the --location parameter, but the packaging
code for checking for a remote file / checking file date didn't.
2021-08-04 03:08:50 +01:00
Jools Wills
711e75b030 packages - work from commit date rather than authored date
This is used for our package information, although it's not used to check for newer versions
as we only check the remote hash of a git repository for updates.

We also used this for checking if we need to update a binary based on the last date of a change to the
module file. However as we were using author date, if a binary was built before the change was accepted, but
more recently than the change was authored, it wouldn't trigger a binary rebuild.

It makes more sense to use the date the commit was made rather than when it was authored in both cases, as
we want to know when something was last changed in the repository rather than the date of the change.
2021-07-31 07:30:20 +01:00
Jools Wills
90d0d80b7b packages - allow custom binary installs when we don't host binaries
Custom binary URLs provided by __binary_url_* scriptmodule functions were ignored for platforms
we don't host general binary builds for. This meant that lr-duckstation wouldn't show binary
install options on aarch64 / x86_64.

Moved the rp_hasBinaries check logic to rp_getBinaryUrl, so we only set a URL by default when
we have binaries for that system. This is overridden as needed by install_bin_* / __binary_url_*
scriptmodule functions. The rp_hasBinary function will check for a binary if the URL is set, so
we allow overriding of our own binaries, as well as having the ability to install 3rd party binaries
for systems we don't host binaries for.
2021-06-13 02:51:43 +01:00
Jools Wills
10b2e05f69 packages - use last commit date rather than file date for checking module modifications
rp_hasNewerModule will force a rebuild if the module was updated since it was installed. This was added to
handle cases where we update patches or build parameters in module. Using the last commit date is more reliable
as module dates can be changed when rebasing etc. This resolves some issues with the builder module rebuilding
binaries when not needed, due to branch switches / rebases.
2021-06-10 03:29:02 +01:00
Jools Wills
2b6bde72a6 packages - added md_licence variable for module use
md_licence contains the rp_module_licence string for the module
2021-05-11 02:44:25 +01:00
Jools Wills
43e9d5532f Rework the checks and error messages displayed on network error
Create a new function isConnected in helpers.sh which calls getIPAddress, but also sets a new global
__NET_ERRMSG if not connected. This is used in setup.sh and packages.sh so we don't duplicate the same
message between files.

Split out a new function runCurl from the download function, to do lower level curl calls, but capture any
errors into __NET_ERRMSG for display in setup.sh or via the packaging functions. Use a connect timeout of 10
in the download function rather than 60 which is quite long, but keep the 60 second limit on no data transfer.

Adjust rp_remoteFileExists to use runCurl, so we can capture any error when checking a remote file,
and use this value for display in setup and in logs etc. Switch to using long versions of curl options for
readability, and add --show-error so we still output errors when being silent.

Also switch rp_getFileDate to use new runCurl function, so that any curl argument overrides are handled, and use
long format parameters also. No error handling is done here though.
2021-03-02 05:52:34 +00:00
Jools Wills
cdee38f135 packages - fix subversion version checks
Use "Last Changed Rev:" rather than "Revision:" as we want the last revision for the URL/branch/tag
rather than the last revision for the repository.

Don't just compare commits if the commit is HEAD (used for svn repos) as it's not a static commit but
references the latest commit.
2021-03-02 03:06:16 +00:00
Jools Wills
9b3371e800 builder - only build binaries when newer
Copy retropie.pkg to archive folder named as $md_id.pkg and use this in rp_hasNewerModule if no installed
package is found. Adjust the builder code to check for a newer source package to utilise this so we only
rebuild binaries as are needed.
2021-03-01 23:08:53 +00:00
Jools Wills
8fb0ad61b7 packages - increase curl timeout for remote file exists check to 10 seconds
Some users reported issues and it was taking between 5 and 6 seconds - which points to an connectivity issue
really, as it's a small HEAD request. However increasing the timeout will help for these users.

This is a quick fix, as I will look into improving the error msgs also.
2021-03-01 17:58:34 +00:00
Jools Wills
2a3cbf9497 packages - cosmetic, the, not the the 2021-02-24 19:37:11 +00:00
Jools Wills
b3a73c097b
Merge pull request #3315 from joolswills/repo_tag_ref_check_fix
packages - handle git repositories with two tag references
2021-02-24 16:47:50 +00:00
Jools Wills
4a285bb1c2 packages - handle git repositories with two tag references
When the remote repository uses an annotated Git tag, the real commit is found
by looking for the "tag^{}" reference, since the the tag ref will point to the
tag object itself, instead of the tagged commit. See gitrevisions(7).
2021-02-24 16:46:32 +00:00
Jools Wills
ff9bdad6cc system / packages - allow bypassing signing when creating binaries for testing
Also moved the retropie email used for checking to __gpg_retropie_key and use this rather than __gpg_signing_key
as we hardcode the install of the actual key - so the logic didn't make sense in the case of wanting to sign
with another key. But __gpg_signing_key can now be set to an empty string to bypass signing of binaries as used
by the build scripts. This is only useful for developers/testing binary creation on systems without our signing key.
2021-02-22 02:36:17 +00:00
Jools Wills
f157793263 packages - add some output when checking for updates
Useful for logging, and if lots of modules are installed but are all up to date it is useful to see
some progress.
2021-02-15 23:54:13 +00:00
Jools Wills
927b9922df setup / packages - fix up installing retropiemenu / runcommand without a network connection
The previous changes to check for an internet connection to avoid showing options to update failed
with these modules as they have install_bin functions which are handled by rp_hasBinary but don't
require an internet connection.

To workaround this, I have added a "nonet" flag, which if set, will force has_net to 1 in setup and packages
so the install options will show, and they can be removed and reinstalled even if no network connection is available.

runcommand can still fail due to not being able to install mesa-drm - which will be reported, but it's safer to allow
the main runcommand to be installed even without mesa-drm in case of accidental removal.
2021-02-15 23:54:13 +00:00
Jools Wills
2c0f618198 packages - fix issue with previously set pkg_origin
Reworked rp_loadPackageInfo to clear package information in __mod_info and defaulting pkg_origin to "unknown".
The pkg_origin was set on module load before, but this isn't enough as it was remembered when removing a package,
so wouldn't be set back to the default if no package information was found. This caused installing from a section
to install from the last pkg_origin rather than the default of "unknown" if installing a package that had been removed.

The default is best handled here also, so we have less related code in other functions.
2021-02-15 23:54:13 +00:00
Jools Wills
687a250187 packages / setup - quietly handle issues with unparseable dates 2021-02-15 23:54:13 +00:00
Jools Wills
587b96b777 packages - cache rp_hasBinary and rp_hasNewerModule results
Unless there is an error, cache the return result for rp_hasBinary and rp_hasNewerModule
and clear when running rp_setModuleInfo or removing a module.

Reworked the rp_hasNewerModule code to have a single return point to allow us to cache the result.

This speeds up navigating Setup menus.
2021-02-15 23:54:13 +00:00
Jools Wills
ed20022055 packages / setup - rework logic to handle cases where there is no internet connection 2021-02-15 23:54:13 +00:00
Jools Wills
e41558200e packages - fix logic for when a module is using an 8 character commit hash
If a module chooses a specific commit via rp_module_repo (directly or via a hook) using the first 8
characters of the git hash, only compare against the first 8 characters of our installed package hash.

This should fix any cases where an older commit is used for a module, but would not match, so a git ls-remote
would be called, which would get the last commit, and an update would be forced when not needed.
2021-02-15 23:54:13 +00:00
Jools Wills
f2555854c9 packages - add support for module handling of rp_module_repo via hook as first parameter
If the first parameter of rp_module_repo starts with a : it the following function will be called
when setting package information during source install, and when checking for a new source version.

The function takes the parameters "get" and "check".

"get" - should return code to set any packaging variables needed for the module hook later.

The pkg_repo_extra field has been added specifically for modules to store something different from the
standard fields also

"newer" will be called with pkg_repo_* vars set, and can be used by the function hook to determine if
a new version is available. If so, the function should return 0, or 1 if no update is required.

I also split off checking remote repo hash/commit to separate function and fix up an issue with checking
remote git hash, as previously a branch or tag could have multiple matches - we now specifically grep
the results for ref/heads and ref/tags
2021-02-15 23:54:13 +00:00
Jools Wills
25573f57d9 packages / helpers - record git checkout dir in gitPullOrClone for use in rp_setPackageInfo 2021-02-15 23:54:13 +00:00
Jools Wills
272777bb36 packages / helpers - allow rp_module_repo to have function hooks as parameters
rp_module_repo is currently in the format

TYPE URL BRANCH COMMIT

where type is file, git or svn

If rp_module_repo URL BRANCH or COMMIT starts with a : the rest is considered to be a function that
will return the URL, BRANCH, or COMMIT via an echo. This allows for using of the new rp_module_repo
by modules that use some logic to determine what branch / commit is used.

eg. Some modules will use an older branch based on the system they are running on.

These variables are resolved before use, as some modules query the net for information, so we only
want to check these just before they are used.
2021-02-15 23:54:13 +00:00
Jools Wills
c4e6d77727 packages - force update for source if module date is newer then install date
With binaries, if we update a scriptmodule, we can rebuild or update the date on the binaries to force
an update. However, with the source installs, if the remote repository is not updated, an update won't
happen until it does. This could be an issue in a situation where we notice a bug in the module. In this
case we check if the module date is newer than the install date - and if so, we force an update.
2021-02-15 23:54:13 +00:00
Jools Wills
a07d8ed569 packages / setup - re-implement rp_getPackageInfo as rp_loadPackageInfo
Previously we eval's the return of getPackageInfo so the package variables could be created
locally to the function. However, due to the use of a subshell we couldn't cache anything in a variable
for use later.

The functions is now renamed to rp_loadPackageInfo and loads the package information into __mod_info[ID/FIELD]

eg. __mod_info[ID/pkg_origin] will contain the retropie.pkg origin field for the installed module

It also uses just grep to load the data rather than our existing ini functions for performance. As it's not
considered a user editable file, performance is key here, as we need this data when traversing the
RetroPie-Setup menus.

If a full load of a retropie.pkg is done, __mod_info[ID/pkg_info] is set to 1, as a cache flag so the data can be
reused without reloading on an additional call. rp_SetPackageInfo will clear this flag

Optional parameters for rp_loadPackageInfo can choose individual fields but if used the data won't be
cached, but it can be a lot faster - we use this to grab pkg_origin for the section menus in RetroPie-Setup.
2021-02-15 23:54:13 +00:00
Jools Wills
ac5da4ecca packages - split off md_* vars setting to function
This allows it to be used manually for loading module variables - eg in administration scripts
2021-02-15 23:54:13 +00:00
Jools Wills
b79ad04667 packages - add support for basic source versioning
These changes allow storing of source repo information in retropie.pkg as well as the ability
to check for a new version. To do this, repository information needs to be moved to the variable
md_module_repo in the format

md_module_repo="TYPE URL BRANCH COMMIT"

Currently types of file, git, or svn are suppported.

If using file the BRANCH and COMMIT are not used.
If using svn the BRANCH should be - and the COMMIT is the SVN revision.

This information is split up and provided to the module in the form of

md_repo_type
md_repo_url
md_repo_branch
md_repo_commit
2021-02-15 23:54:13 +00:00
Jools Wills
fcb80cbe2c packages - fix md_build cleaning logic when __persistent_repos is set
Previously if set and if md_build contained a git repository, it would reset it, to undo any patches we
may have so they get reapplied after next git update. However, if there wasn't a .git folder in md_build it would
still remove the folder, rather than leave it behind. Adjusted the logic to fix this, but this code is very old
and was a quick "hack" so needs revisiting with upcoming packaging changes.
2021-02-14 03:12:03 +00:00
Jools Wills
4fc2e4ee9e packages - only do an additional check on module ids on 3rd party repos
Doing an additional grep on every module to check if it duplicated an additional module_id, added
more overhead than was ideal. However we can just do the check on 3rd party repos, which brings performance
back to how it was pretty much, and will have a slight overhead if a user has a 3rd party repo added
2021-02-08 01:35:35 +00:00
Jools Wills
968df7e453 packages - only run _update_hooks for modules that are enabled for the current system 2021-02-02 05:42:54 +00:00
Jools Wills
f6c01bad67 packages - use id instead of mod_id for consistency with other functions
Some of these old functions will be reworked in the future with some planned packaging improvements
2021-02-02 05:40:54 +00:00
Jools Wills
23047ac145 packages - some var declaration cleanups / fixes 2021-02-02 04:20:11 +00:00
Jools Wills
d3516ce272 packages - use iso-8601 date format for packages
although it works as it is currently due to the flexibility of the unix "date" command, we should
standardise dates so we don't end up with different formats in the configs depending on webserver output etc.
2021-02-01 03:27:30 +00:00
Jools Wills
1f84556f96 packages - fix CR line end character in retropie.pkg date for binaries
Curl headers outputs as CRLF rather than LF. Remove styled output from curl (as a precaution), and
strip CR's via tr before piping to grep, but also just use grep for processing via perl regexp (-P).
2021-02-01 02:19:55 +00:00
Jools Wills
da34399ea4 packages - fix md_data path for 3rd party repos 2021-01-31 22:17:26 +00:00
Jools Wills
f2e2422566 packages / setup - make sure module ids are unique
Do a grep to extract the rp_module_id before sourcing a file and check if it has already been used.
We don't want additional modules overriding existing, or accidental duplication.

Store the path of a module in __mod_info(ID/path)

Display any info/error messages when launching setup as otherwise they wouldn't be seen - they are
shown otherwise at the end of retropie_packages.sh.
2021-01-27 04:47:30 +00:00
Jools Wills
8fe4d254e8 packages / setup - add vendor to module info and display in setup
Used to separate 3rd party packages from RetroPie ones. Added some extra menu items in setup showing
above each type like a heading with

---- VENDOR - TYPE ----

Where:
 * VENDOR is RetroPie or the name of the folder the 3rd party repo is installed in
 * TYPE is the module/package type such as emulator, libretrocore, port etc

Some users have found the ordering of the menus confusing and this should help with that also.

3rd party packages always appear at the end of a section
2021-01-26 03:00:15 +00:00
Jools Wills
48080d2d13 packages - allow adding of 3rd party module repos
3rd party repositories can be checked out to RetroPie-Setup/ext

Repositories should be structured so you have:

ext/REPOSITORY/scriptmodules

Modules are only read from the following subfolders of scriptmodules
 * emulators
 * libretrocores
 * ports
 * supplementary
 * admin
2021-01-26 02:15:01 +00:00
Jools Wills
c4527d433b packages - don't fail to load modules if installed in a path containing a space 2021-01-26 02:08:09 +00:00
Jools Wills
23c4f72303
Revert "packages - allow adding of 3rd party module repos" 2021-01-26 00:52:27 +00:00
Jools Wills
f421c7dbab
Merge pull request #3296 from joolswills/module_info_merge_arrays
Merge module arrays and include all modules in setup
2021-01-26 00:41:36 +00:00
Jools Wills
55071ecf9e packages - allow adding of 3rd party module repos
3rd party repositories can be checked out to RetroPie-Setup/ext

Repositories should be structured so you have:

ext/REPOSITORY/scriptmodules

Modules are only read from the following subfolders of scriptmodules
 * emulators
 * libretrocores
 * ports
 * supplementary
 * admin
2021-01-25 23:59:59 +00:00
Jools Wills
a98c59597f packages / setup - show all modules and if they are not enabled for a system
Previously, allthough all modules were read in, we only displayed modules that were enabled for
the current system. This has caused some confusion in the past with people installing RetroPie on another
system and wondering where a package is.

Now all packages are shown via retropie_packages.sh and in setup menus with information if they are
not enabled for the current system.
2021-01-23 03:27:17 +00:00