-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Loongson-Cloud-Community:main' into main
- Loading branch information
Showing
191 changed files
with
21,127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/python3 | ||
|
||
import os | ||
import typing as t | ||
import requests | ||
|
||
def get_images_from_fs() -> t.List[t.Tuple[str, str]]: | ||
""" | ||
获取到镜像的组织-名称;也就是获取到所有的二级目录 | ||
""" | ||
res = [] | ||
|
||
for root, _, _ in os.walk("."): | ||
## 忽略.git和.github目录 | ||
if root.startswith("./.git") or root.startswith("./.github"): | ||
continue | ||
|
||
segs = root.split("/") | ||
|
||
## segs[1]代表org_name,segs[2]代表image_name | ||
if len(segs)==3 and segs[0] == ".": | ||
res.append((segs[1], segs[2])) | ||
return res | ||
|
||
class QUAYClient: | ||
""" | ||
QUAY 的http请求客户端. | ||
""" | ||
def __init__(self): | ||
pass | ||
|
||
def _tag_url(self, org_name: str, repo_name: str) -> str: | ||
return f"https://lcr.loongnix.cn/api/v1/repository/{org_name}/{repo_name}/tag/" | ||
|
||
def tags(self, org_name: str, repo_name: str) -> t.List[str]: | ||
""" | ||
获取指定镜像所有的标签. | ||
""" | ||
tag_url = self._tag_url(org_name, repo_name) | ||
params = dict(page=1, limit=100) | ||
resp = requests.get(url=tag_url, params=params) | ||
if not resp.ok: | ||
print(f"url={tag_url} 请求失败") | ||
return [] | ||
|
||
res = [] | ||
for tag in resp.json()["tags"]: | ||
tag_name = tag["name"] | ||
res.append(f"{org_name}/{repo_name}:{tag_name}") | ||
return res | ||
|
||
def count_images() -> t.List[str]: | ||
""" | ||
统计镜像的总数 | ||
""" | ||
res = [] | ||
quay_client = QUAYClient() | ||
|
||
for org_name, repo_name in get_images_from_fs(): | ||
for image_name in quay_client.tags(org_name, repo_name): | ||
res.append(image_name) | ||
|
||
return res | ||
|
||
if __name__ == "__main__": | ||
images = count_images() | ||
print(f"镜像的总数为:{len(images)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
FROM lcr.loongnix.cn/library/alpine:3.19 AS builder | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
############################################################### | ||
# set build args | ||
############################################################### | ||
ARG CURL_RELEASE_TAG=latest | ||
ARG CURL_GIT_REPO=https://github.com/curl/curl.git | ||
ARG CURL_CONFIGURE_OPTION=--without-ssl | ||
ARG LABEL_VERSION=1.0.0 | ||
ARG LABEL_NAME=curl | ||
ARG LABEL_DESC=curl | ||
|
||
############################################################### | ||
# build curl | ||
############################################################### | ||
# install deps and use latest curl release source | ||
RUN apk update && apk add libssh2 libssh2-dev libssh2-static \ | ||
autoconf automake build-base \ | ||
groff openssl curl-dev \ | ||
python3 python3-dev \ | ||
libtool curl tlstunnel perl \ | ||
nghttp2 brotli brotli-dev | ||
|
||
RUN mkdir /src | ||
COPY "curl" "/src/curl" | ||
WORKDIR /src/curl | ||
|
||
############################################################### | ||
# get ca cert bundle from curl.haxx.se | ||
############################################################### | ||
RUN curl https://curl.haxx.se/ca/cacert.pem -L -o /cacert.pem | ||
|
||
############################################################### | ||
# build the tag version | ||
############################################################### | ||
RUN ./buildconf && \ | ||
autoreconf -vif && \ | ||
./configure ${CURL_CONFIGURE_OPTION} &&\ | ||
make -j$(nproc) &&\ | ||
#make test &&\ | ||
make DESTDIR="/alpine/" install -j$(nproc) | ||
|
||
############################################################### | ||
# pinning image to Alpine 3.11.11 | ||
############################################################### | ||
FROM lcr.loongnix.cn/library/alpine:3.19 | ||
|
||
ARG CURL_RELEASE_TAG=latest | ||
ARG CURL_RELEASE_VERSION | ||
ARG CURL_GIT_REPO=https://github.com/curl/curl.git | ||
|
||
ENV CURL_VERSION ${CURL_RELEASE_VERSION} | ||
ENV CURL_RELEASE_TAG ${CURL_RELEASE_TAG} | ||
ENV CURL_GIT_REPO ${CURL_GIT_REPO} | ||
|
||
############################################################### | ||
# dependencies | ||
############################################################### | ||
RUN apk update && \ | ||
apk add --no-cache brotli brotli-dev libssh2 nghttp2-dev && \ | ||
rm -fr /var/cache/apk/* | ||
|
||
############################################################### | ||
# add non privileged curl user | ||
############################################################### | ||
RUN addgroup -S curl_group && adduser -S curl_user -G curl_group | ||
|
||
############################################################### | ||
# set curl ca bundle | ||
############################################################### | ||
COPY --from=builder "/cacert.pem" "/cacert.pem" | ||
ENV CURL_CA_BUNDLE="/cacert.pem" | ||
|
||
############################################################### | ||
# install curl built from builder | ||
############################################################### | ||
COPY --from=builder "/alpine/usr/local/lib/libcurl.so.4.8.0" "/usr/lib/" | ||
COPY --from=builder "/alpine/usr/local/bin/curl" "/usr/bin/curl" | ||
COPY --from=builder "/alpine/usr/local/include/curl" "/usr/include/curl" | ||
|
||
# explicitly set symlinks | ||
RUN ln -s /usr/lib/libcurl.so.4.8.0 /usr/lib/libcurl.so.4 | ||
RUN ln -s /usr/lib/libcurl.so.4 /usr/lib/libcurl.so | ||
|
||
############################################################### | ||
# set user | ||
############################################################### | ||
USER curl_user | ||
|
||
############################################################### | ||
# set entrypoint | ||
############################################################### | ||
COPY "entrypoint.sh" "/entrypoint.sh" | ||
CMD ["curl"] | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This file is generated by the template. | ||
|
||
REGISTRY?=lcr.loongnix.cn | ||
ORGANIZATION?=curlimages | ||
REPOSITORY?=curl | ||
TAG?=latest | ||
|
||
IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) | ||
|
||
CURL_RELEASE_TAG?=curl-8_7_1 | ||
CURL_GIT_REPO?=https://github.com/curl/curl.git | ||
|
||
default: image | ||
|
||
image: source replace build | ||
|
||
|
||
source: clear | ||
git clone --branch $(CURL_RELEASE_TAG) $(CURL_GIT_REPO) | ||
|
||
TARGET_FILE_PATH:=curl/lib | ||
TARGET_FILE:=easy_lock.h | ||
|
||
replace: | ||
rm $(TARGET_FILE_PATH)/$(TARGET_FILE) | ||
cp $(TARGET_FILE) $(TARGET_FILE_PATH)/ | ||
|
||
build: | ||
docker build --no-cache \ | ||
-t $(IMAGE) \ | ||
. | ||
|
||
push: | ||
docker push $(IMAGE) | ||
|
||
clear: | ||
rm -rf curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ \| | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* \___|\___/|_| \_\_____| | ||
* | ||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al. | ||
* | ||
* This software is licensed as described in the file COPYING, which | ||
* you should have received as part of this distribution. The terms | ||
* are also available at https://curl.se/docs/copyright.html. | ||
* | ||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell | ||
* copies of the Software, and permit persons to whom the Software is | ||
* furnished to do so, under the terms of the COPYING file. | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
* KIND, either express or implied. | ||
* | ||
* SPDX-License-Identifier: curl | ||
* | ||
***************************************************************************/ | ||
|
||
#include "curl_setup.h" | ||
|
||
#define GLOBAL_INIT_IS_THREADSAFE | ||
|
||
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 | ||
|
||
#define curl_simple_lock SRWLOCK | ||
#define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT | ||
|
||
#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) | ||
#define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) | ||
|
||
#elif defined (HAVE_ATOMIC) | ||
#include <stdatomic.h> | ||
|
||
#define curl_simple_lock atomic_bool | ||
#define CURL_SIMPLE_LOCK_INIT false | ||
|
||
static inline void curl_simple_lock_lock(curl_simple_lock *lock) | ||
{ | ||
for(;;) { | ||
if(!atomic_exchange_explicit(lock, true, memory_order_acquire)) | ||
break; | ||
/* Reduce cache coherency traffic */ | ||
while(atomic_load_explicit(lock, memory_order_relaxed)) { | ||
/* Reduce load (not mandatory) */ | ||
#if defined(__i386__) || defined(__x86_64__) | ||
__builtin_ia32_pause(); | ||
#elif defined(__aarch64__) | ||
asm volatile("yield" ::: "memory"); | ||
#elif defined(HAVE_SCHED_YIELD) | ||
#include<sched.h> // sched_yield(); | ||
#endif | ||
} | ||
} | ||
} | ||
|
||
static inline void curl_simple_lock_unlock(curl_simple_lock *lock) | ||
{ | ||
atomic_store_explicit(lock, false, memory_order_release); | ||
} | ||
|
||
#else | ||
|
||
#undef GLOBAL_INIT_IS_THREADSAFE | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (C) 2020 James Fuller <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
set -e | ||
|
||
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then | ||
set -- curl "$@" | ||
fi | ||
|
||
exec "$@" |
Oops, something went wrong.