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..0baf4338591 --- /dev/null +++ b/dragonos.sh @@ -0,0 +1,8 @@ +bash install_deps.sh +bash default_configure.sh +cd build +make -j $(nproc) +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 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