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

[Build] Support j2 template for debian sources #12557

Merged
merged 6 commits into from
Nov 9, 2022

Conversation

xumia
Copy link
Collaborator

@xumia xumia commented Oct 31, 2022

Why I did it

  1. Unify the Debian mirror sources
  2. Make easy to upgrade to the next Debian release, not source url code change required.
  3. Support to customize the Debian mirror sources during the build

Relative issue: #12523

How I did it

How to verify it

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@xumia xumia added the Build label Oct 31, 2022
@xumia xumia force-pushed the uniq-debian-sources branch from 989b275 to dc38589 Compare October 31, 2022 09:29
@xumia xumia marked this pull request as draft October 31, 2022 12:26
Comment on lines 13 to 19
{% if DISTRIBUTION == 'stretch' %}
deb {{ mirror_url }} {{ DISTRIBUTION }}/updates main contrib non-free
deb-src {{ mirror_url }} {{ DISTRIBUTION }}/updates main contrib non-free
{% else %}
deb {{ mirror_url }} {{ DISTRIBUTION }}-security main contrib non-free
deb-src {{ mirror_url }} {{ DISTRIBUTION }}-security main contrib non-free
{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Format was changed in bullseye: https://www.debian.org/releases/stable/amd64/release-notes/ch-information.en.html#security-archive
Buster also has format {{ DISTRIBUTION }}/updates for security mirrors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kv-y , fixed, thanks for you comment.

Comment on lines 17 to 22
TEMPALTE=files/apt/sources.list.j2
[ -f files/apt/sources.list.$ARCHITECTURE.j2 ] && TEMPALTE=files/apt/sources.list.$ARCHITECTURE.j2
[ -f $CONFIG_PATH/sources.list.j2 ] && TEMPALTE=$CONFIG_PATH/sources.list.j2
[ -f $CONFIG_PATH/sources.list.$ARCHITECTURE.j2 ] && TEMPALTE=$CONFIG_PATH/sources.list.$ARCHITECTURE.j2

j2 $TEMPALTE > $CONFIG_PATH/sources.list.$ARCHITECTURE
Copy link
Contributor

Choose a reason for hiding this comment

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

TEMPALTE

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, thanks.

Comment on lines 5 to 6
DEFAULT_MIRROR_URLS=http://debian-archive.trafficmanager.net/debian/,http://cdn1.packages.trafficmanager.net/snapshot/debian/latest/
DEFAULT_MIRROR_SECURITY_URLS=http://debian-archive.trafficmanager.net/debian-security/,http://cdn1.packages.trafficmanager.net/snapshot/debian-security/latest/
Copy link
Contributor

Choose a reason for hiding this comment

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

Need fix for repr build?
Now REPR_MIRROR_URL_PATTERN='http://packages.trafficmanager.net/debian'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we need to support repr build, fixed, thanks.

@xumia
Copy link
Collaborator Author

xumia commented Nov 5, 2022

@kv-y , do you have any more comments?

@xumia
Copy link
Collaborator Author

xumia commented Nov 5, 2022

@qiluo-msft , could you please help review it? Thanks.

@kv-y
Copy link
Contributor

kv-y commented Nov 5, 2022

@xumia

Could you please retest a customization of Debian mirrors?
I mean something like this:

MIRROR_URLS="http://deb.debian.org/debian/,http://packages.trafficmanager.net/debian/debian/" MIRROR_SECURITY_URLS="http://deb.debian.org/debian-security,http://packages.trafficmanager.net/debian/debian-security/" make configure PLATFORM=vs

MIRROR_URLS="http://deb.debian.org/debian/,http://packages.trafficmanager.net/debian/debian/" MIRROR_SECURITY_URLS="http://deb.debian.org/debian-security,http://packages.trafficmanager.net/debian/debian-security/" make target/sonic-vs.img.gz

I got correct sources.lists for sonic-slaves.
But for docker-base-xxx and for rootfs (files/apt) I got debian-archive.trafficmanager.net instead of expected deb.debian.org.

I think you forgot to pass these variables from Makefile.work to slave.mk.

# The debian-archive.trafficmanager.net does not support armhf, use debian.org instead
if [ "$ARCHITECTURE" == "armhf" ]; then
DEFAULT_MIRROR_URLS=http://deb.debian.org/debian/,http://packages.trafficmanager.net/debian/debian/
DEFAULT_MIRROR_SECURITY_URLS=http://security.debian.org/,http://packages.trafficmanager.net/debian/debian-security/
Copy link
Contributor

@kv-y kv-y Nov 6, 2022

Choose a reason for hiding this comment

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

I think we can use here http://deb.debian.org/debian-security/ instead of http://security.debian.org/ for unification.

There are multiple variants:
security.debian.org
security.debian.org/debian-security
deb.debian.org/debian-security
and all work.

Related question: https://unix.stackexchange.com/questions/387006/sources-list-repository-url-for-debian-security-updates-with-or-without-debian

Documentation recommends to use deb.debian.org/debian-security or security.debian.org/debian-security.
Official debian docker images use deb.debian.org/debian-security since buster.

Copy link
Collaborator Author

@xumia xumia Nov 7, 2022

Choose a reason for hiding this comment

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

Fixed, "deb.debian.org/debian-security" is better than "security.debian.org".

Using the URLs as below:

http://deb.debian.org/debian/
http://deb.debian.org/debian-security/

@kv-y
Copy link
Contributor

kv-y commented Nov 6, 2022

Also I tried to test repr build with this patch, but seem like repr build is broken for master.
Probably need this fix in master branch.

@xumia
Copy link
Collaborator Author

xumia commented Nov 7, 2022

@xumia

Could you please retest a customization of Debian mirrors? I mean something like this:

MIRROR_URLS="http://deb.debian.org/debian/,http://packages.trafficmanager.net/debian/debian/" MIRROR_SECURITY_URLS="http://deb.debian.org/debian-security,http://packages.trafficmanager.net/debian/debian-security/" make configure PLATFORM=vs

MIRROR_URLS="http://deb.debian.org/debian/,http://packages.trafficmanager.net/debian/debian/" MIRROR_SECURITY_URLS="http://deb.debian.org/debian-security,http://packages.trafficmanager.net/debian/debian-security/" make target/sonic-vs.img.gz

I got correct sources.lists for sonic-slaves. But for docker-base-xxx and for rootfs (files/apt) I got debian-archive.trafficmanager.net instead of expected deb.debian.org.

I think you forgot to pass these variables from Makefile.work to slave.mk.

Fixed, thanks, missing to pass the variables.

@xumia
Copy link
Collaborator Author

xumia commented Nov 7, 2022

Also I tried to test repr build with this patch, but seem like repr build is broken for master. Probably need this fix in master branch.

The repr only works on the release branches, such as 202012, 202111, 202205, etc, not on master branch today, but we have a plan to support it.

@xumia xumia force-pushed the uniq-debian-sources branch from d2d798f to 50eebf4 Compare November 7, 2022 02:22
@xumia xumia marked this pull request as ready for review November 7, 2022 03:50
@xumia xumia merged commit ac5d89c into sonic-net:master Nov 9, 2022
@xumia xumia deleted the uniq-debian-sources branch November 9, 2022 00:09
xumia pushed a commit that referenced this pull request Nov 15, 2022
…hanged (#12702)

Why I did it
After #12557 sources.lists are generated.
So we need to recalculate SLAVE_BASE_TAG if mirrors were changed.
Also we need to rebuild DPKG cache in this case.

How I did it
Use generated sources.list for SLAVE_BASE_TAG
Add MIRROR_URLS and MIRROR_SECURITY_URLS to SONIC_COMMON_FLAGS_LIST
davidpil2002 pushed a commit to davidpil2002/sonic-buildimage that referenced this pull request Nov 15, 2022
…hanged (sonic-net#12702)

Why I did it
After sonic-net#12557 sources.lists are generated.
So we need to recalculate SLAVE_BASE_TAG if mirrors were changed.
Also we need to rebuild DPKG cache in this case.

How I did it
Use generated sources.list for SLAVE_BASE_TAG
Add MIRROR_URLS and MIRROR_SECURITY_URLS to SONIC_COMMON_FLAGS_LIST
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Dec 28, 2022
StormLiangMS pushed a commit that referenced this pull request Dec 30, 2022
Why I did it
Unify the Debian mirror sources
Make easy to upgrade to the next Debian release, not source url code change required. Support to customize the Debian mirror sources during the build
Relative issue: #12523

How I did it
How to verify it
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Apr 7, 2023
Why I did it
Unify the Debian mirror sources
Make easy to upgrade to the next Debian release, not source url code change required.
Support to customize the Debian mirror sources during the build
Relative issue: sonic-net#12523
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Apr 14, 2023
Why I did it
Unify the Debian mirror sources
Make easy to upgrade to the next Debian release, not source url code change required.
Support to customize the Debian mirror sources during the build
Relative issue: sonic-net#12523
@xumia xumia mentioned this pull request Apr 14, 2023
10 tasks
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Apr 14, 2023
commit 69f74304e2c848d4ca4c7767c7b0b228f5351de6
Author: xumia <59720581+xumia@users.noreply.github.com>
Date:   Wed Nov 9 08:09:53 2022 +0800

    [Build] Support j2 template for debian sources (sonic-net#12557)

    Why I did it
    Unify the Debian mirror sources
    Make easy to upgrade to the next Debian release, not source url code change required.
    Support to customize the Debian mirror sources during the build
    Relative issue: sonic-net#12523
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Apr 17, 2023
Why I did it
Unify the Debian mirror sources
Make easy to upgrade to the next Debian release, not source url code change required.
Support to customize the Debian mirror sources during the build
Relative issue: sonic-net#12523
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Apr 17, 2023
commit 69f74304e2c848d4ca4c7767c7b0b228f5351de6
Author: xumia <59720581+xumia@users.noreply.github.com>
Date:   Wed Nov 9 08:09:53 2022 +0800

    [Build] Support j2 template for debian sources (sonic-net#12557)

    Why I did it
    Unify the Debian mirror sources
    Make easy to upgrade to the next Debian release, not source url code change required.
    Support to customize the Debian mirror sources during the build
    Relative issue: sonic-net#12523
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Apr 17, 2023
Why I did it
Unify the Debian mirror sources
Make easy to upgrade to the next Debian release, not source url code change required.
Support to customize the Debian mirror sources during the build
Relative issue: sonic-net#12523
xumia added a commit that referenced this pull request Apr 18, 2023
…lity (#14663)

Why I did it
Cherry-pick commits from master to support the snapshot based mirror, and fix the code conflicts.

ad162ae [Build] Optimize the version control for Debian packages (#14557)
38c5d7f [Build] Support j2 template for debian sources for docker ptf (#13198)
5e4826e [Ci] Support to use the same snapshot for all platform builds (#13913)
8206925 [Build] Change the default mirror version config file (#13786)
5e4a866 [Build] Support Debian snapshot mirror to improve build stability (#13097)
ac5d89c [Build] Support j2 template for debian sources (#12557)

Work item tracking
Microsoft ADO (number only): 18018114
How I did it
How to verify it
xumia added a commit that referenced this pull request Apr 18, 2023
…lity (#14664)

Why I did it
Cherry-pick commits from master to support the snapshot based mirror, and fix the code conflicts.

ad162ae [Build] Optimize the version control for Debian packages (#14557)
38c5d7f [Build] Support j2 template for debian sources for docker ptf (#13198)
5e4826e [Ci] Support to use the same snapshot for all platform builds (#13913)
8206925 [Build] Change the default mirror version config file (#13786)
5e4a866 [Build] Support Debian snapshot mirror to improve build stability (#13097)
ac5d89c [Build] Support j2 template for debian sources (#12557)

Work item tracking
Microsoft ADO (number only): 18018114
How I did it
How to verify it
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Apr 20, 2023
Why I did it
Unify the Debian mirror sources
Make easy to upgrade to the next Debian release, not source url code change required.
Support to customize the Debian mirror sources during the build
Relative issue: sonic-net#12523
xumia added a commit to xumia/sonic-buildimage-1 that referenced this pull request Apr 20, 2023
Why I did it
Unify the Debian mirror sources
Make easy to upgrade to the next Debian release, not source url code change required.
Support to customize the Debian mirror sources during the build
Relative issue: sonic-net#12523
qiluo-msft pushed a commit that referenced this pull request Apr 21, 2023
…lity (#14558)

#### Why I did it
Cherry-pick commits from master to support the snapshot based mirror, and fix the code conflicts. And add the last commit to fix the build broken issue according to the mirror change.

ad162ae [Build] Optimize the version control for Debian packages (#14557)
38c5d7f [Build] Support j2 template for debian sources for docker ptf (#13198)
5e4826e  [Ci] Support to use the same snapshot for all platform builds (#13913)
8206925 [Build] Change the default mirror version config file (#13786)
5e4a866 [Build] Support Debian snapshot mirror to improve build stability (#13097)
ac5d89c  [Build] Support j2 template for debian sources (#12557)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants