版本构建测试过程记录

本文详细介绍了从Repo管理系统切换到Git仓库的过程,包括删除Repo、初始化Git仓库、解决.gitignore文件引起的编译问题,以及通过修改预构建脚本来生成commit_id.xml文件。文章提供了实用的Shell和Python脚本,用于自动化这一转换流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

由于瑞芯微拿过来的版本是repo管理的android,本来想建立一个repo仓库存储,但是无奈手底下的人不怎么会使用(其实我也不怎么会使用,就在刚刚,一个repo sync,就将之前的其他仓库的更改付之东流)。于是乎,就考虑到,还是将repo 仓库更改成git仓库存储把,这样也便于手下人使用,repo虽好,无奈需要一定的学习成本。

从repo到git有如下几个步骤。
1.将仓库的repo删除掉,然后通过git init; git add ; git commit ;来实现仓库的建立(当然之前的提交都没有了,没办法,有时候在功能强大和便捷两方面要有所取舍)
2.其他人克隆我建立的仓库代码。

中间会遇到如下问题:
删除repo后,其管理的多个仓库里面会有.gitignore文件,其中某些里面还记录了忽略的.c,.h文件。如果将整体建立一个git 库,那么就会忽略掉一些.c,.h文件,本地编译没关系(因为这些文件通过repo下载下来时候都在)。但是当提交到库,或者别人拉取的时候,则会出现丢失某些文件。笔者曾经想,缺什么就重新提交什么,然后经历了几个库后放弃了,无奈太多了。还有一个问题就是删除repo后,commit_id.xmlwe文件无法创立,于是笔者的思路如下:
将系统中所有的.gitignore文件中的.c,.h都删除掉,这样虽然可能会多一点点文件,但是应该可以保证顺利编译通过,并且最终的目的是其他人也能顺利拉取代码并且编译。
通过修改device/px5/common/prebuild.mk中的脚本,解决commit_id.xml的生成问题
于是乎,有了如下两个脚本(没办法,笔者shell能力较弱,为了最小化的达成某个目的,只好将就用python折腾下了):
run.sh

#/bin/sh
mkdir origin
mv .repo origin
cd origin
repo sync -l
mv .repo ../
cp ../main.py .
python main.py
cp ../compiler.sh .
rm main.py
git init
git add *
git commit -m "init the base code"
./compiler.sh
cd ..

mkdir test
cd test
git clone ../origin
./compiler.sh

python文件

import os
execcom ="sed '2c $(shell git log > commit_id.xml)' device/rockchip/common/prebuild.mk  > device/rockchip/common/prebuild.mk.bank"
execcom2 ="mv device/rockchip/common/prebuild.mk.bank device/rockchip/common/prebuild.mk"
os.system(execcom)
os.system(execcom2)

genefilecommand = "find -name .gitignore |xargs grep -iwrn \"c\" > temp.t"
os.system(genefilecommand)
tempfile = open('temp.t')
for line in tempfile.readlines():
        linearray = line.split(':')
        deletefilename = linearray[0]
        deletefileline = linearray[1]
        execcommand = "sed " + linearray[1] + "d " + linearray[0]
        os.system(execcommand)
tempfile.close()

genefilecommand = "find -name .gitignore |xargs grep -iwrn \"h\" > temp.t"
os.system(genefilecommand)
tempfile = open('temp.t')
for line in tempfile.readlines():
        linearray = line.split(':')
        deletefilename = linearray[0]
        deletefileline = linearray[1]
        execcommand = "sed " + linearray[1] + "d " + linearray[0]
        os.system(execcommand)
tempfile.close()
os.system("rm temp.t")

当上面的test目录下面正确编译,则说明我的代码转换成功

经过优化后,两个脚本变成了一个脚本,额


#/bin/sh
mkdir origin
mv .repo origin

cd origin
repo sync -l
mv .repo ../
cp ../compiler.sh .
find -name ".gitignore" | sed -i '/\.c$/d'
sed '2c $(shell git log > commit_id.xml)' device/rockchip/common/prebuild.mk  > device/rockchip/common/prebuild.mk.bank"
mv device/rockchip/common/prebuild.mk.bank device/rockchip/common/prebuild.mk"
find -name .git -exec rm -rf {} \;

git init
git add *
git commit -m "init the base code"
#./compiler.sh
cd ..

git clone origin test
cd test
./compiler.sh

经过优化的终极版本,一共含有两个文件compiler.sh,run.sh
run.sh

#/bin/sh
mkdir origin
mv .repo origin

cd origin
repo sync -l
mv .repo ../
cp ../compiler.sh .
find -name .git -exec rm -rf {} \;
find -name ".gitignore" | xargs sed -i '/\.c$/d'
find -name ".gitignore" | xargs sed -i '/\.h$/d'
sed -i '/config.h\*/d' external/libusb/.gitignore
sed -i '/net/d' external/libpcap/.gitignore
sed -i '/config\.\*/d' external/iptables/.gitignore
sed -i '/\*\.elf/d' u-boot/.gitignore
sed -i '286c BOARD_RECORD_COMMIT_ID ?= false' device/rockchip/common/BoardConfig.mk
#sed -i '2c $(shell git log > commit_id.xml)' device/rockchip/common/prebuild.mk

git init
git add *
git commit -m "init the base code"
#./compiler.sh
cd ..

git clone origin test
cd test
time ./compiler.sh
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值