Closed arturngomes closed 1 week ago
Hi @arturngomes
Thanks for your question.
Have you checked the "sources backup" feature? I think it can help with your air-gap system, it was designed with that use case in mind too, depending on how you are "importing" the packages (from ConanCenter I guess), it might be quite straightforward.
Please have a look at https://docs.conan.io/2/devops/backup_sources/sources_backup.html and let us know.
Hi @memsharded,
Thanks a lot for the quick reply. After reading through the link you sent this is the process I'm following (example for the abseil library):
tools.build:download_source=True
to global.confconan graph info --requires=abseil/20240116.2
# I noticed this will actually download the sources and package in one goconan cache save abseil/20240116.2 --file abseil_20240116.2.tgz
Question: Is it possible use the conan download in a way that forces to download the sources?
Then I move the abseil_20240116.2.tgz into the air gapped system and upload it there into the self hosted artifactory.
conan cache restore abseil_20240116.2.tgz
conan upload abseil/20240116.2 -r local
I guess I'm still missing something since when I upload on the air gapped system I get:
-------- Uploading backup sources --------
No backup sources files to upload
edit: I can see the sources are actually in the file:
Add tools.build:download_source=True to global.conf
Probably not recommended, it is inefficient to always download the sources in every conan install
. You can add this argument in command line like -c:a tools.build:download_source=True
just when you want.
conan cache save abseil/20240116.2 --file abseil_20240116.2.tgz
Then I move the abseil_20240116.2.tgz into the air gapped system and upload it there into the self hosted artifactory.
I see. The conan cache save
doesn't save the download cache. At the moment it is necessary to:
core.sources:upload_url
I think you might try this way:
core.sources:download_cache
conan cache save
packages, copy to that folder to the air gapcore.sources:download_cache
in the air-gap pointing to the copied foldercore.sources:upload_url
to the generic repo in the airgapconan upload
should upload the sources tooPlease try that and let us know.
Hi @memsharded,,
Once again thank you for the quick reply. I finally managed to get it to work thanks to your help.
Just in case someone else has the same issue, I'll leave here the procedure I followed to be able to get it working.
Assumptions:
Replace the variables below identified by |
variable | description |
---|---|---|
cache_location | Any directory where the source code (from github/etc) will be stored | |
package | The name of the package | |
version | The version of the package | |
out_file | The name of the compressed file where to store the cached value (e.g abseil_20240116.2.tgz) | |
packaged_zip | Any name you want to identify the packages you just downloaded (e.g abseil_20240116.2.zip) | |
upload_tmp_dir | Directory used to unzip the packaged_zip before uploading | |
backup_url | The url of the generic repository for artifactory | |
remote_name | The name of the remote repository to be used |
For this part a machine with internet connection is needed.
conan graph info --requires=${package}/${version} \
-c:a tools.build:download_source=True \
-cc core.sources:download_cache=${cache_location}
conan cache save ${package}/${version} --file ${out_file}
zip -r ${packaged_zip} ${out_file} ${cache_location}
First go to a directory where you can extract the package and copy the zip file into it:
unzip ${packaged_zip}
conan cache restore ${out_file}`
conan upload ${package}/${version} -r ${remote_name}\
-cc core.sources:download_cache="${upload_tmp_dir}/${cache_location}" \
-cc core.sources:upload_url="${backup_url}"/ \
-cc 'core.sources:download_urls=["${backup_url}", "origin"]'
conan install . --output-folder=build --build=missing -cc 'core.sources:download_urls=["${backup_url}", "origin"]'
Many thanks for your feedback, this is great.
I see some potential simplifications. For example, it wouldn't be necessary to do operations one package at a time. A "package list" can represent multiple packages and conan cache save/restore
can use "package lists" as argument to do their operation, as well as conan upload
and other commands also can use package lists
I also see some potential improvements and features in Conan, like the possibility of conan cache save
the download cache too. However, this doesn't seem a high priority at the moment, as there is a viable process.
In any case, I'd like to comment on something quite important. If you are using an air-gapped environment I am sure that you have high security requirements and other policies and constraints. I am not sure, but if the packages that you are bringing into the air-gap are packages from ConanCenter, then most likely, the recommended approach for your case would be different, mostly building the packages from source yourself. We have different docs and features in Conan to help with this, please check:
What is your question?
Hi, I'm trying to setup conan and artifactory in an air gapped system. So far I managed to get all the dependencies that I need in the self hosted repository. However when I try to install a project that requires some of the dependencies I run into the issue of not being able to compile the project, because the source code is in github, and being in an air gapped system means I have no way of accessing it from the that machine.
Example:
conan install . --output-folder=build --build=missing
abseil/20240116.2: WARN: network: Error downloading file https://github.com/abseil/abseil-cpp/archive/20240116.2.tar.gz: 'HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /abseil/abseil-cpp/archive/20240116.2.tar.gz (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f00674c1cd0>: Failed to establish a new connection: [Errno -2] Name or service not known'))'
Is it possible to pre-download these sources and upload as part of the conan cache save package archive to the self hosted repository?
Have you read the CONTRIBUTING guide?