guysoft / CustomPiOS

A Raspberry Pi and other ARM devices distribution builder
GNU General Public License v3.0
514 stars 149 forks source link

Using gitclone without a specified folder fails #103

Closed David00 closed 3 years ago

David00 commented 3 years ago

Hi,

First of all, thanks for being such an awesome contributor to the 3D printing community, and of course for this project too!

I'm working on building a custom image for my Raspberry Pi Power Monitor project using CustomPiOS and have uncovered an issue with the gitclone function in common.sh.

The comments in the gitclone function state:

# if second parameter is not provided last URL segment of the BUILD repo URL
# minus the optional .git postfix will be used

However, I've found this to not be the case.

I have my REPO_SHIP variable defined in the config file located in ~/CustomPiOS/src/distros/powermon/src/modules/powermon/ : [ -n "$POWERMON_POWERMON_REPO_SHIP" ] || POWERMON_POWERMON_REPO_SHIP=https://github.com/David00/rpi-power-monitor.git

And in my start_chroot_script (same folder as the config above), I am calling gitclone like this:

cd /home/pi
gitclone POWERMON_POWERMON_REPO

I'm building with the Docker image on Ubuntu 18.04 server, and it eventually fails with the following output:

+ build_repo=
+ ship_repo=https://github.com/David00/rpi-power-monitor.git
+ branch=
+ '[' '!' -n '' ']'
+ build_repo=https://github.com/David00/rpi-power-monitor.git
+ clone_params=
+ repo_recursive=
+ '[' -n '' ']'
+ '[' -n '' ']'
+ '[' -n '' ']'
+ repo_dir=
+ '[' '!' -n '' ']'
++ echo
++ sed 's%^.*/\([^/]*\)\(\.git\)?$%\1%g'
+ repo_dir=
+ sudo -u pi git clone https://github.com/David00/rpi-power-monitor.git ''
sudo: unable to resolve host 87672414d467: Name or service not known
fatal: could not create work tree dir '': No such file or directory
++++ echo_red 'build failed, unmounting image...'
++++ echo -e -n '\e[91m'
++++ echo build failed, unmounting image...
build failed, unmounting image...

It's easy to specify a directory, and this works fine as a workaround... I just wanted to mention the misleading comment in the gitclone definition.

guysoft commented 3 years ago

Indeed, an error with perhaps a usage example would help out. I have no time for this and a PR would be welcome.