Skip to content

Commit 2e21013

Browse files
committed
provide a way to build the package and keep the tar archive
Example: $> NOCPIO=1 build-packages-for-obs uyuni-tools
1 parent 62b7108 commit 2e21013

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

bin/build-packages-for-obs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Usage: build-packages-for-obs.sh [PACKAGE]..
2222
Build package for submission to OBS from the current HEAD. Without argument
2323
all packages mentioned in .tito/packages or rel-eng/packages are processed.
2424
Package directories will be created in \$WORKSPACE/SRPMS/<package> ($WORKSPACE).
25+
26+
To build tar archives instead of CPIO, set "NOCPIO" environment variable.
2527
EOF
2628
exit 0
2729
}
@@ -149,32 +151,37 @@ while read PKG_NAME PKG_VER PKG_DIR; do
149151
continue 2
150152
fi
151153

152-
# Convert to obscpio
153-
SPEC_VER=$(sed -n -e 's/^Version:\s*\(.*\)/\1/p' ${T_DIR}/${PKG_NAME}.spec)
154-
SOURCE=$(sed -n -e 's/^\(Source\|Source0\):\s*.*[[:space:]\/]\(.*\)/\2/p' ${T_DIR}/${PKG_NAME}.spec|sed -e "s/%{name}/${PKG_NAME}/"|sed -e "s/%{version}/${SPEC_VER}/")
155-
SPEC_REL=$(sed -n -e 's/^Release: \+\([0-9]\).*/\1/p' ${T_DIR}/${PKG_NAME}.spec)
156-
# If the package does not have sources, we don't need to repackage them
157-
if [ "${SOURCE}" != "" ]; then
158-
FOLDER=$(tar -tf ${T_DIR}/${SOURCE}|head -1|sed -e 's/\///')
159-
(cd ${T_DIR}; tar -xf ${SOURCE}; rm ${SOURCE}; mv ${FOLDER} ${PKG_NAME}; find ${PKG_NAME} | cpio --create --format=newc --reproducible > ${FOLDER}.obscpio; rm -rf ${PKG_NAME})
160-
fi
161-
# Move to destination
162-
mv "$T_DIR" "$SRPM_DIR/$PKG_NAME"
163-
# If the package does not have sources, we don't need service or .obsinfo file
164-
if [ "${SOURCE}" != "" ]; then
165-
# Copy service
166-
if [ -e "${BASE_DIR}/../_service" ]; then
167-
cp ${BASE_DIR}/../_service "${SRPM_DIR}/${PKG_NAME}"
168-
else
169-
cp ${SHARE_DIR}/_service "${SRPM_DIR}/${PKG_NAME}"
154+
if [ -n "$NOCPIO" ]; then
155+
# Move to destination
156+
mv "$T_DIR" "$SRPM_DIR/$PKG_NAME"
157+
else
158+
# Convert to obscpio
159+
SPEC_VER=$(sed -n -e 's/^Version:\s*\(.*\)/\1/p' ${T_DIR}/${PKG_NAME}.spec)
160+
SOURCE=$(sed -n -e 's/^\(Source\|Source0\):\s*.*[[:space:]\/]\(.*\)/\2/p' ${T_DIR}/${PKG_NAME}.spec|sed -e "s/%{name}/${PKG_NAME}/"|sed -e "s/%{version}/${SPEC_VER}/")
161+
SPEC_REL=$(sed -n -e 's/^Release: \+\([0-9]\).*/\1/p' ${T_DIR}/${PKG_NAME}.spec)
162+
# If the package does not have sources, we don't need to repackage them
163+
if [ "${SOURCE}" != "" ]; then
164+
FOLDER=$(tar -tf ${T_DIR}/${SOURCE}|head -1|sed -e 's/\///')
165+
(cd ${T_DIR}; tar -xf ${SOURCE}; rm ${SOURCE}; mv ${FOLDER} ${PKG_NAME}; find ${PKG_NAME} | cpio --create --format=newc --reproducible > ${FOLDER}.obscpio; rm -rf ${PKG_NAME})
170166
fi
171-
# Create .obsinfo file
172-
cat > "${SRPM_DIR}/${PKG_NAME}/${PKG_NAME}.obsinfo" <<EOF
167+
# Move to destination
168+
mv "$T_DIR" "$SRPM_DIR/$PKG_NAME"
169+
# If the package does not have sources, we don't need service or .obsinfo file
170+
if [ "${SOURCE}" != "" ]; then
171+
# Copy service
172+
if [ -e "${BASE_DIR}/../_service" ]; then
173+
cp ${BASE_DIR}/../_service "${SRPM_DIR}/${PKG_NAME}"
174+
else
175+
cp ${SHARE_DIR}/_service "${SRPM_DIR}/${PKG_NAME}"
176+
fi
177+
# Create .obsinfo file
178+
cat > "${SRPM_DIR}/${PKG_NAME}/${PKG_NAME}.obsinfo" <<EOF
173179
name: ${PKG_NAME}
174180
version: $(echo ${FOLDER}|sed -e "s/${PKG_NAME}-//")
175181
mtime: $(date +%s)
176182
commit: $(git rev-parse --verify HEAD)
177183
EOF
184+
fi
178185
fi
179186
# Release is handled by the Buildservice
180187
# With untagged changes we can only build using --test with tito build.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Support building with tar archive instead of cpio

0 commit comments

Comments
 (0)