From e746cf717e6f06a4583d11b708ca05e6c7615b82 Mon Sep 17 00:00:00 2001 From: Chiichen Date: Fri, 5 Apr 2024 22:04:08 +0800 Subject: [PATCH 1/4] chore/ci: add build script and github release action (#1) * feat: added support for automatically insatll dependencies and build * chore: fix workflow path * chore: fix install_deps.sh * chore: update workflow * chore: update install script * chore: update workflow * chore: update workflow * chore: update workflow * chore: update workflow * chore: update workflow * chore: update workflow * chore: automatically release * chore: update workflow * chore: remove unused pip dep * chore: remove comments * chore: add seperated configure script for cross compile * ci: add cross compile support * ci: fix bash command error * ci: fix arch name * chore: fix cross compile error * ci: fix unexported arch variable * chore: fix command error * chore: fix command error * ci: switch file structure & remove aarch64 target * chore: update config * chore: x86_64 release & add dragonos build script * chore: switch default prefix from /usr to / --- .github/workflows/glibc.yml | 123 ++++++++++++++++++++++++++++++++++++ .gitignore | 3 + default_configure.sh | 19 ++++++ dragonos.sh | 5 ++ install_deps.sh | 17 +++++ 5 files changed, 167 insertions(+) create mode 100644 .github/workflows/glibc.yml create mode 100644 default_configure.sh create mode 100644 dragonos.sh create mode 100644 install_deps.sh diff --git a/.github/workflows/glibc.yml b/.github/workflows/glibc.yml new file mode 100644 index 00000000000..f90ff1f26a4 --- /dev/null +++ b/.github/workflows/glibc.yml @@ -0,0 +1,123 @@ +name: glibc + +on: + push: + tags: + - "v*" + +jobs: + meta: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.set_tag.outputs.tag }} + prerelease: ${{ steps.set_pre.outputs.prerelease }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + path: temp + show-progress: false + + - name: Fetch history + if: ${{ !startsWith(github.ref, 'refs/pull/') }} + run: | + git init + cp $GITHUB_WORKSPACE/temp/.git/config ./.git + rm -rf $GITHUB_WORKSPACE/temp + # git config remote.origin.fetch '+refs/*:refs/*' + git fetch --filter=tree:0 # --update-head-ok + git reset --hard origin/$(git branch --show-current) || true + git checkout ${{ github.ref_name }} + + - name: Set tag + id: set_tag + run: | + ${{ startsWith(github.ref, 'refs/pull/') && 'cd temp' || '' }} + echo tag=$(git describe --tags --match "v*" ${{ github.ref }} || git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT + exit ${PIPESTATUS[0]} + + - name: Judge pre-release + id: set_pre + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | + if [[ '${{ steps.set_tag.outputs.tag }}' =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo prerelease=false | tee -a $GITHUB_OUTPUT + else + echo prerelease=true | tee -a $GITHUB_OUTPUT + fi + + - name: Generate changelog + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | + this_tag=${{ steps.set_tag.outputs.tag }} + if [[ '${{ steps.set_pre.outputs.prerelease }}' != 'false' ]]; then + last_tag=$(git describe --tags --match "v*" --abbrev=0 --exclude='${{ steps.set_tag.outputs.tag }}') + else + last_tag=$(git describe --tags --match "v*" --abbrev=0 --exclude='${{ steps.set_tag.outputs.tag }}' --exclude='*-*') + fi + echo >> CHANGELOG.md + echo "**Full Changelog**: [$last_tag -> $this_tag](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/compare/${last_tag}...${this_tag})" >> CHANGELOG.md + + - name: Upload changelog to Github + uses: actions/upload-artifact@v4 + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + with: + name: changelog + path: CHANGELOG.md + + build: + needs: meta + runs-on: ubuntu-latest + strategy: + matrix: + # arch: [x86_64,riscv64,aarch64] + arch: [x86_64] + steps: + - uses: actions/checkout@v4 + - name: Install Dependencies + run: | + export ARCH=${{matrix.arch}} + bash ./install_deps.sh + - name: Configure + run: | + export ARCH=${{matrix.arch}} + bash ./default_configure.sh + - name: Build + run: | + cd build + make -j $(nproc) + make install DESTDIR=$GITHUB_WORKSPACE/install -j $(nproc) + - name: Package glibc + run: | + mkdir -p release + cd install && ls -ahl && tar czvf $GITHUB_WORKSPACE/release/glibc-${{matrix.arch}}-${{ needs.meta.outputs.tag }}.tar.gz . + - name: Upload to Github + uses: actions/upload-artifact@v4 + with: + name: glibc-${{matrix.arch}} + path: | + release/*.tar.gz + release: + if: startsWith(github.ref, 'refs/tags/v') + needs: [meta, build] + runs-on: ubuntu-latest + steps: + - name: Download glibc from Github + uses: actions/download-artifact@v4 + with: + path: assets + + - name: Cleanup files + run: | + mv -vf assets/changelog/* . + cd assets + find . -type f | while read f; do mv -fvt . $f; done + + - name: Release to Github + uses: softprops/action-gh-release@v1 + with: + body_path: CHANGELOG.md + files: | + assets/* + prerelease: ${{ needs.meta.outputs.prerelease != 'false' }} + diff --git a/.gitignore b/.gitignore index 07d4a129e5d..753bd4efd5b 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ core /linuxthreads_db /rtkaio *.pyc +build +install +release \ No newline at end of file diff --git a/default_configure.sh b/default_configure.sh new file mode 100644 index 00000000000..8535927b5ed --- /dev/null +++ b/default_configure.sh @@ -0,0 +1,19 @@ +mkdir -p build +mkdir -p install +if [ -z "$ARCH" ] || [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "riscv64" ] && [ "$ARCH" != "aarch64" ]; then + echo "No ARCH specified, use x86_64 as default" + export ARCH="x86_64" +fi +if [ "$ARCH" == "x86_64" ] || [ "$ARCH" == "riscv64" ] || [ "$ARCH" == "aarch64" ]; then + export TRIPLET=${ARCH}-linux-gnu +fi +export BUILD=`uname -m` +cd build +../configure \ + --prefix=/ \ + --host=${TRIPLET} \ + --build=${BUILD}-linux-gnu \ + CC="${TRIPLET}-gcc -m64" \ + CXX="${TRIPLET}-g++ -m64" \ + CFLAGS="-O2" \ + CXXFLAGS="-O2" \ No newline at end of file diff --git a/dragonos.sh b/dragonos.sh new file mode 100644 index 00000000000..0faa5517364 --- /dev/null +++ b/dragonos.sh @@ -0,0 +1,5 @@ +bash install_deps.sh +bash default_configure.sh +cd build +make -j $(nproc) +DESTDIR=$DADK_CURRENT_BUILD_DIR make install -j $(nproc) \ No newline at end of file diff --git a/install_deps.sh b/install_deps.sh new file mode 100644 index 00000000000..97d09956bec --- /dev/null +++ b/install_deps.sh @@ -0,0 +1,17 @@ +sudo apt-get install -y make gdb +sudo apt-get install -y texinfo gawk bison sed +sudo apt-get install -y python3-dev python-is-python3 +if [ -z "$ARCH" ] || [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "riscv" ] && [ "$ARCH" != "aarch64" ]; then + echo "No ARCH specified, use x86_64 as default" + export ARCH="x86_64" +fi + +if [ "$ARCH" == "riscv" ] || [ "$ARCH" == "aarch64" ]; then + export TRIPLET=${ARCH}-linux-gnu +fi + +if [ "$ARCH" == "x86_64" ] ; then + export TRIPLET=x86-64-linux-gnu +fi + +sudo apt-get install -y gcc-${TRIPLET} \ No newline at end of file From ad4ad589dcedb62e86f175d905e9487c787c9abe Mon Sep 17 00:00:00 2001 From: Chiichen Date: Fri, 5 Apr 2024 22:28:51 +0800 Subject: [PATCH 2/4] chore: switch default prefix from /usr to / (#2) * feat: added support for automatically insatll dependencies and build * chore: fix workflow path * chore: fix install_deps.sh * chore: update workflow * chore: update install script * chore: update workflow * chore: update workflow * chore: update workflow * chore: update workflow * chore: update workflow * chore: update workflow * chore: automatically release * chore: update workflow * chore: remove unused pip dep * chore: remove comments * chore: add seperated configure script for cross compile * ci: add cross compile support * ci: fix bash command error * ci: fix arch name * chore: fix cross compile error * ci: fix unexported arch variable * chore: fix command error * chore: fix command error * ci: switch file structure & remove aarch64 target * chore: update config * chore: x86_64 release & add dragonos build script * chore: switch default prefix from /usr to / From de33c5f528addbad1c7dcb9d781893e2921a8cd6 Mon Sep 17 00:00:00 2001 From: MemoryShore <1353318529@qq.com> Date: Fri, 30 Aug 2024 21:17:57 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=9B=E5=BB=BAlib64=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dragonos.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dragonos.sh b/dragonos.sh index 0faa5517364..a6c2e0017a4 100644 --- a/dragonos.sh +++ b/dragonos.sh @@ -1,5 +1,8 @@ bash install_deps.sh -bash default_configure.sh +# bash default_configure.sh cd build make -j $(nproc) -DESTDIR=$DADK_CURRENT_BUILD_DIR make install -j $(nproc) \ No newline at end of file +DESTDIR=$DADK_CURRENT_BUILD_DIR make install -j $(nproc) + +mkdir -p $DADK_CURRENT_BUILD_DIR/lib64 +cp $DADK_CURRENT_BUILD_DIR/lib/* $DADK_CURRENT_BUILD_DIR/lib64 \ No newline at end of file From 61174188bb73098ed3e89af96d3c863061c7f6f4 Mon Sep 17 00:00:00 2001 From: MemoryShore <1353318529@qq.com> Date: Fri, 30 Aug 2024 21:21:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dragonos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dragonos.sh b/dragonos.sh index a6c2e0017a4..0baf4338591 100644 --- a/dragonos.sh +++ b/dragonos.sh @@ -1,5 +1,5 @@ bash install_deps.sh -# bash default_configure.sh +bash default_configure.sh cd build make -j $(nproc) DESTDIR=$DADK_CURRENT_BUILD_DIR make install -j $(nproc)