forked from ChimeraTK/DebianPackagingScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublishDebianPackages
executable file
·131 lines (108 loc) · 5.92 KB
/
publishDebianPackages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash -e
WD=`pwd`
# load configuration
source config.sh
# load master-control file
if [ ! -f master-control ]; then
echo "No master_control file found. Run the master script first."
exit 1
fi
source master-control
PackageArchive=`eval echo $PackageArchive`
# check for local modifications in the DebianBuildVersions directory
${WD}/checkIfBuildVersionsCommitted || exit 1
# Check that there are debian packages and return an error if not
if [ ! -d pbuilder-result ]; then
echo "No pbuilder-result directory found. Run the master script first."
exit 1
fi
cd ${WD}/pbuilder-result/dists/${distribution}/main/binary-${arch}
# check that none of the packages already exists in the repositories
wget -q "http://doocspkgs.desy.de/pub/doocs/dists/${distribution}/main/binary-${arch}/Packages" -O "${WD}/Packages.DESY"
for debfile in *.deb ; do
if [ -n "`grep \"$debfile\" \"${WD}/Packages.DESY\"`" ]; then
echo "The package $debfile is currently already in the Debian repository. Publication is not allowed!"
echo "Probably someone else published packages in parallel with you. In this case, delete the local changes in the DebianBuildVersions repository and start the entire package building process from the beginnin!"
exit 1
fi
done
# actually perform the installation of each package
for package in "${!package_buildcmd[@]}"; do # loop over all packages in the list (note: this is *not* the list of .deb files but the list of projects!)
# get the path to the control file from the build command (argument to makeDebianPackage)
BUILD_CONTROL_FILE=`echo ${package_buildcmd[$package]} | sed -e "s|^./makeDebianPackage.*Debian|${WD}/Debian|"`/control
# obtain list of package names from the control file and form wildcards to match the deb files
PACKAGE_FILES_WILDCARDS_DEB=$(awk 'BEGIN{ORS=" "} /^Package:/{print $2"_*.deb"}' ${BUILD_CONTROL_FILE})
# derive list of debug packages from this - they are not mentioned in the control files
PACKAGE_FILES_WILDCARDS_DBGSYM=$(awk 'BEGIN{ORS=" "} /^Package:/{print $2"-dbgsym_*.deb"}' ${BUILD_CONTROL_FILE})
# New for focal - debug packages have .ddeb suffix now
PACKAGE_FILES_WILDCARDS_DBGSYM="${PACKAGE_FILES_WILDCARDS_DBGSYM} $(awk 'BEGIN{ORS=" "} /^Package:/{print $2"-dbgsym_*.ddeb"}' ${BUILD_CONTROL_FILE})"
# Filter dbgsym package names against available packages since they may or may not have been build
TMPPKG=""
for p in ${PACKAGE_FILES_WILDCARDS_DBGSYM} ; do
if ls ${p} >/dev/null 2>&1 ; then
TMPPKG="${TMPPKG} ${p}"
fi
done
PACKAGE_FILES_WILDCARDS_DBGSYM="${TMPPKG}"
# obtain source package name from the control file and form wildcards to match the changes file
PACKAGE_FILES_WILDCARDS_CHANGES=$(awk 'BEGIN{ORS=" "} /^Source:/{print $2"_*.changes"}' ${BUILD_CONTROL_FILE})
# merge the wildcards
PACKAGE_FILES_WILDCARDS="${PACKAGE_FILES_WILDCARDS_DEB} ${PACKAGE_FILES_WILDCARDS_CHANGES} ${PACKAGE_FILES_WILDCARDS_DBGSYM}"
# obtain content of Target-repositories variable from CONFIG file
TARGET_REPOSITORIES=`grep '^Target-repositories: ' ${WD}/DebianBuildVersions/${package}/CONFIG | sed -e 's/^Target-repositories: //'`
# Step 1: Remove an older version of the package
# -- from the package archive
# -- from the actual repository
# This is done by writing a script, copying it to the InstallHost and executing it there.
echo "${PACKAGE_FILES_WILDCARDS_DEB}"
echo "${PACKAGE_FILES_WILDCARDS_DBGSYM}"
TEMPFILE=`mktemp -p .`
echo "#!/bin/bash -e" > $TEMPFILE
echo "cd ${PackageArchive}" >> $TEMPFILE
echo "for p in ${PACKAGE_FILES_WILDCARDS_CHANGES}; do" >> $TEMPFILE
echo " if [ ! -f \"\$p\" ]; then continue ; fi" >> $TEMPFILE
echo " echo mv \"\$p\" ../old" >> $TEMPFILE
echo " mv \"\$p\" ../old" >> $TEMPFILE
echo "done" >> $TEMPFILE
echo "for p in ${PACKAGE_FILES_WILDCARDS_DBGSYM}; do" >> $TEMPFILE
echo " if [ ! -f \"\$p\" ]; then continue ; fi" >> $TEMPFILE
echo " packname=\`dpkg-deb -f \$p Package\`" >> $TEMPFILE
echo " echo mv \"\$p\" ../old" >> $TEMPFILE
echo " mv \"\$p\" ../old" >> $TEMPFILE
for REPO in ${TARGET_REPOSITORIES}; do
echo " echo sudo -H reprepro --waitforlock 2 -Vb ${RepositoryDirectories[${REPO}]} remove ${distribution} \"\$packname\"" >> $TEMPFILE
echo " sudo -H reprepro --waitforlock 2 -Vb ${RepositoryDirectories[${REPO}]} remove ${distribution} \"\$packname\"" >> $TEMPFILE
done
echo "done" >> $TEMPFILE
echo "for p in ${PACKAGE_FILES_WILDCARDS_DEB}; do" >> $TEMPFILE
echo " if [ ! -f \"\$p\" ]; then continue ; fi" >> $TEMPFILE
echo " packname=\`dpkg-deb -f \$p Package\`" >> $TEMPFILE
echo " echo mv \"\$p\" ../old" >> $TEMPFILE
echo " mv \"\$p\" ../old" >> $TEMPFILE
for REPO in ${TARGET_REPOSITORIES}; do
echo " echo sudo -H reprepro --waitforlock 2 -Vb ${RepositoryDirectories[${REPO}]} remove ${distribution} \"\$packname\"" >> $TEMPFILE
echo " sudo -H reprepro --waitforlock 2 -Vb ${RepositoryDirectories[${REPO}]} remove ${distribution} \"\$packname\"" >> $TEMPFILE
done
echo "done" >> $TEMPFILE
echo "rm \$HOME/$TEMPFILE" >> $TEMPFILE
chmod +x $TEMPFILE
scp $TEMPFILE ${InstallHost}:$TEMPFILE
ssh ${InstallHost} $TEMPFILE
rm $TEMPFILE
# Step 2: Copy the files to the package archive
scp ${PACKAGE_FILES_WILDCARDS} ${InstallHost}:${PackageArchive}
# Step 3: Install to the repository
for REPO in ${TARGET_REPOSITORIES}; do
PUBLISH_FILES_WILDCARDS="${PACKAGE_FILES_WILDCARDS_DEB} ${PACKAGE_FILES_WILDCARDS_DBGSYM}"
for FILE in ${PUBLISH_FILES_WILDCARDS} ; do
ssh ${InstallHost} sudo -H reprepro --ignore=extension --waitforlock 2 -Vb \
${RepositoryDirectories[${REPO}]} includedeb ${distribution} \
${PackageArchive}/${FILE}
done
done
# Remove just installed files from the local pbuilder-result directory
rm ${PACKAGE_FILES_WILDCARDS}
done
# Everything installed: remove the entire pbuilder-result directory
cd ${WD}
rm -rf pbuilder-result master-control debian_package