Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
abuild
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
abuild
Commits
e3a2e14f
Commit
e3a2e14f
authored
Apr 05, 2017
by
Kaarle Ritvanen
Committed by
Timo Teräs
Jun 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
abuild: build in chroot
This patch is based on earlier work by Timo Teräs.
parent
5a4e6f38
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
161 additions
and
3 deletions
+161
-3
Makefile
Makefile
+1
-1
abuild-rmtemp.c
abuild-rmtemp.c
+49
-0
abuild-sudo.c
abuild-sudo.c
+1
-0
abuild.conf
abuild.conf
+2
-2
abuild.in
abuild.in
+108
-0
No files found.
Makefile
View file @
e3a2e14f
...
...
@@ -10,7 +10,7 @@ datadir ?= $(prefix)/share/$(PACKAGE)
SCRIPTS
:=
abuild abuild-keygen abuild-sign newapkbuild
\
abump apkgrel buildlab apkbuild-cpan checkapk
\
apkbuild-gem-resolver
USR_BIN_FILES
:=
$(SCRIPTS)
abuild-tar abuild-gzsplit abuild-sudo abuild-fetch
USR_BIN_FILES
:=
$(SCRIPTS)
abuild-tar abuild-gzsplit abuild-sudo abuild-fetch
abuild-rmtemp
SAMPLES
:=
sample.APKBUILD sample.initd sample.confd
\
sample.pre-install sample.post-install
AUTOTOOLS_TOOLCHAIN_FILES
:=
config.sub config.guess
...
...
abuild-rmtemp.c
0 → 100644
View file @
e3a2e14f
/*
* abuild-rmtemp
* Copyright (c) 2017 Kaarle Ritvanen
* Distributed under GPL-2
*/
#include <err.h>
#include <errno.h>
#include <ftw.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#define PREFIX "/var/tmp/abuild."
static
void
fail
()
{
errx
(
1
,
"%s"
,
strerror
(
errno
));
}
static
int
handler
(
const
char
*
fpath
,
const
struct
stat
*
sb
,
int
typeflag
,
struct
FTW
*
ftwbuf
)
{
return
remove
(
fpath
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
2
)
return
0
;
if
(
getuid
())
{
argv
[
0
]
=
"-abuild-rmtemp"
;
execv
(
"/usr/bin/abuild-sudo"
,
argv
);
}
if
(
strncmp
(
argv
[
1
],
PREFIX
,
strlen
(
PREFIX
))
||
\
strchr
(
argv
[
1
]
+
strlen
(
PREFIX
),
'/'
))
errx
(
1
,
"Invalid path: %s"
,
argv
[
1
]);
struct
stat
s
;
if
(
lstat
(
argv
[
1
],
&
s
))
fail
();
struct
passwd
*
p
=
getpwnam
(
getenv
(
"USER"
));
if
(
!
p
)
errx
(
1
,
"Incorrect user"
);
if
(
s
.
st_uid
!=
p
->
pw_uid
)
errx
(
1
,
"Permission denied"
);
if
(
nftw
(
argv
[
1
],
handler
,
512
,
FTW_DEPTH
))
fail
();
return
0
;
}
abuild-sudo.c
View file @
e3a2e14f
...
...
@@ -27,6 +27,7 @@ static const char* valid_cmds[] = {
"/bin/addgroup"
,
"/usr/sbin/addgroup"
,
"/sbin/apk"
,
"/usr/bin/abuild-rmtemp"
,
NULL
};
...
...
abuild.conf
View file @
e3a2e14f
...
...
@@ -22,7 +22,7 @@ REPODEST=$HOME/packages/
#MAINTAINER="$PACKAGER"
# what to clean up after a successful build
CLEANUP
=
"srcdir pkgdir deps"
CLEANUP
=
"srcdir
bldroot
pkgdir deps"
# what to cleanup after a failed build
ERROR_CLEANUP
=
"deps"
ERROR_CLEANUP
=
"
bldroot
deps"
abuild.in
View file @
e3a2e14f
...
...
@@ -83,6 +83,11 @@ cleanup() {
fi
for
i
;
do
case
$
i
in
bldroot
)
if
[
"$BUILD_ROOT"
];
then
msg
"Cleaning up build chroot"
abuild
-
rmtemp
"$BUILD_ROOT"
fi
;;
pkgdir
)
msg
"Cleaning up pkgdir"
;
rm
-
rf
"$pkgbasedir"
;;
srcdir
)
msg
"Cleaning up srcdir"
;
rm
-
rf
"$srcdir"
;;
deps
)
...
...
@@ -1992,6 +1997,106 @@ checksum() {
echo
"sha512sums=
\"
$sha512sums
\"
"
>>
"$APKBUILD"
}
subst
()
{
(
for
key
in
$(
git
config
--
list
--
name
-
only
);
do
k
=${
key
#
abuild
.}
[
$
k
!= $key ] && \
eval
"export $k=
\"
$(git config --get $key)
\"
"
done
export
mirror
version
[
"$mirror"
]
||
mirror
=
http
://
dl
-
cdn
.
alpinelinux
.
org
/
alpine
if
[
-
z
"$version"
];
then
version
=$(
git
symbolic
-
ref
--
short
HEAD
)
[
"$version"
]
&&
\
version
=$(
expr
"$version"
:
'\([0-9]\+\(\.[0-9]\+\)*\)-'
)
&&
\
version
=
v
${
version
}
[
"$version"
]
||
version
=
edge
fi
envsubst
)
}
rootbld
()
{
if
apk_up2date
&&
[
-
z
"$force"
];
then
msg
"Package is up to date"
return
fi
[
"$CBUILD"
=
"$CHOST"
]
||
die
"rootbld: cross-building not supported currently"
local
cmd
for
cmd
in
bwrap
git
;
do
[
-
x
"$(which $cmd)"
]
||
die
"rootbld: $cmd not installed"
done
logcmd
"chroot building building $repo/$pkgname-$pkgver-r$pkgrel"
#
check
early
if
we
have
abuild
key
abuild
-
sign
--
installed
#
networking
business
sanitycheck
clean
fetch
verify
msg
"Preparing build chroot..."
BUILD_ROOT
=$(
mktemp
-
d
/
var
/
tmp
/
abuild
.
XXXXXXXXXX
)
local
aportsgit
=${
APORTSDIR
:-${
startdir
}}
mkdir
-
p
"$BUILD_ROOT/proc"
"$BUILD_ROOT/etc/apk/keys"
\
"$BUILD_ROOT/$HOME/.abuild"
"$BUILD_ROOT/$aportsgit"
\
"$BUILD_ROOT/$SRCDEST"
"$BUILD_ROOT/$REPODEST"
\
"$BUILD_ROOT/tmp/pkg"
"$BUILD_ROOT/tmp/src"
\
"$BUILD_ROOT/usr/bin"
"$pkgbasedir"
"$REPODEST"
\
"$srcdir"
cp
/
etc
/
abuild
.
conf
"$BUILD_ROOT/etc"
cp
/
etc
/
apk
/
keys
/*
"$BUILD_ROOT/etc/apk/keys"
local
repo_template
=$
aportsgit
/$
repo
/.
rootbld
-
repositories
local
repofile
=$
BUILD_ROOT
/
etc
/
apk
/
repositories
if
[
-
s
"$repo_template"
];
then
subst
<
"$repo_template"
else
local
prefix
=
'$mirror/$version'
subst
<<-
EOF
$
prefix
/
main
$
prefix
/
community
EOF
fi
>
"$repofile"
echo
"$REPODEST/$repo"
>>
"$repofile"
calcdeps
$
SUDO_APK
add
--
initdb
--
root
"$BUILD_ROOT"
--
update
\
abuild
alpine
-
base
build
-
base
git
$
hostdeps
$
builddeps
local
bwrap_opts
=
""
options_has
"net"
||
bwrap_opts
=
"$bwrap_opts --unshare-net"
bwrap
--
unshare
-
ipc
--
unshare
-
uts
$
bwrap_opts
\
--
ro
-
bind
"$BUILD_ROOT"
/
\
--
proc
/
proc
\
--
dev
-
bind
/
dev
/
dev
\
--
ro
-
bind
"$HOME/.abuild"
"$HOME/.abuild"
\
--
ro
-
bind
"$aportsgit"
"$aportsgit"
\
--
bind
"$SRCDEST"
"$SRCDEST"
\
--
bind
"$BUILD_ROOT/tmp/src"
"$srcdir"
\
--
bind
"$BUILD_ROOT/tmp/pkg"
"$pkgbasedir"
\
--
bind
"$BUILD_ROOT/tmp"
/
tmp
\
--
bind
"$REPODEST"
"$REPODEST"
\
--
hostname
"build-edge-$CARCH"
\
--
chdir
"$startdir"
\
--
setenv
PATH
/
bin
:/
usr
/
bin
:/
sbin
:/
usr
/
sbin
\
/
usr
/
bin
/
abuild
$
force
symlinksrc
unpack
prepare
mkusers
build
rootpkg
update_abuildrepo_index
cleanup
$
CLEANUP
}
stripbin
()
{
local
bin
if
options_has
"!strip"
||
[
"${subpkgarch:-$pkgarch}"
=
"noarch"
];
then
...
...
@@ -2241,6 +2346,7 @@ usage() {
listpkg
List
target
packages
package
Create
package
in
\$
REPODEST
prepare
Apply
patches
rootbld
Build
package
in
clean
chroot
rootpkg
Run
'package'
,
the
split
functions
and
create
apks
as
fakeroot
sanitycheck
Basic
sanity
check
of
APKBUILD
snapshot
Create
a
\$
giturl
or
\$
svnurl
snapshot
and
upload
to
\$
disturl
...
...
@@ -2308,6 +2414,8 @@ repo=${repo##*/}
SRCDEST
=${
SRCDEST
:-$
startdir
}
BUILD_ROOT
=
#
set
a
default
CC
:
${
CC
:=
gcc
}
export
CC
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment