forked from vieter-v/vieter
				
			Fixed linting errors
							parent
							
								
									732b53b6ce
								
							
						
					
					
						commit
						4a4362c138
					
				
							
								
								
									
										14
									
								
								src/build.v
								
								
								
								
							
							
						
						
									
										14
									
								
								src/build.v
								
								
								
								
							|  | @ -2,7 +2,6 @@ module main | ||||||
| 
 | 
 | ||||||
| import docker | import docker | ||||||
| import encoding.base64 | import encoding.base64 | ||||||
| import rand |  | ||||||
| import time | import time | ||||||
| import json | import json | ||||||
| import server | import server | ||||||
|  | @ -10,6 +9,7 @@ import env | ||||||
| import net.http | import net.http | ||||||
| 
 | 
 | ||||||
| const container_build_dir = '/build' | const container_build_dir = '/build' | ||||||
|  | 
 | ||||||
| const build_image_repo = 'vieter-build' | const build_image_repo = 'vieter-build' | ||||||
| 
 | 
 | ||||||
| fn create_build_image() ?string { | fn create_build_image() ?string { | ||||||
|  | @ -83,13 +83,13 @@ fn build() ? { | ||||||
| 	for repo in repos { | 	for repo in repos { | ||||||
| 		// TODO what to do with PKGBUILDs that build multiple packages? | 		// TODO what to do with PKGBUILDs that build multiple packages? | ||||||
| 		commands := [ | 		commands := [ | ||||||
| 			"git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo" | 			'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo', | ||||||
| 			'cd repo' | 			'cd repo', | ||||||
| 			"makepkg --nobuild --nodeps" | 			'makepkg --nobuild --nodeps', | ||||||
| 			'source PKGBUILD' | 			'source PKGBUILD', | ||||||
| 			// The build container checks whether the package is already present on the server | 			// The build container checks whether the package is already present on the server | ||||||
| 			"curl --head --fail $conf.address/\$pkgname-\$pkgver-\$pkgrel-\$(uname -m).pkg.tar.zst && exit 0" | 			'curl --head --fail $conf.address/\$pkgname-\$pkgver-\$pkgrel-\$(uname -m).pkg.tar.zst && exit 0', | ||||||
| 			'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/publish; done' | 			'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/publish; done', | ||||||
| 		] | 		] | ||||||
| 
 | 
 | ||||||
| 		// We convert the list of commands into a base64 string, which then gets | 		// We convert the list of commands into a base64 string, which then gets | ||||||
|  |  | ||||||
|  | @ -14,6 +14,8 @@ pub fn pull_image(image string, tag string) ?http.Response { | ||||||
| 	return request('POST', urllib.parse('/v1.41/images/create?fromImage=$image&tag=$tag') ?) | 	return request('POST', urllib.parse('/v1.41/images/create?fromImage=$image&tag=$tag') ?) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // create_image_from_container creates a new image from a container with the | ||||||
|  | // given repo & tag, given the container's ID. | ||||||
| pub fn create_image_from_container(id string, repo string, tag string) ?Image { | pub fn create_image_from_container(id string, repo string, tag string) ?Image { | ||||||
| 	res := request('POST', urllib.parse('/v1.41/commit?container=$id&repo=$repo&tag=$tag') ?) ? | 	res := request('POST', urllib.parse('/v1.41/commit?container=$id&repo=$repo&tag=$tag') ?) ? | ||||||
| 
 | 
 | ||||||
|  | @ -24,6 +26,7 @@ pub fn create_image_from_container(id string, repo string, tag string) ?Image { | ||||||
| 	return json.decode(Image, res.text) or {} | 	return json.decode(Image, res.text) or {} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // remove_image removes the image with the given ID. | ||||||
| pub fn remove_image(id string) ?bool { | pub fn remove_image(id string) ?bool { | ||||||
| 	res := request('DELETE', urllib.parse('/v1.41/images/$id') ?) ? | 	res := request('DELETE', urllib.parse('/v1.41/images/$id') ?) ? | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue