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

Download sources during installation and upgrade to 1.0.36 #38

Merged
merged 4 commits into from Jan 17, 2017

Conversation

JimboJoe
Copy link
Contributor

No description provided.

@JimboJoe JimboJoe changed the title Download sources during installation and upgrade to 1.0.35 Download sources during installation and upgrade to 1.0.36 Jan 2, 2017
@JimboJoe
Copy link
Contributor Author

JimboJoe commented Jan 2, 2017

Finally implemented dependencies download during install/upgrade with composer
Upgraded upstream version to 1.0.36

Copy link
Contributor

@mbugeia mbugeia left a comment

Choose a reason for hiding this comment

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

Hi, thank you for the package update, I've put my remarks but didn't test the package yet. Other thing LGTM.

In a more general notice while managing the dependency throught composer seems a good idea it not always the case. Composer take a lot (and I mean a lot) of RAM during install so the kanboard install will probably fail on small hardware. Related bug: https://dev.yunohost.org/issues/363 (plus there is a bunch of open bug for failed roundcube install because of this).
Did you notice that the link https://kanboard.net/kanboard-latest.zip always contain dependency while the github one don't ? Maybe it would be better to use this link and don't install composer at all. But I don't like that we can't point a specific version :/

# Uncompress
sudo unzip -qq kanboard.zip -d ..
# Create tmp directory and install app inside
TMPDIR=$(ynh_mkdir_tmp)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is deprecated, use mktemp since it's bash native.

sudo sudo -u "$USER" $@
fi
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This is so over-engineered IMO. This complicate the script for exactly no gain, the whole script is run as "admin" user by YunoHost and this is used only to run thing as admin. Plus I don't think apps script should contain such generic helper, if one is really needed it should be in yunohost core.

exec_composer() {
local AS_USER=$1
local WORKDIR=$2
shift 2
Copy link
Contributor

Choose a reason for hiding this comment

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

shift is useless here

# update dependencies to create composer.lock
exec_composer "$AS_USER" "$DESTDIR" install --no-dev \
|| ynh_die "Unable to update application core dependencies"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think exec_composer and init_composer function should be merged since:

  • they are never called independently
  • they can be simplified by removing all the exec_as thing

local AS_USER=${2:-admin}

# install composer
curl -sS https://getcomposer.org/installer \
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not the best way to install composer, the composer website provide a way more secure script here: https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md

@JimboJoe
Copy link
Contributor Author

JimboJoe commented Jan 3, 2017

Thanks for taking time to review the PR!
I took the roundcube app as a reference, which obviously seems like a bad idea... We clearly don't want to restrict hardware targets if we can avoid doing that.
You had a good idea to check the kanboard-latest.zip for dependencies... I blindly checked that URL: https://kanboard.net/kanboard-1.0.36.zip
And bingo! Dependencies are there!
I'll update the PR to revert to the first commit, updating to that link.

@mbugeia
Copy link
Contributor

mbugeia commented Jan 4, 2017

Cool, I didn't know it worked. Using the zip of kanboard.net with the dependencies was the way I updated the package before (as noted is the readme).
I look forward to your update, fetching the source and using a common script are good practices :)

@JimboJoe
Copy link
Contributor Author

JimboJoe commented Jan 4, 2017

Just did another commit: now downloading Kanboard sources from kanboard.net website, avoiding the need to use composer.

Copy link
Contributor

@mbugeia mbugeia left a comment

Choose a reason for hiding this comment

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

Thanks again!

wget -q -O "$archive" "$APPLICATION_SOURCE_URL" \
|| ynh_die "Unable to download application archive"
# Here we process with unzip as would tar "--strip-component" option
unzip -qq "$archive" -d "$DESTDIR" && rm "$archive" && f=("$DESTDIR"/*) && mv "$DESTDIR"/*/* "$DESTDIR" && rm -f "${f[@]}"/.htaccess && rmdir "${f[@]}" \
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow! Why is this needed? I remember having to deal with the lack of strip-component option in unzip before but I don't remember how I solved it.
Here is how I handle the gogs zip archive for example: https://github.com/YunoHost-Apps/gogs_ynh/blob/master/scripts/_common.sh#L32-L47
If it's really needed please move it to its own function since it's not obvious how it work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When looking for a substitute to --strip-component, I also stumbled upon rsync-based solutions. I do prefer using bash-only when possible.
But I agree it's ugly, so I'll make it cleaner in a specific function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh ok so it was probably Gogs. But since rsync is installed in debian like unzip why bother? I prefer not to have complicated rm -f while rsync do the job very well.

@@ -46,9 +46,9 @@ ynh_app_setting_set $app adminusername $admin
ynh_app_setting_set $app is_public $is_public

# Create tmp directory and install app inside
TMPDIR=$(ynh_mkdir_tmp)
TMPDIR=`mktemp -d`
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 a little picky here but could you use $(command) instead of backquotes theses are deprecated. Also consistency with the rest of the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I fell into old habits here :-)

@mbugeia
Copy link
Contributor

mbugeia commented Jan 5, 2017

Ok for me, tested the upgrade on my production instance yesterday without issue. I'd like to have another person to test it before merging since it's an official app.

@mbugeia mbugeia merged commit 7ae3c03 into YunoHost-Apps:master Jan 17, 2017
JimboJoe added a commit to JimboJoe/kanboard_ynh that referenced this pull request Feb 26, 2017
* Create check_process

* Syntax fix

* Download sources during installation and upgrade to 1.0.36 (YunoHost-Apps#38)

* Download sources (except dependencies) during installation and upgrade to 1.0.35

* Download dependencies during installation
Upgrade to 1.0.36

* Download kanboard zip from kanboard.net website

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

Successfully merging this pull request may close these issues.

None yet

2 participants